From patchwork Tue Feb 15 19:04:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12747562 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23018C433F5 for ; Tue, 15 Feb 2022 19:29:04 +0000 (UTC) Received: from localhost ([::1]:42256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK3VW-0000b9-Qz for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 14:29:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK380-0000Uw-HE for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:44 -0500 Received: from [2607:f8b0:4864:20::f2c] (port=40636 helo=mail-qv1-xf2c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nK37y-0002j6-H6 for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:44 -0500 Received: by mail-qv1-xf2c.google.com with SMTP id v10so26537qvk.7 for ; Tue, 15 Feb 2022 11:04:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q/a52Ymyen9MRJFePDxCcyYr+mACfmfhjAFtBkPNnik=; b=bj7+aSCws3ia/mOQt+JJ63Hv+pmA+6X/usethwlir31+s8ZXX5E4jKmcG8VE8BlFsQ eX7NlY4x2v0PEIWXPEuCPOBOqmK0Y3DUbT3+pSVvZFsfDzPb9tEewTv4goFp23/E1CRT 5JZtMS3pW8j7sBerC47zKFojaPTHVJ0aFxiipwP6IWwsjIDB6fHadBI6BpOcT2M/v4wq t8NB9kI1sFC+jiiq8IOyOp6WEl/1fJpVAc5InLxEK5/PEWDXU81mBwC4KEmbbbrKEBT2 epKYJD81Oq6ESyTqJ1eGtpvyMV9CEq07QhQSjlcHwFn4LBzztDKvROqjlWqt/KDFhGOb 2Ulw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q/a52Ymyen9MRJFePDxCcyYr+mACfmfhjAFtBkPNnik=; b=qYV+pG8lmitu4ZEWjxMfzt4wWducWgBN2OEZid91dHvY+ox5u+8V/O/zfkq+GFw0za B7+/hv1xFwwW7TxtGm6IylLET1xdDj3dMj4VrtZqbfKOXmwsx1B7vYZZZBaPnjLruvvd Vy5bfvV2BGy0pIl4nqEd/ogNfu8lWk6bb5QB9zvOo+tjmCMRnVOjTSQtE3C4s80eYz+E EmwVqV0BKRXZKwG22bkk18MPj2ngy2QfGUIcwCl/vyYK0xd7KJq6Y+DFQE04iqtRzYKH c1IeRKLGGC4LeD6fV1lwD3KOXty9yjCHJR+ADGM58+edlXxM7MiczcbtmUGBx2bzdGwr RdsQ== X-Gm-Message-State: AOAM530xJVbeHH5Syjdu/uixjsHnzrqeUvgxvBg/ph/FwbqaN2zdubGJ 0ZFs5Ii85jEwvaVVYPdbQG5gv+226UkebA== X-Google-Smtp-Source: ABdhPJwR6/OriVWYUayfUKBTmm2E9EYc5Lzc+DO/8v/SibYPfgYsXJRZMunQxrGMMB/7kstsM1Q08w== X-Received: by 2002:a05:6214:5005:: with SMTP id jo5mr422712qvb.19.1644951881040; Tue, 15 Feb 2022 11:04:41 -0800 (PST) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w10sm21364527qtj.73.2022.02.15.11.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 11:04:40 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v7 01/11] 9p: linux: Fix a couple Linux assumptions Date: Tue, 15 Feb 2022 14:04:16 -0500 Message-Id: <20220215190426.56130-2-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215190426.56130-1-wwcohen@gmail.com> References: <20220215190426.56130-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f2c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2c; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf2c.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.904, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer - Guard Linux only headers. - Add qemu/statfs.h header to abstract over the which headers are needed for struct statfs - Define `ENOATTR` only if not only defined (it's defined in system headers on Darwin). Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch While it might at first appear that fsdev/virtfs-proxy-header.c would need similar adjustment for darwin as file-op-9p here, a later patch in this series disables virtfs-proxy-helper for non-Linux. Allowing virtfs-proxy-helper on darwin could potentially be an additional optimization later. [Will Cohen: - Fix headers for Alpine - Integrate statfs.h back into file-op-9p.h - Remove superfluous header guards from file-opt-9p - Add note about virtfs-proxy-helper being disabled on non-Linux for this patch series] Signed-off-by: Will Cohen Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Greg Kurz --- fsdev/file-op-9p.h | 9 ++++++++- hw/9pfs/9p-local.c | 2 ++ hw/9pfs/9p.c | 4 ++++ include/qemu/xattr.h | 4 +++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h index 8fd89f0447..4997677460 100644 --- a/fsdev/file-op-9p.h +++ b/fsdev/file-op-9p.h @@ -16,10 +16,17 @@ #include #include -#include #include "qemu-fsdev-throttle.h" #include "p9array.h" +#ifdef CONFIG_LINUX +# include +#endif +#ifdef CONFIG_DARWIN +# include +# include +#endif + #define SM_LOCAL_MODE_BITS 0600 #define SM_LOCAL_DIR_MODE_BITS 0700 diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 210d9e7705..1a5e3eed73 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -32,10 +32,12 @@ #include "qemu/error-report.h" #include "qemu/option.h" #include +#ifdef CONFIG_LINUX #include #ifdef CONFIG_LINUX_MAGIC_H #include #endif +#endif #include #ifndef XFS_SUPER_MAGIC diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 15b3f4d385..9c63e14b28 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -32,7 +32,11 @@ #include "migration/blocker.h" #include "qemu/xxhash.h" #include +#ifdef CONFIG_LINUX #include +#else +#include +#endif int open_fd_hw; int total_open_fd; diff --git a/include/qemu/xattr.h b/include/qemu/xattr.h index a83fe8e749..f1d0f7be74 100644 --- a/include/qemu/xattr.h +++ b/include/qemu/xattr.h @@ -22,7 +22,9 @@ #ifdef CONFIG_LIBATTR # include #else -# define ENOATTR ENODATA +# if !defined(ENOATTR) +# define ENOATTR ENODATA +# endif # include #endif From patchwork Tue Feb 15 19:04:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12747564 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD56DC433F5 for ; Tue, 15 Feb 2022 19:35:53 +0000 (UTC) Received: from localhost ([::1]:50744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK3c8-0006X1-Po for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 14:35:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK382-0000YO-4P for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:46 -0500 Received: from [2607:f8b0:4864:20::736] (port=37536 helo=mail-qk1-x736.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nK380-0002jK-4l for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:45 -0500 Received: by mail-qk1-x736.google.com with SMTP id 71so18211302qkf.4 for ; Tue, 15 Feb 2022 11:04:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aU38QXrWIFeszm233oTiu8pqJG9R/BMWH8IeCEGMGvc=; b=if8EoBF93CN41Elg221j8HZak/5KMvhkebm5HhVaYmU1EifxoSEfxcvn6w7SLUsMKn vqNYZ8CpqKS1p/t0GAQQQrKp+Da637mzRsrXjucWqn+aotczT/RpWDS5yXVg7lKjIXQa Vnzvzecd/eTMoHp1Pqm/RRYhjcG9Tmn9Dga7/7EdcLY6LNVjA5EXnnpg75AkuCn5GrgB Sd+hrG2Y6vkBiP6iyAfsJatVNVar3qeqjIBlHig0Gz2gXN1Z9nimH8azDL0rHTk+Xrus rDUqQ25+MZG3XSgYVMe3H9x/i8EQaND0+O6ZH/kmnz2oz4fTplekDhO7hsFZo/JpEHOa MNOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aU38QXrWIFeszm233oTiu8pqJG9R/BMWH8IeCEGMGvc=; b=1Kg2OWER27i0c58uhBIob+D+cGtTdsMWZSB57k9KGbSLls0u+AAHs4T4kxWhiZpAqv PM25/BoEoPRnuicXmDAnZh+bMjCrAIgeSQCjLwkRXO0E0rOOOTkE+cSRjr8egJZngZYH sCsMpBuBs5l3073YcIK/CsuUd9jn67/wknG45KUHQn2fQeRuynrc3eBkYCt4cPLxgl9J v3/gZ7NiWWdUfrpZPhWAOE1juT4SYi9Cz3g9vushR6A8RLDfdljcFzdvt1zUAvz4ZDdP 5tTmE+yG0h5QLC5NRfZeczAn7bOGK1cN/iDdzXFbqbNkkfXhuSJJmollFHRM/3hHaVL1 WEKg== X-Gm-Message-State: AOAM532iblyB6KIC5VgZprSRHhDCE/xoZySbvJv3G4aP1Y0xWsAxFWau 0zHWWYdqvCffXsd1EiEIxOUZYOSPiT+Wfw== X-Google-Smtp-Source: ABdhPJxjm52TCK0k9w6f7K3clCuBvHUu7Rt7ecMeGIE0N6y7JRIwgAfOS1vQDsrlCZZimTVB1B86XQ== X-Received: by 2002:a05:620a:70f:: with SMTP id 15mr253071qkc.682.1644951882784; Tue, 15 Feb 2022 11:04:42 -0800 (PST) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w10sm21364527qtj.73.2022.02.15.11.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 11:04:41 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v7 02/11] 9p: Rename 9p-util -> 9p-util-linux Date: Tue, 15 Feb 2022 14:04:17 -0500 Message-Id: <20220215190426.56130-3-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215190426.56130-1-wwcohen@gmail.com> References: <20220215190426.56130-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::736 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::736; envelope-from=wwcohen@gmail.com; helo=mail-qk1-x736.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.904, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer The current file only has the Linux versions of these functions. Rename the file accordingly and update the Makefile to only build it on Linux. A Darwin version of these will follow later in the series. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen Reviewed-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daudé --- hw/9pfs/{9p-util.c => 9p-util-linux.c} | 2 +- hw/9pfs/meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename hw/9pfs/{9p-util.c => 9p-util-linux.c} (97%) diff --git a/hw/9pfs/9p-util.c b/hw/9pfs/9p-util-linux.c similarity index 97% rename from hw/9pfs/9p-util.c rename to hw/9pfs/9p-util-linux.c index 3221d9b498..398614a5d0 100644 --- a/hw/9pfs/9p-util.c +++ b/hw/9pfs/9p-util-linux.c @@ -1,5 +1,5 @@ /* - * 9p utilities + * 9p utilities (Linux Implementation) * * Copyright IBM, Corp. 2017 * diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index 99be5d9119..1b28e70040 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -4,7 +4,6 @@ fs_ss.add(files( '9p-posix-acl.c', '9p-proxy.c', '9p-synth.c', - '9p-util.c', '9p-xattr-user.c', '9p-xattr.c', '9p.c', @@ -14,6 +13,7 @@ fs_ss.add(files( 'coth.c', 'coxattr.c', )) +fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-util-linux.c')) fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c')) softmmu_ss.add_all(when: 'CONFIG_FSDEV_9P', if_true: fs_ss) From patchwork Tue Feb 15 19:04:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12747522 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A736C433FE for ; Tue, 15 Feb 2022 19:06:51 +0000 (UTC) Received: from localhost ([::1]:38234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK3A2-00035B-14 for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 14:06:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK383-0000Zn-Gh for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:47 -0500 Received: from [2607:f8b0:4864:20::834] (port=43597 helo=mail-qt1-x834.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nK381-0002js-MT for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:47 -0500 Received: by mail-qt1-x834.google.com with SMTP id x5so19491407qtw.10 for ; Tue, 15 Feb 2022 11:04:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s9PuenkLpugsLgi/PBoKGw80paVQIWqbF1SUukEIRZI=; b=gIKy3LatdgoFnH8Afv6Kr9zuAR4LD75qgIY0IP4MPhXsaX73jm8hcajPgVEQVB7e3J 6WVvyAMLuAZgj27m+7n2stRB1DPiGMfhmAGS/fJ0U3yaMymHwhIXYbqM1dF6V0CP4Ffw wsF20ijraqRjxV2MmhWs7FNY/uf+gxlAV0FQtC2Vl11HX1tr7CqImRkH3Suralp7g9UB u8tcrXfzaXoWjzBRr+OaZYtnCl3wrLVK1vKy0iTFjiyhno+kflS44MSmVNDpeGPOv6I0 QCCXHdG0dITerYgXcI5qhPHQK5YvNOdxB7KH5XLwkvnESFJZTtd6OBMd0bH80BPABwzO UbsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s9PuenkLpugsLgi/PBoKGw80paVQIWqbF1SUukEIRZI=; b=RUC4Vrz+pBcSd5xzQFoOKsD2knc6S+TjT7LBtK1jMWuWv1yBME0oVaxaGIQEPDGuJl wDJri25GRWd11Gyguq6F7s5obmjqLjOgVVFdfxWdMVLRvRqnfMKawbNCAHfckHV1iVh7 ADdW/+T9sJkXGGBhflnVptn6NLwRDppgy4NDOgUs8Pz+cJRj5ImaAb6TIrfa+lcLgRiQ z42D/eXxhGxm8M46bjgXNLXclRlDOci5wDVbQFS3aIaxKTkbCqsNXylsYVZMyzgTC0Mq S4uWy3dNGPG+J3ZIAEO5tCgnnIdUko5GiardzoyPKuQYU+LoQp+046HbYvhul5K5XU6J tfNQ== X-Gm-Message-State: AOAM533GxkIzMj86QwnvdkdqIAEAir4sJCwyD05ijrCCbGYySofJZQ0m 7noNkwXo6+5Dp5idT7rfn4CXYycmsrmKgA== X-Google-Smtp-Source: ABdhPJyYSlhjSMyzkC9QqKEveWO0+usekEEpPSZpj0z36jA8ZngmAj8yeDrd727a929FKnwzbFCiRA== X-Received: by 2002:a05:622a:54d:: with SMTP id m13mr461162qtx.106.1644951884293; Tue, 15 Feb 2022 11:04:44 -0800 (PST) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w10sm21364527qtj.73.2022.02.15.11.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 11:04:43 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v7 03/11] 9p: darwin: Handle struct stat(fs) differences Date: Tue, 15 Feb 2022 14:04:18 -0500 Message-Id: <20220215190426.56130-4-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215190426.56130-1-wwcohen@gmail.com> References: <20220215190426.56130-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::834 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::834; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x834.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.904, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch [Will Cohen: - Note lack of f_namelen and f_frsize on Darwin - Ensure that tv_sec and tv_nsec are both initialized for Darwin and non-Darwin] Signed-off-by: Will Cohen --- hw/9pfs/9p-proxy.c | 22 ++++++++++++++++++++-- hw/9pfs/9p-synth.c | 2 ++ hw/9pfs/9p.c | 16 ++++++++++++++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index 09bd9f1464..b1664080d8 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -123,10 +123,16 @@ static void prstatfs_to_statfs(struct statfs *stfs, ProxyStatFS *prstfs) stfs->f_bavail = prstfs->f_bavail; stfs->f_files = prstfs->f_files; stfs->f_ffree = prstfs->f_ffree; +#ifdef CONFIG_DARWIN + /* f_namelen and f_frsize do not exist on Darwin */ + stfs->f_fsid.val[0] = prstfs->f_fsid[0] & 0xFFFFFFFFU; + stfs->f_fsid.val[1] = prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; +#else stfs->f_fsid.__val[0] = prstfs->f_fsid[0] & 0xFFFFFFFFU; stfs->f_fsid.__val[1] = prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; stfs->f_namelen = prstfs->f_namelen; stfs->f_frsize = prstfs->f_frsize; +#endif } /* Converts proxy_stat structure to VFS stat structure */ @@ -143,12 +149,24 @@ static void prstat_to_stat(struct stat *stbuf, ProxyStat *prstat) stbuf->st_size = prstat->st_size; stbuf->st_blksize = prstat->st_blksize; stbuf->st_blocks = prstat->st_blocks; + stbuf->st_atime = prstat->st_atim_sec; + stbuf->st_mtime = prstat->st_mtim_sec; + stbuf->st_ctime = prstat->st_ctim_sec; +#ifdef CONFIG_DARWIN + stbuf->st_atimespec.tv_sec = prstat->st_atim_sec; + stbuf->st_mtimespec.tv_sec = prstat->st_mtim_sec; + stbuf->st_ctimespec.tv_sec = prstat->st_ctim_sec; + stbuf->st_atimespec.tv_nsec = prstat->st_atim_nsec; + stbuf->st_mtimespec.tv_nsec = prstat->st_mtim_nsec; + stbuf->st_ctimespec.tv_nsec = prstat->st_ctim_nsec; +#else stbuf->st_atim.tv_sec = prstat->st_atim_sec; + stbuf->st_mtim.tv_sec = prstat->st_mtim_sec; + stbuf->st_ctim.tv_sec = prstat->st_ctim_sec; stbuf->st_atim.tv_nsec = prstat->st_atim_nsec; - stbuf->st_mtime = prstat->st_mtim_sec; stbuf->st_mtim.tv_nsec = prstat->st_mtim_nsec; - stbuf->st_ctime = prstat->st_ctim_sec; stbuf->st_ctim.tv_nsec = prstat->st_ctim_nsec; +#endif } /* diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index b38088e066..4a4a776d06 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -427,7 +427,9 @@ static int synth_statfs(FsContext *s, V9fsPath *fs_path, stbuf->f_bsize = 512; stbuf->f_blocks = 0; stbuf->f_files = synth_node_count; +#ifndef CONFIG_DARWIN stbuf->f_namelen = NAME_MAX; +#endif return 0; } diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 9c63e14b28..1563d7b7c6 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1313,11 +1313,17 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf, v9lstat->st_blksize = stat_to_iounit(pdu, stbuf); v9lstat->st_blocks = stbuf->st_blocks; v9lstat->st_atime_sec = stbuf->st_atime; - v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec; v9lstat->st_mtime_sec = stbuf->st_mtime; - v9lstat->st_mtime_nsec = stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_sec = stbuf->st_ctime; +#ifdef CONFIG_DARWIN + v9lstat->st_atime_nsec = stbuf->st_atimespec.tv_nsec; + v9lstat->st_mtime_nsec = stbuf->st_mtimespec.tv_nsec; + v9lstat->st_ctime_nsec = stbuf->st_ctimespec.tv_nsec; +#else + v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec; + v9lstat->st_mtime_nsec = stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_nsec = stbuf->st_ctim.tv_nsec; +#endif /* Currently we only support BASIC fields in stat */ v9lstat->st_result_mask = P9_STATS_BASIC; @@ -3519,9 +3525,15 @@ static int v9fs_fill_statfs(V9fsState *s, V9fsPDU *pdu, struct statfs *stbuf) f_bavail = stbuf->f_bavail / bsize_factor; f_files = stbuf->f_files; f_ffree = stbuf->f_ffree; +#ifdef CONFIG_DARWIN + fsid_val = (unsigned int)stbuf->f_fsid.val[0] | + (unsigned long long)stbuf->f_fsid.val[1] << 32; + f_namelen = NAME_MAX; +#else fsid_val = (unsigned int) stbuf->f_fsid.__val[0] | (unsigned long long)stbuf->f_fsid.__val[1] << 32; f_namelen = stbuf->f_namelen; +#endif return pdu_marshal(pdu, offset, "ddqqqqqqd", f_type, f_bsize, f_blocks, f_bfree, From patchwork Tue Feb 15 19:04:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12747526 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BE7A1C433EF for ; Tue, 15 Feb 2022 19:11:01 +0000 (UTC) Received: from localhost ([::1]:44476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK3E4-0007aa-L7 for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 14:11:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35160) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK385-0000fZ-VV for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:49 -0500 Received: from [2607:f8b0:4864:20::72c] (port=42572 helo=mail-qk1-x72c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nK383-0002kI-Io for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:49 -0500 Received: by mail-qk1-x72c.google.com with SMTP id m25so18196916qka.9 for ; Tue, 15 Feb 2022 11:04:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=usoXj/aS1VhYctCFHSsTirdJcm/7xjAPuTTAm7+v4eQ=; b=F1PweqS3cUCWyxSRXoQACIdpxrYZSpoY2I4H/kO2tCTXsM4V0aX9gfYcI69h6UVbJR g565kjBFXHCkORcGwLGts7hKRdov1rjLbVyZlmaoicyERTjfRtpG/5Fo6c0qvewHGG03 Ib0WZEiuq5RmY48mtNuE97BkXOsT9zDeIT30c45RTIOy6NyYII6qh49f39JHx1/aLBIS j7vFFVdsnwj1sFzSRlLOxWHH/bBGnoMcSkjdfoGMXBauEPDrYzLbm8VMqKJQur9pJU3y lizuTbbd+plSvjcq7f7x+Yqev1xDGOIO2eINqddj0QTBreb7a9B49I2y1dCdkG8uyA/x YPpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=usoXj/aS1VhYctCFHSsTirdJcm/7xjAPuTTAm7+v4eQ=; b=ZYixYzYhzvQO9WR/1P7miEi61NxyacqYp1Tl381Tw1rhO3EA1VPEfN4CGIDXm5uc9I IU0fBkAGFu2CxamyrAJSGhKdabyLrZmJ6XFPBOGUnQDoI4AUkYdrtfTd8Dn0qt62gvh4 hjitZ49H7K+e+PVM4tmHy+lcxqGirfuHCtj2PSqOn3ZqYMivXQBwPBIaJONH/6D0QFAP PwJoD611RiqmYIXdTS6ZPz6ruVivN/nhZXaV9LQ9ruCNLah+T7Q5KLLFqz8xCK7qmOi6 VDxNkCDhCitKH+EiW1j55tSZAUWj0arKvdsuWfD0x+0HPB/C05c5NOhJ7v/T4X8D+TzL tb2g== X-Gm-Message-State: AOAM5330AImx/2kxZefpAVlV6sAcuiboFpejI4sgKn+dHyhtzmIZKlGL NCD+Sz4NQW+67KpLCHzqoflZwgPWF7DcKQ== X-Google-Smtp-Source: ABdhPJwHZq1E6CFrgup3dGvZC48wEgCTMmvfAbaN824g7HPiJpuJKj0cpFNFSPngMHSyYf4JVTZbkw== X-Received: by 2002:a05:620a:24d5:: with SMTP id m21mr241956qkn.15.1644951886246; Tue, 15 Feb 2022 11:04:46 -0800 (PST) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w10sm21364527qtj.73.2022.02.15.11.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 11:04:45 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v7 04/11] 9p: darwin: Handle struct dirent differences Date: Tue, 15 Feb 2022 14:04:19 -0500 Message-Id: <20220215190426.56130-5-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215190426.56130-1-wwcohen@gmail.com> References: <20220215190426.56130-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::72c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=wwcohen@gmail.com; helo=mail-qk1-x72c.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.904, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Fabian Franz , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer On darwin d_seekoff exists, but is optional and does not seem to be commonly used by file systems. Use `telldir` instead to obtain the seek offset and inject it into d_seekoff, and create a qemu_dirent_off helper to call it appropriately when appropriate. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Adjust to pass testing - Ensure that d_seekoff is filled using telldir on darwin, and create qemu_dirent_off helper to decide which to access] [Fabian Franz: - Add telldir error handling for darwin] Signed-off-by: Fabian Franz [Will Cohen: - Ensure that telldir error handling uses signed int - Cleanup of telldir error handling - Remove superfluous error handling for qemu_dirent_off - Adjust formatting - Use qemu_dirent_off in codir.c] Signed-off-by: Will Cohen --- hw/9pfs/9p-local.c | 9 +++++++++ hw/9pfs/9p-proxy.c | 16 +++++++++++++++- hw/9pfs/9p-synth.c | 4 ++++ hw/9pfs/9p-util.h | 16 ++++++++++++++++ hw/9pfs/9p.c | 7 +++++-- hw/9pfs/codir.c | 4 +++- 6 files changed, 52 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 1a5e3eed73..f3272f0b43 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -562,6 +562,15 @@ again: if (!entry) { return NULL; } +#ifdef CONFIG_DARWIN + int off; + off = telldir(fs->dir.stream); + /* If telldir fails, fail the entire readdir call */ + if (off < 0) { + return NULL; + } + entry->d_seekoff = off; +#endif if (ctx->export_flags & V9FS_SM_MAPPED) { entry->d_type = DT_UNKNOWN; diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index b1664080d8..8b4b5cf7dc 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -706,7 +706,21 @@ static off_t proxy_telldir(FsContext *ctx, V9fsFidOpenState *fs) static struct dirent *proxy_readdir(FsContext *ctx, V9fsFidOpenState *fs) { - return readdir(fs->dir.stream); + struct dirent *entry; + entry = readdir(fs->dir.stream); +#ifdef CONFIG_DARWIN + if (!entry) { + return NULL; + } + int td; + td = telldir(fs->dir.stream); + /* If telldir fails, fail the entire readdir call */ + if (td < 0) { + return NULL; + } + entry->d_seekoff = td; +#endif + return entry; } static void proxy_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index 4a4a776d06..e264a03eef 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -222,7 +222,11 @@ static void synth_direntry(V9fsSynthNode *node, { strcpy(entry->d_name, node->name); entry->d_ino = node->attr->inode; +#ifdef CONFIG_DARWIN + entry->d_seekoff = off + 1; +#else entry->d_off = off + 1; +#endif } static struct dirent *synth_get_dentry(V9fsSynthNode *dir, diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 546f46dc7d..d41f37f085 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -79,3 +79,19 @@ ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, const char *name); #endif + + +/** + * Darwin has d_seekoff, which appears to function similarly to d_off. + * However, it does not appear to be supported on all file systems, + * so ensure it is manually injected earlier and call here when + * needed. + */ +inline off_t qemu_dirent_off(struct dirent *dent) +{ +#ifdef CONFIG_DARWIN + return dent->d_seekoff; +#else + return dent->d_off; +#endif +} diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 1563d7b7c6..caf3b240fe 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -27,6 +27,7 @@ #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" #include "9p-xattr.h" +#include "9p-util.h" #include "coth.h" #include "trace.h" #include "migration/blocker.h" @@ -2281,7 +2282,7 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu, count += len; v9fs_stat_free(&v9stat); v9fs_path_free(&path); - saved_dir_pos = dent->d_off; + saved_dir_pos = qemu_dirent_off(dent); } v9fs_readdir_unlock(&fidp->fs.dir); @@ -2420,6 +2421,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString name; int len, err = 0; int32_t count = 0; + off_t off; struct dirent *dent; struct stat *st; struct V9fsDirEnt *entries = NULL; @@ -2480,12 +2482,13 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, qid.version = 0; } + off = qemu_dirent_off(dent); v9fs_string_init(&name); v9fs_string_sprintf(&name, "%s", dent->d_name); /* 11 = 7 + 4 (7 = start offset, 4 = space for storing count) */ len = pdu_marshal(pdu, 11 + count, "Qqbs", - &qid, dent->d_off, + &qid, off, dent->d_type, &name); v9fs_string_free(&name); diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c index 032cce04c4..8e66205d9d 100644 --- a/hw/9pfs/codir.c +++ b/hw/9pfs/codir.c @@ -22,6 +22,8 @@ #include "qemu/coroutine.h" #include "qemu/main-loop.h" #include "coth.h" +#include "9p-xattr.h" +#include "9p-util.h" /* * Intended to be called from bottom-half (e.g. background I/O thread) @@ -167,7 +169,7 @@ static int do_readdir_many(V9fsPDU *pdu, V9fsFidState *fidp, } size += len; - saved_dir_pos = dent->d_off; + saved_dir_pos = qemu_dirent_off(dent); } /* restore (last) saved position */ From patchwork Tue Feb 15 19:04:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12747534 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A031CC433EF for ; Tue, 15 Feb 2022 19:17:50 +0000 (UTC) Received: from localhost ([::1]:51946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK3Kf-0004Sw-Ax for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 14:17:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK388-0000kv-Cx for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:52 -0500 Received: from [2607:f8b0:4864:20::82a] (port=42532 helo=mail-qt1-x82a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nK385-0002kV-G1 for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:52 -0500 Received: by mail-qt1-x82a.google.com with SMTP id s1so19502667qtw.9 for ; Tue, 15 Feb 2022 11:04:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gIGVlFzwI+BOQT0G5tpy36kLec/z/FbtOyvz6GVCXtw=; b=iTSBifTbp2bHC0SIE9SHd5uKARuJ8+xzmO0rxatJrS3LEYAe8JJmnK/uniMOMtpItf nQbfLnO0T1KgZFye6prel28Hl13sOGIBBcCrnS3shroo6N1Ryw9OKv9R5N2l35xPPbj7 yaB5dW+iy4Tn3AV6OFcPvM2IaVaXM6xs4y9qaCjk2rP61kLMp7DJMJildh+fJNflSLD4 jAQVcKWhANsz+RVx+uzQKJtps7BpRiIZ7uGzq9p3ogsF3OrYV3LxSdJ6JddpGN7D/QEp 8Ra5Y2E5H6f5Sow0vnNhU7M8wlm9lffST8GDNaxIVgPcp8fLz76UVRVTvYHdsxh1lLlo yJbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gIGVlFzwI+BOQT0G5tpy36kLec/z/FbtOyvz6GVCXtw=; b=fCSAWo5ZD4hfHwCvC+EUoDlrrTmMPUvr4fE33saJf5o9l8jTCA3vuzhgXcObFh/wpZ MWHM59cLOdn+c88MDfheFZpJr2nXOSV42NqrAjzwFtI07usY1Y0BoeqnmQ8cnWRS0OO/ l8n9+AA2qTBKoHBaZJlw9CIDqqz07NmVG2ybBznqKoBXoU1jIxbTqAYzXKFtST8LW/xL +q0YwhWbx8hbXqeRlwOQDWHQAGPJajIomrrSw316FYTguMXsO6vKjNqhqsH0r+MPFT76 kqGc1UkhKz+nDoqD6bAG+z6/F9xOlrIJUBGNJwnh5qLASI9jtcRRkJ6tkqXcA4FbPCF8 7CDw== X-Gm-Message-State: AOAM5330P3mK8jot/hzIFDwlluVEttiW9+5ME2Xtxp95D6PtyhRdWerY lwZJyCfOqLPcGzxKg4TbL8u2M48mRVqdmg== X-Google-Smtp-Source: ABdhPJy8FlwBDx0uCdpO+/muvmFO4dBptvaISQQv7qIW19kO+f1VWIGwp8LKnkRC1a8IfGCVskS8og== X-Received: by 2002:ac8:5fca:: with SMTP id k10mr383045qta.639.1644951887898; Tue, 15 Feb 2022 11:04:47 -0800 (PST) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w10sm21364527qtj.73.2022.02.15.11.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 11:04:47 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v7 05/11] 9p: darwin: Ignore O_{NOATIME, DIRECT} Date: Tue, 15 Feb 2022 14:04:20 -0500 Message-Id: <20220215190426.56130-6-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215190426.56130-1-wwcohen@gmail.com> References: <20220215190426.56130-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::82a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x82a.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.904, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Darwin doesn't have either of these flags. Darwin does have F_NOCACHE, which is similar to O_DIRECT, but has different enough semantics that other projects don't generally map them automatically. In any case, we don't support O_DIRECT on Linux at the moment either. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Adjust coding style] Signed-off-by: Will Cohen --- hw/9pfs/9p-util.h | 2 ++ hw/9pfs/9p.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index d41f37f085..0e445b5d52 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -41,6 +41,7 @@ again: fd = openat(dirfd, name, flags | O_NOFOLLOW | O_NOCTTY | O_NONBLOCK, mode); if (fd == -1) { +#ifndef CONFIG_DARWIN if (errno == EPERM && (flags & O_NOATIME)) { /* * The client passed O_NOATIME but we lack permissions to honor it. @@ -53,6 +54,7 @@ again: flags &= ~O_NOATIME; goto again; } +#endif return -1; } diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index caf3b240fe..14e84c3bcf 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -138,11 +138,20 @@ static int dotl_to_open_flags(int flags) { P9_DOTL_NONBLOCK, O_NONBLOCK } , { P9_DOTL_DSYNC, O_DSYNC }, { P9_DOTL_FASYNC, FASYNC }, +#ifndef CONFIG_DARWIN + { P9_DOTL_NOATIME, O_NOATIME }, + /* + * On Darwin, we could map to F_NOCACHE, which is + * similar, but doesn't quite have the same + * semantics. However, we don't support O_DIRECT + * even on linux at the moment, so we just ignore + * it here. + */ { P9_DOTL_DIRECT, O_DIRECT }, +#endif { P9_DOTL_LARGEFILE, O_LARGEFILE }, { P9_DOTL_DIRECTORY, O_DIRECTORY }, { P9_DOTL_NOFOLLOW, O_NOFOLLOW }, - { P9_DOTL_NOATIME, O_NOATIME }, { P9_DOTL_SYNC, O_SYNC }, }; @@ -171,10 +180,12 @@ static int get_dotl_openflags(V9fsState *s, int oflags) */ flags = dotl_to_open_flags(oflags); flags &= ~(O_NOCTTY | O_ASYNC | O_CREAT); +#ifndef CONFIG_DARWIN /* * Ignore direct disk access hint until the server supports it. */ flags &= ~O_DIRECT; +#endif return flags; } From patchwork Tue Feb 15 19:04:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12747566 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD523C433F5 for ; Tue, 15 Feb 2022 19:41:56 +0000 (UTC) Received: from localhost ([::1]:59136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK3hz-00044y-S5 for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 14:41:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK38A-0000r2-9D for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:54 -0500 Received: from [2607:f8b0:4864:20::82b] (port=40627 helo=mail-qt1-x82b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nK387-0002kj-UH for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:53 -0500 Received: by mail-qt1-x82b.google.com with SMTP id l14so19520708qtp.7 for ; Tue, 15 Feb 2022 11:04:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=42w8zH8fh4oqZPs0bvaBNjORXWqdsJUdc9cHlnfnog0=; b=Nu8nOHwBTquMCe7fcasecUcyLyHLr2x57f4QMp/IPL8gLz6pEEn47Y5L29Cf3zDqyw UetID7BrMGRPTgcRkv0dJMFUl6kQMm3VCHHnQZv6UqVjyhRQfy/Jsu3KvL61Ntetsxdy dXLnkncGKdYoZZzva7uUuCufl9TV/c4B9GlCJQpXQ4+V8EZ0FeoXk6AHCenthMy3kG0C MMIDfcRGrD2BE0eDSlfhXEgzQCA58zNMgR1/R/uc3Uvo4MbUQWfMvnBecrzE7pXIOz+P zspwgGMPX9YFzG16+ya+pLSHdbU6z1q9kzqiIEsJ5nOxc5/z9pktmx7aNMmYgkHYqlOQ 0dzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=42w8zH8fh4oqZPs0bvaBNjORXWqdsJUdc9cHlnfnog0=; b=zHtWnKdqP4MfRzU21qfmqPcvkEfkw30XE7Vhxtwb5BcIn76L9PZRHcndXjjB/XU/QT wM+MNXMT44Pd8lMYY8w+JsWZ79oFVzL7Mxu9LBOSYLQQCXWOLI8/TURVP8HZvohsKYue mJKlT5WPA7Jaj4weqZbd5d+U+Bxh/sSGFZn5ulyWQmARznKf4janqGHBHclrA4+OSvF3 g5bLat4itdT0lrWGfvhPA+SpaWKYRxBXzMmPXQDgXjQzf099v3kLglEzl7eVBBWwJnV6 H8xwhtyfe0HQlV+eBvbcYiZaas+42AWJhFWgLhEnGp5FCGGqnkaBRBNdSdzkp5JndVUC q1aA== X-Gm-Message-State: AOAM532lLfUAAoiluzfqQh0hNZ4HG2Ah74UgoW45Y8e0kRN32HMui7xm W+JcklRLST5oOysx8Z/0TL2CCHWH/0MfLQ== X-Google-Smtp-Source: ABdhPJw3A5pf4WF/W8b6L6X7omnq1hVqYtERBZ3KRECBuFx+oc/BvlLTf8SxeTCwHb+5o9psK9hHWQ== X-Received: by 2002:a05:622a:30e:: with SMTP id q14mr448767qtw.48.1644951889668; Tue, 15 Feb 2022 11:04:49 -0800 (PST) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w10sm21364527qtj.73.2022.02.15.11.04.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 11:04:48 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v7 06/11] 9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX Date: Tue, 15 Feb 2022 14:04:21 -0500 Message-Id: <20220215190426.56130-7-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215190426.56130-1-wwcohen@gmail.com> References: <20220215190426.56130-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::82b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x82b.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.904, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Fabian Franz , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch Because XATTR_SIZE_MAX is not defined on Darwin, create a cross-platform P9_XATTR_SIZE_MAX instead. [Will Cohen: - Adjust coding style - Lower XATTR_SIZE_MAX to 64k - Add explanatory context related to XATTR_SIZE_MAX] [Fabian Franz: - Move XATTR_SIZE_MAX reference from 9p.c to P9_XATTR_SIZE_MAX in 9p.h] Signed-off-by: Will Cohen Signed-off-by: Fabian Franz [Will Cohen: - For P9_XATTR_MAX, ensure that Linux uses XATTR_SIZE_MAX, Darwin uses 64k, and error out for undefined hosts] Signed-off-by: Will Cohen --- hw/9pfs/9p.c | 2 +- hw/9pfs/9p.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 14e84c3bcf..7405352c37 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3949,7 +3949,7 @@ static void coroutine_fn v9fs_xattrcreate(void *opaque) rflags |= XATTR_REPLACE; } - if (size > XATTR_SIZE_MAX) { + if (size > P9_XATTR_SIZE_MAX) { err = -E2BIG; goto out_nofid; } diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 1567b67841..94b273b3d0 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -479,4 +479,22 @@ struct V9fsTransport { void (*push_and_notify)(V9fsPDU *pdu); }; +#if defined(XATTR_SIZE_MAX) +/* Linux */ +#define P9_XATTR_SIZE_MAX XATTR_SIZE_MAX +#elif defined(CONFIG_DARWIN) +/* + * Darwin doesn't seem to define a maximum xattr size in its user + * space header, so manually configure it across platforms as 64k. + * + * Having no limit at all can lead to QEMU crashing during large g_malloc() + * calls. Because QEMU does not currently support macOS guests, the below + * preliminary solution only works due to its being a reflection of the limit of + * Linux guests. + */ +#define P9_XATTR_SIZE_MAX 65536 +#else +#error Missing definition for P9_XATTR_SIZE_MAX for this host system +#endif + #endif From patchwork Tue Feb 15 19:04:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12747527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 33B43C433F5 for ; Tue, 15 Feb 2022 19:12:38 +0000 (UTC) Received: from localhost ([::1]:46182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK3Fd-0000SJ-20 for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 14:12:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK38C-0000wG-DO for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:56 -0500 Received: from [2607:f8b0:4864:20::f29] (port=34783 helo=mail-qv1-xf29.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nK389-0002l0-2U for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:56 -0500 Received: by mail-qv1-xf29.google.com with SMTP id fh9so55522qvb.1 for ; Tue, 15 Feb 2022 11:04:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=axA+qxXpY8sKbyRbqVq801h3dnGKdNQsigejBH57FZ8=; b=PyhSs4o0+mg3EVtKmV1zwXy6vtt8FL8syRdNhaa84qO5No9p/1WhOUlAxDsf5rUKxv fKbhYE5dB+lpsigRji6fsqqg7l81dnt3PI6ebXwX8Pb/1nJ86n5rXtUJotKnfuBksp6N zxjTLDDBtqEJTNHkOM6ybU9FUgcCinRFGnSYWbuWDHtbU8dvbo0DUlN2Fetrly53A8n+ WRuNYdpn5JzBukaC0UjDQvp7bRkY8uVOlIpask8IJvo3XO1sgvy7AogRVsjYs2r1MQIA NJGFXTmjWnhgNZXK5ly6dp1akBT+KL3Ikc4ovc483v8KHfc/fSL3oXDq4ixBAOS4qpiy v0Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=axA+qxXpY8sKbyRbqVq801h3dnGKdNQsigejBH57FZ8=; b=fwfoluBDPnxpDiAzuUAFhk8O26aFoxsDrQ6pggdyUj57L0lSNNedfhs6GaWmUGnVom t1hXBUK6xh9rER5tSwW+mVNqD5nHfZ8ucC95sombJ6WRl3XGgn46rAtS8SL8I/fy/rJ8 0OXZy4Wcqe25zfuuykJWe/WI/CcVfquohlb6vrKLMEaXvN5mHlwi48/wsRO8s1f8Rgpz GTT6Pw0fXpi56ael9BnOrWiErvRRKthafc93irCKt1Ttvmv42mKPpcQSF6eXt20PU7/B lpqvO2NghWzAoIXt5x1WX4ZA5m6YP9fOmfSxiGQEUJ5KpAf6pN0sAkUNRvBVw3yKOMB0 20Aw== X-Gm-Message-State: AOAM5307FCRhrynsZS9cTJu363JqgEloI2CXeSCSPqROXxf2rxMWP9Iv c8yi+ajHesEAOIA1AfA8XMTmaCFDFARHBg== X-Google-Smtp-Source: ABdhPJw3pBy2MaFf25fIbdCqiUS0BwdzIwVV4h6dC2LO561ahexuSE6BIRAY/GCW0Oun76SIAmh6TA== X-Received: by 2002:a0c:ed23:: with SMTP id u3mr441793qvq.74.1644951891723; Tue, 15 Feb 2022 11:04:51 -0800 (PST) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w10sm21364527qtj.73.2022.02.15.11.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 11:04:51 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v7 07/11] 9p: darwin: *xattr_nofollow implementations Date: Tue, 15 Feb 2022 14:04:22 -0500 Message-Id: <20220215190426.56130-8-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215190426.56130-1-wwcohen@gmail.com> References: <20220215190426.56130-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f29 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f29; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf29.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.904, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer This implements the darwin equivalent of the functions that were moved to 9p-util(-linux) earlier in this series in the new 9p-util-darwin file. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- hw/9pfs/9p-util-darwin.c | 64 ++++++++++++++++++++++++++++++++++++++++ hw/9pfs/meson.build | 1 + 2 files changed, 65 insertions(+) create mode 100644 hw/9pfs/9p-util-darwin.c diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c new file mode 100644 index 0000000000..cdb4c9e24c --- /dev/null +++ b/hw/9pfs/9p-util-darwin.c @@ -0,0 +1,64 @@ +/* + * 9p utilities (Darwin Implementation) + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/xattr.h" +#include "9p-util.h" + +ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size) +{ + int ret; + int fd = openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = fgetxattr(fd, name, value, size, 0, 0); + close_preserve_errno(fd); + return ret; +} + +ssize_t flistxattrat_nofollow(int dirfd, const char *filename, + char *list, size_t size) +{ + int ret; + int fd = openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = flistxattr(fd, list, size, 0); + close_preserve_errno(fd); + return ret; +} + +ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, + const char *name) +{ + int ret; + int fd = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = fremovexattr(fd, name, 0); + close_preserve_errno(fd); + return ret; +} + +int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size, int flags) +{ + int ret; + int fd = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = fsetxattr(fd, name, value, size, 0, flags); + close_preserve_errno(fd); + return ret; +} diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index 1b28e70040..12443b6ad5 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -14,6 +14,7 @@ fs_ss.add(files( 'coxattr.c', )) fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-util-linux.c')) +fs_ss.add(when: 'CONFIG_DARWIN', if_true: files('9p-util-darwin.c')) fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c')) softmmu_ss.add_all(when: 'CONFIG_FSDEV_9P', if_true: fs_ss) From patchwork Tue Feb 15 19:04:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12747537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 465B0C433EF for ; Tue, 15 Feb 2022 19:20:19 +0000 (UTC) Received: from localhost ([::1]:53826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK3N3-0005ve-Vz for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 14:20:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK38D-0000yG-3s for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:57 -0500 Received: from [2607:f8b0:4864:20::733] (port=38822 helo=mail-qk1-x733.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nK38B-0002lH-3R for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:56 -0500 Received: by mail-qk1-x733.google.com with SMTP id n185so1391682qke.5 for ; Tue, 15 Feb 2022 11:04:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9kM+hfKaNHkhAKW7qPhMom4aNnY+CTog/UjBQslxta0=; b=fuh7eB4Jn1cCvj4S8hW3js3zOa4O7UC5SarPdTohj4/q4hzch52f05TGW3r7uf/PRt bgYENFFZCJGf+iyG2ZrK0j0lrR7kgfeXB9sktgmrQDUVUwz95ogCd4W6ajhjK/j+2diX 0Vj8QCYY1ECKZJKNYLb21arE/Q8DRdQg7rwet/OMvp5fJv0NvrdWnpkn3Hj35NTViU1e 70Oi6bPcnN6obQ9ll+fiZ4mx73Zedp8sJyfGK8UU79MGv65E2K25y9x0VjWJt9yBf46u yOdrtZxWbooce1bz/GwahVuKfCaqWZtR9ZVdVPtUyfUzJhbd+yTUEHjsGtEgZ5fCHhUI 0+FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9kM+hfKaNHkhAKW7qPhMom4aNnY+CTog/UjBQslxta0=; b=lCw2iSkmE9ybWJaonE/MpX2wq8yZ+HboPb7TM2sAGGeT1mbVlF8A7d46D98M6FN0TU rVf5Tw0odbwFpeEcCVLwiBmBWHDWn+XjFAEDGEqjBegrE/LhwaZA3vTzuY7aYWFqvx9Z oCo8UKggNTeUY5/03zlZm9c+wQzNJS56uxTni6+EdC9N4tWaCHfWPPpa8ReQb92gtXGa fuyLtNmQ7Xou0bm76BFzs7ckz4pvpEL2mDsvYbIWj5Y/eLZhhyLcZaELVGWCyfjFGHWM SmNwm7Uh1hM3loLLkHNdtpJOhnqsWISkO5r9YWf8UnMpjE3wJxPbJT+/omAs733TYX/W goAw== X-Gm-Message-State: AOAM533shZVL7kO5HzJjCOkThHxoJPAM+EXALKa1EwmuIndGlkDhyDG+ RTfTmplIJekdz1AH8mUWSe7WEOR8P/HXuQ== X-Google-Smtp-Source: ABdhPJw5jyrn6k+krYMhpYVlvk5l1E+RhbC8/ox22Qsxp2+cQwVWOXuwfFcHBS3swxKdFuxA23h0cQ== X-Received: by 2002:a05:620a:8d7:: with SMTP id z23mr220784qkz.753.1644951893712; Tue, 15 Feb 2022 11:04:53 -0800 (PST) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w10sm21364527qtj.73.2022.02.15.11.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 11:04:52 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v7 08/11] 9p: darwin: Compatibility for f/l*xattr Date: Tue, 15 Feb 2022 14:04:23 -0500 Message-Id: <20220215190426.56130-9-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215190426.56130-1-wwcohen@gmail.com> References: <20220215190426.56130-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::733 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::733; envelope-from=wwcohen@gmail.com; helo=mail-qk1-x733.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.904, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer On darwin `fgetxattr` takes two extra optional arguments, and the l* variants are not defined (in favor of an extra flag to the regular variants. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- hw/9pfs/9p-local.c | 12 ++++++++---- hw/9pfs/9p-util.h | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index f3272f0b43..a0d08e5216 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -790,16 +790,20 @@ static int local_fstat(FsContext *fs_ctx, int fid_type, mode_t tmp_mode; dev_t tmp_dev; - if (fgetxattr(fd, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) { + if (qemu_fgetxattr(fd, "user.virtfs.uid", + &tmp_uid, sizeof(uid_t)) > 0) { stbuf->st_uid = le32_to_cpu(tmp_uid); } - if (fgetxattr(fd, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) { + if (qemu_fgetxattr(fd, "user.virtfs.gid", + &tmp_gid, sizeof(gid_t)) > 0) { stbuf->st_gid = le32_to_cpu(tmp_gid); } - if (fgetxattr(fd, "user.virtfs.mode", &tmp_mode, sizeof(mode_t)) > 0) { + if (qemu_fgetxattr(fd, "user.virtfs.mode", + &tmp_mode, sizeof(mode_t)) > 0) { stbuf->st_mode = le32_to_cpu(tmp_mode); } - if (fgetxattr(fd, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) { + if (qemu_fgetxattr(fd, "user.virtfs.rdev", + &tmp_dev, sizeof(dev_t)) > 0) { stbuf->st_rdev = le64_to_cpu(tmp_dev); } } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 0e445b5d52..82399702b9 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -19,6 +19,23 @@ #define O_PATH_9P_UTIL 0 #endif +#ifdef CONFIG_DARWIN +#define qemu_fgetxattr(...) fgetxattr(__VA_ARGS__, 0, 0) +#define qemu_lgetxattr(...) getxattr(__VA_ARGS__, 0, XATTR_NOFOLLOW) +#define qemu_llistxattr(...) listxattr(__VA_ARGS__, XATTR_NOFOLLOW) +#define qemu_lremovexattr(...) removexattr(__VA_ARGS__, XATTR_NOFOLLOW) +static inline int qemu_lsetxattr(const char *path, const char *name, + const void *value, size_t size, int flags) { + return setxattr(path, name, value, size, 0, flags | XATTR_NOFOLLOW); +} +#else +#define qemu_fgetxattr fgetxattr +#define qemu_lgetxattr lgetxattr +#define qemu_llistxattr llistxattr +#define qemu_lremovexattr lremovexattr +#define qemu_lsetxattr lsetxattr +#endif + static inline void close_preserve_errno(int fd) { int serrno = errno; From patchwork Tue Feb 15 19:04:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12747582 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5AD4C433F5 for ; Tue, 15 Feb 2022 19:44:58 +0000 (UTC) Received: from localhost ([::1]:38948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK3kv-0001JG-To for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 14:44:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK38E-00011b-PV for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:58 -0500 Received: from [2607:f8b0:4864:20::836] (port=42544 helo=mail-qt1-x836.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nK38C-0002lT-FP for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:04:58 -0500 Received: by mail-qt1-x836.google.com with SMTP id s1so19503043qtw.9 for ; Tue, 15 Feb 2022 11:04:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EB8tJkFyv0t4GdFE0KqllcD+blasxRu406yEHevMwSc=; b=cR9+tPRN4rtlc4IOX949GROCSX81Q1ESQclGgB1057mo8lX0CGipzdM1mlRqJvsViX No6ztMx35bQ5jDsxXxsPnUW8u0EMwS6ne5zuxaG+Ob+F7e6W/zfdQlNWBnwmROXpgMDL SGsv9opE3PVr4rQJLxYn/BgqVEzFuvpHxgCWu+bWzO0ayhGnrcyfqee92qFM5tOiDqJB FFeklC21/oDEUu6yiY3dkoLKZ6yhKLHw1tOhHbsc+W0XqaUhNbi0ZShbSuQOpAkQSTBV 48dROSpspM3/sc76wr7wEwzOdv3VpkxG51MFbYMyq161/trB/CWgyy48dOHsvpSTbI5D jbPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EB8tJkFyv0t4GdFE0KqllcD+blasxRu406yEHevMwSc=; b=wxBs1kv811JxQBWXIf3qUeXXNM31gPxFpQnhkqW6z/KsbpBW0ojpzmYy0FoXLxOUv0 TilpwtCEz6liEeqaOhH69JcqSzGp182T6oTdjEb84+Ne70uWn+JO9pT1GOKRYYYHTI4z LXPuBnoy5ud6X74mCFb+BjVauS23yiQKhViZFcqdgAJEA/ilBmA85EdZbAwDMUNI8OPI dEBbqQhGyI931JZI+U7hiXG/Sn1RZ78RUG5sc5SVzPNLbZPohMsx7dkVB5XbeTA1re/E iCkV4P180UIo/lpWCa0no0nyDXrhSpNh/UiIlELjsIapx5sbem/6HWT+QDP+jkd7o9XB f8PQ== X-Gm-Message-State: AOAM532CzBxNZZanc0WyFZZJe/1JrVT+O2CwVV3xjX+4Q7pG8RLaZ3vA gYPBj/Q4/OwhrvWLfdNTqkcA9UYsTghRqg== X-Google-Smtp-Source: ABdhPJxahFa2X5PiQzx/B2DlgzY6vd416+XNAYqbBbHgjpdI0LPRTKJwp1lqj4WlOAKcyD3H6fKIrw== X-Received: by 2002:a05:622a:249:: with SMTP id c9mr414794qtx.109.1644951895192; Tue, 15 Feb 2022 11:04:55 -0800 (PST) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w10sm21364527qtj.73.2022.02.15.11.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 11:04:54 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v7 09/11] 9p: darwin: Implement compatibility for mknodat Date: Tue, 15 Feb 2022 14:04:24 -0500 Message-Id: <20220215190426.56130-10-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215190426.56130-1-wwcohen@gmail.com> References: <20220215190426.56130-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::836 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::836; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x836.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.904, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Darwin does not support mknodat. However, to avoid race conditions with later setting the permissions, we must avoid using mknod on the full path instead. We could try to fchdir, but that would cause problems if multiple threads try to call mknodat at the same time. However, luckily there is a solution: Darwin includes a function that sets the cwd for the current thread only. This should suffice to use mknod safely. This function (pthread_fchdir_np) is protected by a check in meson in a patch later in this series. Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch [Will Cohen: - Adjust coding style - Replace clang references with gcc - Note radar filed with Apple for missing syscall - Replace direct syscall with pthread_fchdir_np and adjust patch notes accordingly - Move qemu_mknodat from 9p-util to osdep and os-posix - Move pthread_fchdir_np declaration only to osdep - Declare pthread_fchdir_np with - __attribute__((weak_import)) to allow checking for its presence before usage - Move declarations above cplusplus guard - Add CONFIG_PTHREAD_FCHDIR_NP to meson and check for presence in osdep.h and os-posix.c] Signed-off-by: Will Cohen --- hw/9pfs/9p-local.c | 4 ++-- include/qemu/osdep.h | 12 ++++++++++++ meson.build | 1 + os-posix.c | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index a0d08e5216..d42ce6d8b8 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -682,7 +682,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { - err = mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); + err = qemu_mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); if (err == -1) { goto out; } @@ -697,7 +697,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, } } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { - err = mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); + err = qemu_mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); if (err == -1) { goto out; } diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index d1660d67fa..fb25cafcc4 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -805,6 +805,18 @@ static inline int platform_does_not_support_system(const char *command) } #endif /* !HAVE_SYSTEM_FUNCTION */ +/* + * As long as mknodat is not available on macOS, this workaround + * using pthread_fchdir_np is needed. qemu_mknodat is defined in + * os-posix.c. pthread_fchdir_np is weakly linked here as a guard + * in case it disappears in future macOS versions, because it is + * is a private API. + */ +#if defined CONFIG_DARWIN && defined CONFIG_PTHREAD_FCHDIR_NP +int pthread_fchdir_np(int fd) __attribute__((weak_import)); +#endif +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev); + #ifdef __cplusplus } #endif diff --git a/meson.build b/meson.build index ae5f7eec6e..6fdc0281ad 100644 --- a/meson.build +++ b/meson.build @@ -1557,6 +1557,7 @@ config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate' config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign')) config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll')) config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include ')) +config_host_data.set('CONFIG_PTHREAD_FCHDIR_NP', cc.has_function('pthread_fchdir_np')) config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads)) config_host_data.set('CONFIG_SENDFILE', cc.has_function('sendfile')) config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_function('unshare')) diff --git a/os-posix.c b/os-posix.c index ae6c9f2a5e..ccc3d1e9d3 100644 --- a/os-posix.c +++ b/os-posix.c @@ -332,3 +332,38 @@ int os_mlock(void) return -ENOSYS; #endif } + +/* + * As long as mknodat is not available on macOS, this workaround + * using pthread_fchdir_np is needed. + * + * Radar filed with Apple for implementing mknodat: + * rdar://FB9862426 (https://openradar.appspot.com/FB9862426) + */ +#if defined CONFIG_DARWIN && defined CONFIG_PTHREAD_FCHDIR_NP + +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + int preserved_errno, err; + if (!pthread_fchdir_np) { + error_report_once("pthread_fchdir_np() is not available on this version of macOS"); + return -ENOTSUP; + } + if (pthread_fchdir_np(dirfd) < 0) { + return -1; + } + err = mknod(filename, mode, dev); + preserved_errno = errno; + /* Stop using the thread-local cwd */ + pthread_fchdir_np(-1); + if (err < 0) { + errno = preserved_errno; + } + return err; +} +#else +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + return mknodat(dirfd, filename, mode, dev); +} +#endif From patchwork Tue Feb 15 19:04:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12747586 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 97CCFC433F5 for ; Tue, 15 Feb 2022 19:49:05 +0000 (UTC) Received: from localhost ([::1]:46464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK3ou-0006dg-NY for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 14:49:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK38G-00016g-Fh for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:05:00 -0500 Received: from [2607:f8b0:4864:20::836] (port=43600 helo=mail-qt1-x836.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nK38E-0002lr-80 for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:05:00 -0500 Received: by mail-qt1-x836.google.com with SMTP id x5so19492031qtw.10 for ; Tue, 15 Feb 2022 11:04:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VI0Ghpcxq8/Yi1AQXKCEmSeO6fHHyV1SL/EjKkI3wfk=; b=KEe1T1sNJo41xxjROCr/q195Xa7JdG9+b0DBLoMxbYff8fiIj/wgIlsgN/Qd3qNFj3 KAipRRfxH2O8MOqVAAVFjFw50nbeHNxRgL8UM1rK8Jp9NwpNYSAKIjuOtEwfMPuHtRV7 khcAruu+mzSjC6pRVAaJXFs7kXvaUYTViYOkkAE6MoBcVIfGKR5mjwLUGZAyuZrNVLGX O17K1dsmpiM3cYnmGAP/VBSipg7nVlu+h3cLutVTNfiyVIQTKs2KZeUaaBWov8nzV3Hw bqmbs7VJtrZDQIVjPq31k6QnMSh+thS0v3NvumS1mDHddm54FKolxgzEWKB0m+JWIA9N Z3VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VI0Ghpcxq8/Yi1AQXKCEmSeO6fHHyV1SL/EjKkI3wfk=; b=k0C9doQEzwFKQtFjFZPxJrAR7eoLq5JRcZeunrcqLV/ADaZQjInX8wxhqojkzGMlgV ahaFfhYa+aBU4ZwgZgsk71L/Ly2YIyAtMDDGcr5JEAPPfvUJMCt2l1aI8ODodEQxv1/L pq+4wJ23uqFfKzexOBIQ7wficaF9WsXD/4dCn4v6uNb9nj2IHO1EKRy+oeXkbkWP9nRa ajxaGPsHWqkDjdgrmBB1umTqu/sj2pFnrNiepI+bC0N68OtglMBCKnlxe6Gmu3qng/E1 H/GMG+cKpkuCNKjfiRqcfFEU3Si0UdUvu1chuxEtfRpA5EYi8bdPSvfXzdwOVSAIi2sx xJ4A== X-Gm-Message-State: AOAM5319AerqPIEMBGsbGzaC6Pw/lHXT62g/smT0bKFIyQWYVWkBWYq4 a2mab4nz+PYFkrNHC3jA/UJHl3juaOrdMA== X-Google-Smtp-Source: ABdhPJwTyPMRnraf6wUBDYirRD0fZYvVtje/+iUabvMeKaGfA6lLv6Pin5gyCvjN2ElVTxwGsoCClA== X-Received: by 2002:a05:622a:607:: with SMTP id z7mr397138qta.281.1644951896842; Tue, 15 Feb 2022 11:04:56 -0800 (PST) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w10sm21364527qtj.73.2022.02.15.11.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 11:04:56 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v7 10/11] 9p: darwin: Adjust assumption on virtio-9p-test Date: Tue, 15 Feb 2022 14:04:25 -0500 Message-Id: <20220215190426.56130-11-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215190426.56130-1-wwcohen@gmail.com> References: <20220215190426.56130-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::836 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::836; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x836.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.904, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Fabian Franz , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Will Cohen , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The previous test depended on the assumption that P9_DOTL_AT_REMOVEDIR and AT_REMOVEDIR have the same value. While this is true on Linux, it is not true everywhere, and leads to an incorrect test failure on unlink_at, noticed when adding 9p to darwin: Received response 7 (RLERROR) instead of 77 (RUNLINKAT) Rlerror has errno 22 (Invalid argument) ** ERROR:../tests/qtest/virtio-9p-test.c:305:v9fs_req_recv: assertion failed (hdr.id == id): (7 == 77) Bail out! ERROR:../tests/qtest/virtio-9p-test.c:305:v9fs_req_recv: assertion failed (hdr.id == id): (7 == 77) Signed-off-by: Fabian Franz [Will Cohen: - Add explanation of patch and description of pre-patch test failure] Signed-off-by: Will Cohen Acked-by: Thomas Huth [Will Cohen: - Move this patch before 9p: darwin: meson patch to avoid qtest breakage during bisecting] Signed-off-by: Will Cohen Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 41fed41de1..6bcf89f0f8 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -1270,7 +1270,7 @@ static void fs_unlinkat_dir(void *obj, void *data, QGuestAllocator *t_alloc) /* ... and is actually a directory */ g_assert((st.st_mode & S_IFMT) == S_IFDIR); - do_unlinkat(v9p, "/", "02", AT_REMOVEDIR); + do_unlinkat(v9p, "/", "02", P9_DOTL_AT_REMOVEDIR); /* directory should be gone now */ g_assert(stat(new_dir, &st) != 0); From patchwork Tue Feb 15 19:04:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12747523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0FB2C433F5 for ; Tue, 15 Feb 2022 19:07:17 +0000 (UTC) Received: from localhost ([::1]:39468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK3AS-0003xz-PE for qemu-devel@archiver.kernel.org; Tue, 15 Feb 2022 14:07:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK38I-0001BR-RQ for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:05:02 -0500 Received: from [2607:f8b0:4864:20::82e] (port=45666 helo=mail-qt1-x82e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nK38G-0002mF-8I for qemu-devel@nongnu.org; Tue, 15 Feb 2022 14:05:01 -0500 Received: by mail-qt1-x82e.google.com with SMTP id o3so19521580qtm.12 for ; Tue, 15 Feb 2022 11:04:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JbF/C9JMkxQTOgzoTFWfI/WAJzjiOKPl6EnvR0wzVl4=; b=LczEbLetGohAjLD3KzWkQjFMVWilpSPa2oyEF9gMDxzJf8rdkByHwdf07y4UroAST8 7xUnowM/+FEeOyqY9I92fyOYFNEAW0cYGzrWobdqfIggJle5NyPospJ7jj+217V0UkIV P+1vwQPDobT221Zzhy5iUM0TbDmDG7Te7JOeiiy+YKZ9JwLeubPNbaBhyOHP+K/69VsX 6x+tuZvMfUJGOfbf1TPVqPpwrP/2ZApYOiv93xAOu8sIR3SN4wW01t5MQZIViPTiTb9x yUovm2BAvKKEdAwcGlNduMgHmU7RyLv8yrv6Ditlxu05kFr+SW9RQc4urDsY9EaP8vDv uY3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JbF/C9JMkxQTOgzoTFWfI/WAJzjiOKPl6EnvR0wzVl4=; b=E4kZsST9uKzAvt5MYm+ggvqozi8nMmH2q/lGoOHEfW7bUHFSTjt/G0eulL+Yj88iQD wEvmD5Jf1RwO1dc8wPl8wzJZj56AogaeEUTEOOB8/lrrTmJ8E2DwcsvDUc/2g0wkF3Qa 2qEcOspdtuIQuJkWPJQAQ7sNqeqz4FpTgwmYRpnq32YwQkhZ9qirxFLo8iO7KaR3DEwQ g7HTJRjG9Xcox1VhkOedu8sVgXv3zXIiFl5B/7rbS+sscAjzAeaCIaAEvIoq4Ba9O+m7 LlNNYWIKV4Eeu1gELZuOOkFN3y/EWJzClnezphiy/mUKbs2MTL1v0xGohpUj/FhocrMC yhuw== X-Gm-Message-State: AOAM531sR1cClHc4F5RNXwYbizmdMrJkox4nIa4nqu6yM+BU1OWJ986+ cW3veuC38eWAfa/A8b7WOATSJWeMi5KGTQ== X-Google-Smtp-Source: ABdhPJyNX/4ZM5qv2r5Pc3UbBF39TbhJH+ck322e+kHkwxVuRj/CVVs7izhcj3mDnZk+vsG23+usqw== X-Received: by 2002:ac8:7dc8:: with SMTP id c8mr416846qte.672.1644951898759; Tue, 15 Feb 2022 11:04:58 -0800 (PST) Received: from localhost.localdomain (209-6-248-219.s2265.c3-0.wrx-ubr1.sbo-wrx.ma.cable.rcncustomer.com. [209.6.248.219]) by smtp.gmail.com with ESMTPSA id w10sm21364527qtj.73.2022.02.15.11.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 11:04:58 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v7 11/11] 9p: darwin: meson: Allow VirtFS on Darwin Date: Tue, 15 Feb 2022 14:04:26 -0500 Message-Id: <20220215190426.56130-12-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215190426.56130-1-wwcohen@gmail.com> References: <20220215190426.56130-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::82e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::82e; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x82e.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.904, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer To allow VirtFS on darwin, we need to check that pthread_fchdir_np is available, which has only been available since macOS 10.12. Additionally, virtfs_proxy_helper is disabled on Darwin. This patch series does not currently provide an implementation of the proxy-helper, but this functionality could be implemented later on. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Rebase to master] Signed-off-by: Will Cohen Reviewed-by: Paolo Bonzini [Will Cohen: - Add check for pthread_fchdir_np to virtfs - Add comments to patch commit - Note that virtfs_proxy_helper does not work on macOS - Fully adjust meson virtfs error note to specify macOS] Signed-off-by: Will Cohen --- fsdev/meson.build | 1 + meson.build | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fsdev/meson.build b/fsdev/meson.build index adf57cc43e..b632b66348 100644 --- a/fsdev/meson.build +++ b/fsdev/meson.build @@ -7,6 +7,7 @@ fsdev_ss.add(when: ['CONFIG_FSDEV_9P'], if_true: files( 'qemu-fsdev.c', ), if_false: files('qemu-fsdev-dummy.c')) softmmu_ss.add_all(when: 'CONFIG_LINUX', if_true: fsdev_ss) +softmmu_ss.add_all(when: 'CONFIG_DARWIN', if_true: fsdev_ss) if have_virtfs_proxy_helper executable('virtfs-proxy-helper', diff --git a/meson.build b/meson.build index 6fdc0281ad..b6f5c57487 100644 --- a/meson.build +++ b/meson.build @@ -1416,17 +1416,23 @@ if not get_option('dbus_display').disabled() endif endif -have_virtfs = (targetos == 'linux' and +if targetos == 'darwin' and cc.has_function('pthread_fchdir_np') + have_virtfs = have_system +else + have_virtfs = (targetos == 'linux' and have_system and libattr.found() and libcap_ng.found()) +endif -have_virtfs_proxy_helper = have_virtfs and have_tools +have_virtfs_proxy_helper = targetos != 'darwin' and have_virtfs and have_tools if get_option('virtfs').enabled() if not have_virtfs - if targetos != 'linux' - error('virtio-9p (virtfs) requires Linux') + if targetos != 'linux' and targetos != 'darwin' + error('virtio-9p (virtfs) requires Linux or macOS') + elif targetos == 'darwin' and not cc.has_function('pthread_fchdir_np') + error('virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') elif not libcap_ng.found() or not libattr.found() error('virtio-9p (virtfs) requires libcap-ng-devel and libattr-devel') elif not have_system