From patchwork Sun Feb 27 22:35:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12762166 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 D0938C433EF for ; Sun, 27 Feb 2022 22:37:09 +0000 (UTC) Received: from localhost ([::1]:45014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOSA8-0008ON-S8 for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 17:37:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOS8k-0005rb-HJ for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:42 -0500 Received: from [2607:f8b0:4864:20::836] (port=34451 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 1nOS8j-00031o-3t for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:42 -0500 Received: by mail-qt1-x836.google.com with SMTP id c4so7506152qtx.1 for ; Sun, 27 Feb 2022 14:35:40 -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=NNqqtWfX+7r5Cvr34BgDX1k8to7b5IQs7giXGg/3I6o=; b=HwMnN0pMB2gGgGxuRKOWWkTghTw5vGD2fuevLWkxLc2t7SF2mTuoQlKHJrYrAkGc5V 6lWgkeBfjF1GBrbfmDmh/fA+XFN72KirbaXu3kUj6KaIC9/2F42MKPZO0UWyDCgYKa2Z ShbWRiz+RvkZuUZ3XnnUYOaq09AulKka01sMX7lgoTJPwRg4CLHfXXQZO2HTsbXlyvFw bGS+tzTLtKURLnex2gS/KtZJxOMSoxe5z+U9PDI2YZOPw4d9JLhUtpD0/3xCM1pjNU0P BT4g7b8o4FTIBbv+EBYbLRLmaUCr0MFvSkgy54E3IeNjF0AYUk6iq0e9FHKn90L7SWL5 rsrw== 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=NNqqtWfX+7r5Cvr34BgDX1k8to7b5IQs7giXGg/3I6o=; b=RxHnUel6mArgTtt7AERNCgKrVgChJDS3UiHY3XOcqYDkwPHGIMgNdnAVEnhNdh0uhT RtkIqgBZEzcqAUueOuPivIIUAgdXIOjrNFyOlsnydDdSs2M6XOvUsvmaTzJvQWCS5aAe ZaNGHCRQj3e5RVkhzeH+0HvI3EfnkgryRB6ameQR0YenPrWzOSGxDQKHtdwTC/NIBToA bo3QrDFmogGxPDnc1NYM0GxcvUp2uyIrG1718j4jkZeTgwOTelmj/TR1g030SJVzW7uT KWDUdxoYAU8xYGnFd4XimQZbCiC9gK9EUkmTFNdMyQTtoUx9sENENG5Io4hFNQimUnwF 1iAw== X-Gm-Message-State: AOAM532uuI9zvrC3h9jkbAPQbC7JKKpF9eqe5TI/bSvJ1Ob5eCMQi2uG XP4+2BKJ0JuTUrpMmXGpJ0zn+Dub1s+r9w== X-Google-Smtp-Source: ABdhPJwvOOUTOmjZebf8c391jD2yJ/KALCcJ2hG69JFOMp8J195wDRjzhobqeZfOu7HNhjtJO7MRyQ== X-Received: by 2002:a05:622a:34d:b0:2dd:1364:2555 with SMTP id r13-20020a05622a034d00b002dd13642555mr14592254qtw.404.1646001339930; Sun, 27 Feb 2022 14:35:39 -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 85-20020a370758000000b00648b7e3b8a4sm4206485qkh.111.2022.02.27.14.35.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 14:35:39 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v9 01/11] 9p: linux: Fix a couple Linux assumptions Date: Sun, 27 Feb 2022 17:35:12 -0500 Message-Id: <20220227223522.91937-2-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227223522.91937-1-wwcohen@gmail.com> References: <20220227223522.91937-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: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, 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 , Greg Kurz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , 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 Sun Feb 27 22:35:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12762174 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 C7EE7C433F5 for ; Sun, 27 Feb 2022 22:40:25 +0000 (UTC) Received: from localhost ([::1]:54610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOSDI-0006OC-Nc for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 17:40:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOS8z-0006R9-NX for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:57 -0500 Received: from [2607:f8b0:4864:20::82a] (port=45585 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 1nOS8l-00032F-0p for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:57 -0500 Received: by mail-qt1-x82a.google.com with SMTP id e2so7498015qte.12 for ; Sun, 27 Feb 2022 14:35: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=YhmCSOC3CM9NyDHcskObyMbpau9QkFn/fvg6ws80gds=; b=UZV1M1C8CTpf8LGz0oD9dSH9vO2XTp9GVHg7vY0Id962rpmMWnoRouLuvdRIqhZVxj uyHJmGEKJnuSPjI1avpcWR8pDzL+q/pTdais2UOjn4RSfWe/KC57NRaHmTmjdSNVLJA/ JI7T0eqiPPAlMvsalDVUPNXB4ZQzE1J8Ce2B3Df0/+8L6+/3ikLRMPSUSap5xyy0YtAP 0RmHEoTNsHa812B/OHGsBnD9fSOGjAKT5yiPlgF+Z60WJTyb5f3Mgr6ZavN+fKso1xbX n48/DvS/HQz4ou8ij53azHs8T9Sei1HD9+1QUM7OTjqkuMLApreEj3/bYIc57rnsDVsA pY3A== 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=YhmCSOC3CM9NyDHcskObyMbpau9QkFn/fvg6ws80gds=; b=GF7I94M+bxgq1utia+WKLt2MXAhjV54+zmWW53bU2mJWjSJ37cJ2rWMCY3Csrh9J2e 58BfRblOLbxUEFdKFLpuum0w2ShmxtVeV0ZOb44WBNxn4ZE3xoFtBODHP+grNYtkVpaj lHWT8npvEm/e9et1jqTF01fM5ICs3o+lCgVmppe9ff12KHbyVgK5S8qmJoxVhv1mSEXs cHg5xPwT5MCPJTpySQrZ6aabRfRzyyf3VV1Lt6+7KNMEngZpUdAZ0bwre1AQvJWBVT/r tlfX1horx7ytVVYVq+MGSa++Q+UXtJQsdL2YPsVuH233R6lsLe5Lll3OtEY4OH9CceOK 6uEg== X-Gm-Message-State: AOAM532zc0wZDYHdDpYDzhh0Sa97P/C6WmezlumrdJ1BgxjKgnlp3yrs hpTCqt2rohWMAyiXVX0/llsOV3sT/ss36A== X-Google-Smtp-Source: ABdhPJxBWd/fi4EQURlP14wq/GoMvgtNC6uaTelFBoboQFi4WXDdiZuydKGR/pJ2AoivBPAWmeP/5A== X-Received: by 2002:ac8:5fd5:0:b0:2de:6411:f1f5 with SMTP id k21-20020ac85fd5000000b002de6411f1f5mr14357946qta.470.1646001341867; Sun, 27 Feb 2022 14:35: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 85-20020a370758000000b00648b7e3b8a4sm4206485qkh.111.2022.02.27.14.35.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 14:35:41 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v9 02/11] 9p: Rename 9p-util -> 9p-util-linux Date: Sun, 27 Feb 2022 17:35:13 -0500 Message-Id: <20220227223522.91937-3-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227223522.91937-1-wwcohen@gmail.com> References: <20220227223522.91937-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: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, 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 , Greg Kurz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , 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 Sun Feb 27 22:35:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12762167 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 8C997C433EF for ; Sun, 27 Feb 2022 22:37:17 +0000 (UTC) Received: from localhost ([::1]:45624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOSAG-0000OA-MK for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 17:37:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOS8s-00064K-JZ for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:50 -0500 Received: from [2607:f8b0:4864:20::82c] (port=45587 helo=mail-qt1-x82c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOS8n-00032P-2E for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:50 -0500 Received: by mail-qt1-x82c.google.com with SMTP id e2so7498045qte.12 for ; Sun, 27 Feb 2022 14:35:44 -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=/9yV7bRN6OBkNxsaJNqx6IRx9uWTGL8PDPo9dIDyd0E=; b=JbitSNDJL99E+aCcHHBxiJap3bb4/1eINwQZY4crboGJREola+ZLqJvH1wecYZIEBk cMZiFawwiByy9ZdjHfuUf1Jxpb/DBUCe4s2cZYKKmn4MFVXvqvLGy8ll4JgAgnS3Nw49 fAwcf9U1Oy/E1n26VJ66UMIB5W3vb4uJnbv/dSY/EehWKIDi4BTQp/UG96OicKAWqxCY RIsCur9qhd67N25gKXIMh2HW2Nx8o2/qKvHGXxVpHDc3jHJeJ0U5RQUSaEwFrPL6dTkf sFqOHuB1VHXm9tB2mV2K7CdJ1sGtDCOfwg6RDds3iS4UoV+jrwKp3YUDM1f3cUc9Yx3B xd0g== 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=/9yV7bRN6OBkNxsaJNqx6IRx9uWTGL8PDPo9dIDyd0E=; b=441Ue2H2a6ZjKE+1wcpiEhp1WutSUVbMsxWir7XE6+DlQWYtKAILcnwV5mYsbWmJOV PMwXHMZwuuoo0rfm19DrLmNbd7v1NOS3iVsVa1O8ZDLQQ70D46xsZJNMrdz+v/sMjEn8 mD1dMFoJ9PixTqHFs9wI50xmZ45rVlXRJe5owTgO71WdYLc21l3IbOHLMLe/pyJoWvpb XfRvt2U1fTvGrVVXifeQquip2UyPjx7874G0uTA4bgH8ONDieI3Qz7/ZJVPGdq+6KbsC qR0QgiwbzsvCOosr69dtgrD4LGPJz7CLm9BvgliMkMFr18pPXr5CkhWUy4wqe49u6TZ2 48nA== X-Gm-Message-State: AOAM5332Pm2v2hXk7ssXRmWCc4c9CODJDVTEXGEB6sycO/986QijDD29 d+de+H4WEm4y249rOQFVQ9HZfTvK1MMhGg== X-Google-Smtp-Source: ABdhPJxR2QBN3+smjeOveVagEr2SX1XUcvTfcwNsW29QFvQknAeP7Y8PpI29SKbcQe31BjobmD/zlw== X-Received: by 2002:a05:622a:11d6:b0:2dd:da66:b064 with SMTP id n22-20020a05622a11d600b002ddda66b064mr14701644qtk.8.1646001343639; Sun, 27 Feb 2022 14:35:43 -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 85-20020a370758000000b00648b7e3b8a4sm4206485qkh.111.2022.02.27.14.35.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 14:35:43 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v9 03/11] 9p: darwin: Handle struct stat(fs) differences Date: Sun, 27 Feb 2022 17:35:14 -0500 Message-Id: <20220227223522.91937-4-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227223522.91937-1-wwcohen@gmail.com> References: <20220227223522.91937-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::82c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::82c; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x82c.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, 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 , Greg Kurz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , 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 7a7cd5c5ba..bf9b0c5ddd 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -439,7 +439,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 Sun Feb 27 22:35:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12762172 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 72189C433EF for ; Sun, 27 Feb 2022 22:39:55 +0000 (UTC) Received: from localhost ([::1]:53640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOSCm-0005iv-Ok for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 17:39:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOS8s-000648-C2 for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:50 -0500 Received: from [2607:f8b0:4864:20::832] (port=37524 helo=mail-qt1-x832.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOS8o-00032T-RQ for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:50 -0500 Received: by mail-qt1-x832.google.com with SMTP id q10so7498802qtw.4 for ; Sun, 27 Feb 2022 14:35:46 -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=tA46xifQb/Ew3SN4Orf7Q7oKzCRYfHaaqw12116qxJA=; b=JPIyqyeJlK7F5z6CJQ0kHxfKuUGr5rZDcnbehVVrK+Dg/v/+VdoOD7I88kQpD8ER/W q/DPHo7M1tjRpgksCEpUHd9HZEZ7MEgMcc+GniY4iuWzdjbKbXe5tBJmQlKvibwvEyVp VRlSOS1zOOgt4JZsHEzqkdhw1W2uSvLu3iJdfjnlKCQCpvOjouVFyYnOjt3huKZT/sg4 BCSAxOlgX/k4v9ia8moLksnLShk0Pw6qcR98ahB2OslAQwOxOJ8H5snuFBMzMKpzj00X vKlN58+oioDWeHodVS/3u2DSaGQdC2VRp2zziP7A1zDUAijszCGTqx49sLRSdcX0ZDVd iMWw== 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=tA46xifQb/Ew3SN4Orf7Q7oKzCRYfHaaqw12116qxJA=; b=djg1c4VYPldTNE27dlTstDha1XMN5g3xsY/r6oe5emtIZGCfns7AzuNNIXyqHgE3aV poCSmQWiNYBFz/tlw0JviXyWLFWb9RCWzjAbXU6E/8hNoZ9gar6FlO/tt78jb9g61ksV wgpeXUN//H0FuJI1W7ALYpb51gh1F1Nagp+Y/y325KzScbNo3KvcrZIVw05jtBEbBsYc b9XkZttJjYz7fGgXmpBuN3Z1MsVBPB0asadPqVSO7VszJZjfdvB6xPCO01T4PN1ILxlb U1c4jQ8PnJVUdvUKFQn1kxuk+rPkfBMYCczPiwHlbu5y9eTlFPEDo2PfF7gknOomyLiE AdaA== X-Gm-Message-State: AOAM533pNuWX13QLtfIg4z9MUEgLwthy+3rfZiG1159e7teJBN7USsT+ zHkwZUzVU66tysHcstzv+Zx7etoGgGUvlA== X-Google-Smtp-Source: ABdhPJyVqQUgmkQsIb6gM+Xjbo4HwJodbmfCjM4KUj8wdWqTiFJys8XFwNT+SKHbkdzCjI59GrWEMg== X-Received: by 2002:a05:622a:1a22:b0:2dd:e0ff:f5e6 with SMTP id f34-20020a05622a1a2200b002dde0fff5e6mr14255732qtb.371.1646001345542; Sun, 27 Feb 2022 14:35:45 -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 85-20020a370758000000b00648b7e3b8a4sm4206485qkh.111.2022.02.27.14.35.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 14:35:45 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v9 04/11] 9p: darwin: Handle struct dirent differences Date: Sun, 27 Feb 2022 17:35:15 -0500 Message-Id: <20220227223522.91937-5-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227223522.91937-1-wwcohen@gmail.com> References: <20220227223522.91937-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::832 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x832.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, 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 , Greg Kurz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , 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 - Declare qemu_dirent_off as static to prevent linker error - Move qemu_dirent_off above the end-of-file endif to fix compilation] 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 bf9b0c5ddd..b3080e415b 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -234,7 +234,11 @@ static void synth_direntry(V9fsSynthNode *node, offsetof(struct dirent, d_name) + sz); memcpy(entry->d_name, node->name, sz); 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..7449733c15 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -78,4 +78,20 @@ ssize_t flistxattrat_nofollow(int dirfd, const char *filename, ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, const char *name); +/** + * 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. + */ +static inline off_t qemu_dirent_off(struct dirent *dent) +{ +#ifdef CONFIG_DARWIN + return dent->d_seekoff; +#else + return dent->d_off; +#endif +} + + #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 c0873bde16..f96d8ac4e6 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) @@ -166,7 +168,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 Sun Feb 27 22:35:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12762173 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 A032FC433EF for ; Sun, 27 Feb 2022 22:40:10 +0000 (UTC) Received: from localhost ([::1]:54226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOSD3-00068S-HV for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 17:40:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOS8t-00067J-NW for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:51 -0500 Received: from [2607:f8b0:4864:20::82f] (port=39607 helo=mail-qt1-x82f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOS8q-00032Y-OZ for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:51 -0500 Received: by mail-qt1-x82f.google.com with SMTP id b23so7513028qtt.6 for ; Sun, 27 Feb 2022 14:35:48 -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=grWbFCldgL720wZ6+WoT8uC1/mR1urOqvneOp/KMncU=; b=UDn+KKvT3ayFoEx0t6JeCS+NUur0ZwTLj3T5ujPJZcWkzrsy6EIYRAlZfDFsPgvvyt 6L/AvTIIMMKErRLkRS+YJt+jQU3gQ2lKOV5gBKm6Hgrhl6ty1TTxcc93bjFSrVafxNi3 RyeX+aquvtSGMPBEFVuqYzlVCPh085WeDt8pIGRUGdIg50WKjopVfEppOEUuv8mMAYV+ cxU11Ui0MJVVMJuEOJc+IMrqGr2J7dIxCo6NA6DjXHL9e5ii2JyY69FCqqKKTUrnTnIe b76MZm+G6JBipOiJqYyEFIAtG1MEbHPJDZgsV5pVtA01bG9TsL6jozIoy0t/2uiz+qo8 PwYQ== 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=grWbFCldgL720wZ6+WoT8uC1/mR1urOqvneOp/KMncU=; b=Umf4zHJDL4V1GIudDUx2zEgODv2WUxHd3kMcyx2HET03TNc3z82fsRp+EAyPPcZtUy JvRp7LDQzjTpcpzBIypsnDSRwMWIAJt02yqXccIgbP8vrsLXW2G0k8HkCglaBifAowfe ji9GW0DuQXDJoAYjJD1BkyT2ZSndd2F2X5bm8swv4yWtIjnJOIS08+SBwPqLFUEAI0YJ Ur7Iejnqx4pgIrsm2OhjXRsdMcXn7GN3hpGvMJ7jE5ZLUbinSdhS0wYDaA8S5WzxQceR LPTucXYFRGRMd4wA1Yb5jZatDG4KxMUrX6ruoTVe/g5WLoLL2bj7evUVv5N5zabk/WJN CJbA== X-Gm-Message-State: AOAM531j0h5/at3QUFhKP1km4WP5Hg5GK71d1uWzsv45YFhIFLlKxbGb tckIW1hzdceZrTHRymru0nHuezdD0UTCSQ== X-Google-Smtp-Source: ABdhPJzNjhFRhDJYHqiDbh2vsWEvO4bwcob0BeP4Y6O8RGPNurFbHb+VsK9URG6IBjOvO4xxOGvFtg== X-Received: by 2002:ac8:7dd1:0:b0:2de:600:a5ab with SMTP id c17-20020ac87dd1000000b002de0600a5abmr14314391qte.532.1646001347593; Sun, 27 Feb 2022 14:35: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 85-20020a370758000000b00648b7e3b8a4sm4206485qkh.111.2022.02.27.14.35.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 14:35:47 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v9 05/11] 9p: darwin: Ignore O_{NOATIME, DIRECT} Date: Sun, 27 Feb 2022 17:35:16 -0500 Message-Id: <20220227223522.91937-6-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227223522.91937-1-wwcohen@gmail.com> References: <20220227223522.91937-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::82f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x82f.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, 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 , Greg Kurz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , 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 7449733c15..2b9ac74291 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 Sun Feb 27 22:35:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12762171 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 4DB23C433EF for ; Sun, 27 Feb 2022 22:39:41 +0000 (UTC) Received: from localhost ([::1]:53258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOSCa-0005Tp-ED for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 17:39:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOS8u-00069R-F4 for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:52 -0500 Received: from [2607:f8b0:4864:20::832] (port=40745 helo=mail-qt1-x832.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOS8s-00032u-Uj for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:52 -0500 Received: by mail-qt1-x832.google.com with SMTP id t28so7502156qtc.7 for ; Sun, 27 Feb 2022 14:35:50 -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=FIM26iDeobdaVDOFSCZhx4ufdUObSP6716TqaQ3mxlU=; b=nshQHBjk4fa/+otyQzLDefnsy049mqpvhhtudGp1daoNkqJCWuW4JMOkjzBgHrWZjY v23PsRS+D6/JVbAE5lq9shzP8uUqkmn5F5gwhnfGusUDmITDW5s1w0gJNofS99OgfUEI UxyRIFxVhALluM1uJgFOwjfsB4icyle5EBB97HWMRO/mq3xYK1JlzWOCjHiHDK5iIW4n fh3RJ1hZeHWf1WGgVCJUfByRA2ate6z262DoY4h0wL3IlM+lKTCENAiSS+1+nuTqFT1R Q7IRM5QKSTNzMhhAY9g9WN0qSs4v0k5Z1Gb5UlHFiPBVP7eNn+oa0vBOmy5sR1tOhFVf a8iQ== 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=FIM26iDeobdaVDOFSCZhx4ufdUObSP6716TqaQ3mxlU=; b=BJGOT9K9V/YKHjuJErq33UwWTfpJdr1n7GFAfb4Nitcio9b0ok+N1MUNRet7JfNGhu J9fNlHghPbxIcv4LVJeE/5VHrNOdfprd0as+m6tNl7PTet7vcGp31rP2xwi3g2z0Za1M CXKqVViAAakDWGCPENSiM53CP92QWHAyDGD3am85NSZgsEfLxn3hrOnAgL4KxCm6vhyN Zry8JqjiMVne7t0+0Sgivuu64LVkjs6BML3hjuE6r7+2tjQsvD9Wkny6NawAFPw3mE6V Y7W4QVabX81PXyBjjCUSe9Mwwd7E7QZE7JfbaopWv1ma/7Dh8dmmlEvtQven3Zk4kb0r SdCg== X-Gm-Message-State: AOAM531UcpG4PBtOYmBSGfCYeLM2C4yu9wqk1FlwKmCkMV3oDf0f5YXs UvHa+vQ5yQuJwuRpNd/pMcg3hMpbJFwWrA== X-Google-Smtp-Source: ABdhPJypdz0d515MpxeuMYz2Xv7BPF80OWjQC4+PP171T6HDg4g3DZr75KEOpMr0F7VsNM8fDz2hXg== X-Received: by 2002:ac8:24d:0:b0:2d5:e1f1:d492 with SMTP id o13-20020ac8024d000000b002d5e1f1d492mr14554883qtg.348.1646001349740; Sun, 27 Feb 2022 14:35: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 85-20020a370758000000b00648b7e3b8a4sm4206485qkh.111.2022.02.27.14.35.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 14:35:49 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v9 06/11] 9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX Date: Sun, 27 Feb 2022 17:35:17 -0500 Message-Id: <20220227223522.91937-7-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227223522.91937-1-wwcohen@gmail.com> References: <20220227223522.91937-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::832 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x832.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, 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 , Greg Kurz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , 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 Sun Feb 27 22:35: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: 12762176 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 BBA5BC433F5 for ; Sun, 27 Feb 2022 22:42:25 +0000 (UTC) Received: from localhost ([::1]:33068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOSFE-0002Wi-P9 for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 17:42:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOS8w-0006F0-9q for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:54 -0500 Received: from [2607:f8b0:4864:20::82e] (port=42719 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 1nOS8u-00033J-Nu for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:54 -0500 Received: by mail-qt1-x82e.google.com with SMTP id 11so7495846qtt.9 for ; Sun, 27 Feb 2022 14:35: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=5V3o5RrwtkJ65v1m3Fl9y6glfQnm4FrYqCfEyCvWZQg=; b=WAqocweAlmkKrk63o+NP+Y2pFSKLXNQkFX8+LIi1mxJ0rUZGC4VGSyzM7BK+5RpLYh /iYg5Hjkc0sDxa+Ln0I0c5LtTBwYSTYXWZ3JUQKQATxaQUkmbculoRYwpJTj/jTf5sqs /JoJB0IzUf+nmrOWI3QnFAfCAKLT7Ni+lHKj3OaFbvHfJGKFvJs/AZ4a84yzRMsQAkvn L1TbU3EJ/zTygOehA0wkEi0XBNwUJ+Q4i4ZRX419ToXVhZLEL2KdSPgB+VSfMW6Hiz8j SV7BelqRWMVFJOOWzmN1XtUDD28wvPTBVMPEJb3UVr7sLl33JrfXGBOzmva92ybrrfE9 Pi2A== 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=5V3o5RrwtkJ65v1m3Fl9y6glfQnm4FrYqCfEyCvWZQg=; b=sYEFzI7kBWdO1NEOn6KdLYoM0pUcGdXYxpJun2N6qC+NqyQG5g2M45OLfYTj8NKTe0 3r8Jmh3811tnPhzB+pRMjVgsz7gyoobGI7qbUjQ2G1kenA4qKXxxAn4xeED94k7dhjDA cKOjY3+x7DiyG3ufAVv41FLGkMGVQ/rQ+tDZGzgmsA92Fa3mNuzbPPI6ewOQlwInJCWC iS3zvhfNEdW7POQE19p1aXjGx+8Ut8ygeeltVZX0UiwdIkGugBmkLcDVTgnTMVVpkF70 I5Whecx6SUfTQhn5RIT4QKyxL90CX1nXjximz90NNtf0/gqRulIiRwTCxNKk9f9cjVI+ WNhw== X-Gm-Message-State: AOAM531qHohsjVzVnzHd5d9hqTNWq1VdVi+aTBicRN+CNcTYBpFT/vmO Jpf+jpm/tajoVBbb0A9DmpPnSEtozIfUpw== X-Google-Smtp-Source: ABdhPJxWnZbWCnr6+a6we7eaRmmSN/+wfN8tBl4d25iko8ss6IJLv3Qcazmo0EisTkchm/HkJlXsRA== X-Received: by 2002:ac8:5bc2:0:b0:2de:adca:6624 with SMTP id b2-20020ac85bc2000000b002deadca6624mr12615508qtb.120.1646001351544; Sun, 27 Feb 2022 14:35: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 85-20020a370758000000b00648b7e3b8a4sm4206485qkh.111.2022.02.27.14.35.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 14:35:51 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v9 07/11] 9p: darwin: *xattr_nofollow implementations Date: Sun, 27 Feb 2022 17:35:18 -0500 Message-Id: <20220227223522.91937-8-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227223522.91937-1-wwcohen@gmail.com> References: <20220227223522.91937-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: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, 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 , Greg Kurz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , 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 Sun Feb 27 22:35: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: 12762168 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 6629AC433EF for ; Sun, 27 Feb 2022 22:37:25 +0000 (UTC) Received: from localhost ([::1]:46198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOSAN-0000m2-Rl for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 17:37:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOS8y-0006LC-4Q for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:56 -0500 Received: from [2607:f8b0:4864:20::82d] (port=46878 helo=mail-qt1-x82d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOS8w-00033l-Kr for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:55 -0500 Received: by mail-qt1-x82d.google.com with SMTP id a1so2961125qta.13 for ; Sun, 27 Feb 2022 14:35: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=cx3IAbAYk/hoLahf3lvx5zska0Zq3/ImEX6yhSjTN6Y=; b=E3hXSU0M8viXiaI/GurE10VQs2MrXJLdoT/9kBB45Rbt5Qr42G3MY9RpNv7V3kqMGA pjhdlnfCAg5L4Dbe4wt4UoQHM2xBNStk90b5Pg9u0TY4LOv1x4xKXSFC3zUwPoPGNMIr 498/JaCmd9wMiOnVPe3IKDmSCzP2WHg0OTuu4Sh57VL26qX3U+ciZpxtGYghDYL0/MZZ 63Gy7MXugm6mgvlRfSk9tvwWegeAuR3zBcG8T9XH4Y5YdY4lipJmHpXKie9fzKfDtIEz YdJbqkfG5OVrrN5MF/VOOqrh7TnSh+rZC7dtRmNITkLLABWNx5bG0A5LsaQ4U+5WGKKP VESw== 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=cx3IAbAYk/hoLahf3lvx5zska0Zq3/ImEX6yhSjTN6Y=; b=XCcs7QnzOw4b+OAOrHpNIcxJ7GfR0p8yutNVjHTfK2b8mzWYjUxYfrMUQEnHM7TeH3 w6A0Bak37m28OLNRqc9zYrcxFSgw0a8KLqzNpBukRZ3RCQUJvYcNjvbJ2SR++mwfDDMw nIdigWYJuY7KFZBMPQIPNPK2bN0pMMPYsfz9Ce986AMQw/8jOPhEemDMpWx7HU1chK3K 688Smicw2jR+A7jG//2WQCEgNeqfHqOUuq/wE2xJyZUyY/Sn1xB1nk19WJnvEIPuJ7YZ l44zSr2L7gZljTk7Xq2i5i8sNL4eD5YYFcJzoWESRbqCda5saObVFknWOcgO3BJORh3e Zj+w== X-Gm-Message-State: AOAM531/aep19kAsada3eMEwSnQJQ6nl8DIi8304ndmtXAks+NLWjcGT zE8KSpLn8BQ4o7+np7ZJBNHm518f/n1DbA== X-Google-Smtp-Source: ABdhPJyEIC9+anhdeXrHNNI3V74YO8rQRnJ4E9gTaSRaGRAziNmUm6b9JOw4BfFwJz8iJ9Z7ahFBpA== X-Received: by 2002:a05:622a:1452:b0:2de:6ed5:6230 with SMTP id v18-20020a05622a145200b002de6ed56230mr14552393qtx.619.1646001353416; Sun, 27 Feb 2022 14:35: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 85-20020a370758000000b00648b7e3b8a4sm4206485qkh.111.2022.02.27.14.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 14:35:52 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v9 08/11] 9p: darwin: Compatibility for f/l*xattr Date: Sun, 27 Feb 2022 17:35:19 -0500 Message-Id: <20220227223522.91937-9-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227223522.91937-1-wwcohen@gmail.com> References: <20220227223522.91937-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::82d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::82d; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x82d.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, 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 , Greg Kurz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , 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 2b9ac74291..9abff79884 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 Sun Feb 27 22:35: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: 12762177 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 DFD55C433F5 for ; Sun, 27 Feb 2022 22:42:41 +0000 (UTC) Received: from localhost ([::1]:33788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOSFU-0002zw-Jw for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 17:42:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOS90-0006UV-JE for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:58 -0500 Received: from [2607:f8b0:4864:20::f30] (port=40692 helo=mail-qv1-xf30.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOS8y-000346-Qh for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:58 -0500 Received: by mail-qv1-xf30.google.com with SMTP id fc19so11024058qvb.7 for ; Sun, 27 Feb 2022 14:35: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=BHiQ7cPhOTC7ZJN/pt7YZwNKBlBpq71we+N9cKrG0TI=; b=g0BzJ9ZlX15SSa0f6waeE2gHfFrcl7an8u00F3/6v712+J+wm91UOc5fn1XQqmkLej 3uXql76HVJfCFknLbHebOcpe/1m8ZwOmcUnvIcTsXz+skxWN024ETXkfyMnJeCBNepJe 9HAHo1ARrFGnm2JR9Xvrf8k/nD8y5jxwl8Z//lwPqiOStgDJq7xZwX6yVyBNQEsmdEG/ c03nzlOzA3Voy72u6Icv3VSdXcmvHD7ydYHOcRm37DL2rIGvLE6HWiUo3g89pHrOcnfV hrAm1E+s70qUb7JDAJlOTCs5meA/yZkoJOJmZJqIh59vi4xsjNVfzcpYlbnatbUuswZ8 1AoA== 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=BHiQ7cPhOTC7ZJN/pt7YZwNKBlBpq71we+N9cKrG0TI=; b=WvG/h9pMj7A22VpdSbcUMogtSG8pngL6trkRBR4NZJ4b8jMYefthrP4KhpTLDcnRhE KYaIw0VjClFeV4E7y7N509qhzC5Ov0P2XU4+/xb6sSsZA8HYr8AQom2jLKKu8qC8Xt3F HFrD3QFU/voWfj9il05x2zYPBak4WO+kovx/5g6Ch/nkxF+VTnrRlZNnn9EqW6ltCbCx tobCcz/Pwp6CJh4N1ZYo8J6UO35nFAcGPoU4VAfVOTbaHHUQoilnh1jBKPZDWLwOuAn9 k59blQiVCh3u6sAZwaljFjwOfj3a2hZ6jYyk7+I0QWfofUet/Zi/apcxqLNvK2rWh8JY RpZg== X-Gm-Message-State: AOAM533YN0+UbOts6cwrNQKormcVBe7Ri92lXv7vALK+usf2fPaNf43x K1nyO39hjwR1lSp/6Kxbrb4K4v50D4MJkw== X-Google-Smtp-Source: ABdhPJxik1HV6cWXaVzWfXzyjOlX6sf95R5vH3eVIvesObPokZhGH1Cnr8FvwLMAcm3xvBpxDfN0mQ== X-Received: by 2002:a05:6214:c4d:b0:432:91ff:ddc3 with SMTP id r13-20020a0562140c4d00b0043291ffddc3mr11842041qvj.9.1646001355502; Sun, 27 Feb 2022 14:35: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 85-20020a370758000000b00648b7e3b8a4sm4206485qkh.111.2022.02.27.14.35.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 14:35:54 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v9 09/11] 9p: darwin: Implement compatibility for mknodat Date: Sun, 27 Feb 2022 17:35:20 -0500 Message-Id: <20220227223522.91937-10-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227223522.91937-1-wwcohen@gmail.com> References: <20220227223522.91937-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f30 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f30; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf30.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, 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 , Greg Kurz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , 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 - 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 9p-util - Rebase to apply cleanly on top of the 2022-02-10 changes to 9pfs - Fix line over 90 characters formatting error] Signed-off-by: Will Cohen --- hw/9pfs/9p-local.c | 4 ++-- hw/9pfs/9p-util-darwin.c | 33 +++++++++++++++++++++++++++++++++ hw/9pfs/9p-util-linux.c | 6 ++++++ hw/9pfs/9p-util.h | 11 +++++++++++ meson.build | 1 + 5 files changed, 53 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/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index cdb4c9e24c..bec0253474 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -7,6 +7,8 @@ #include "qemu/osdep.h" #include "qemu/xattr.h" +#include "qapi/error.h" +#include "qemu/error-report.h" #include "9p-util.h" ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, @@ -62,3 +64,34 @@ int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, close_preserve_errno(fd); return ret; } + +/* + * 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_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() 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; +} + +#endif diff --git a/hw/9pfs/9p-util-linux.c b/hw/9pfs/9p-util-linux.c index 398614a5d0..db451b0784 100644 --- a/hw/9pfs/9p-util-linux.c +++ b/hw/9pfs/9p-util-linux.c @@ -61,4 +61,10 @@ int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, ret = lsetxattr(proc_path, name, value, size, flags); g_free(proc_path); return ret; + +} + +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + return mknodat(dirfd, filename, mode, dev); } diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 9abff79884..1f74d37558 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -112,5 +112,16 @@ static inline off_t qemu_dirent_off(struct dirent *dent) #endif } +/* + * 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); #endif diff --git a/meson.build b/meson.build index 8df40bfac4..3f8dca2c7a 100644 --- a/meson.build +++ b/meson.build @@ -1609,6 +1609,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')) From patchwork Sun Feb 27 22:35: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: 12762178 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 2BB02C433EF for ; Sun, 27 Feb 2022 22:44:59 +0000 (UTC) Received: from localhost ([::1]:38512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOSHi-0006D7-44 for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 17:44:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOS92-0006Zl-5x for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:36:00 -0500 Received: from [2607:f8b0:4864:20::832] (port=42723 helo=mail-qt1-x832.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOS90-00034G-Q2 for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:35:59 -0500 Received: by mail-qt1-x832.google.com with SMTP id 11so7495971qtt.9 for ; Sun, 27 Feb 2022 14:35:58 -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=sYK+uU7D+zXBtVgQvVfFVkY65lZgfTz3L/tbii2QHnA=; b=Ok/CfBVZbLWagnluIVfE6J9c6nO2QWI+bCl0iQA/hztHQwkueJRvgTH+Z2ztb8M7UZ hAs2CpE/fj3O2SsLx+GvGu86UnepFQKq1IR+UxFL8oEsaKi7GfwXLfMwZ0S4qfIATECm Se7pXquEO8Bz6/d7nk3daR6tl1w2C2YYLejNBQJ3v9X1f3RymE3jNLBIySa0ra5oC0kT fCextsIZvlJlc0upKhmAUsM0OTSglJLmb3NpMYAjumrEAVsBVZI0ZKSyEQq40HG5/YEP N6W3ikghZBt6WbZHMRbtGMg/eULTMyHv5ehyurZHMh/D0trgTo4yN8zo7ti5xzsFEilM OXdA== 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=sYK+uU7D+zXBtVgQvVfFVkY65lZgfTz3L/tbii2QHnA=; b=ZeFWA11KeiumEYAdl1ddIzXgdrwPKBjcwIx5HXHUXdiWw7GFGm/rOF3JdpQ+261A81 6/jF6JCeyBHIW8lzTUdvOy8A3mIIZzfP5Nc2e/Hxub14hTa9mVCdJLzzQfSe1Rt3hr43 CUz6s7CXyQxHJocv6ISL+7vvoq9lrlcjaYjzKiS4hM4Z7dtsj1TYReFM6UL1EwwdI7iS nnlHAXwgMDEDiAg5E55PmddEpEpkIOZxWckJQ6f2uk1RQfr2qoaxswIjHLWl7Jo8o93o RpTLWYxQM8GXj3QS3iPiK+unGFqlV2Ba5mdRq8cgJud266da+aLdy3gMyR4fxSJqpLpR xLiw== X-Gm-Message-State: AOAM531y6/uTx0XhVNQiqo9JOKo9hyp7ym69iUi5LTv1vc1CpBoscu0W bucXJr6fGzzyivcBJYNuCbp0hSfSu3Ivjw== X-Google-Smtp-Source: ABdhPJwSpFpawEg5kBRJV85yTAZcfo/sYJDOEAK3OdkoD2bRJZd9/6mqbfiMMhJNGe/anCjFNLqqjw== X-Received: by 2002:a05:622a:311:b0:2de:3a91:1610 with SMTP id q17-20020a05622a031100b002de3a911610mr14158290qtw.487.1646001357151; Sun, 27 Feb 2022 14:35:57 -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 85-20020a370758000000b00648b7e3b8a4sm4206485qkh.111.2022.02.27.14.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 14:35:56 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v9 10/11] 9p: darwin: Adjust assumption on virtio-9p-test Date: Sun, 27 Feb 2022 17:35:21 -0500 Message-Id: <20220227223522.91937-11-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227223522.91937-1-wwcohen@gmail.com> References: <20220227223522.91937-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::832 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x832.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, 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 , Greg Kurz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , 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 502e5ad0c7..01ca076afe 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -1253,7 +1253,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 Sun Feb 27 22:35: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: 12762175 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 32DE3C433EF for ; Sun, 27 Feb 2022 22:42:16 +0000 (UTC) Received: from localhost ([::1]:32806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOSF5-0002Ma-6Q for qemu-devel@archiver.kernel.org; Sun, 27 Feb 2022 17:42:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOS93-0006ge-R0 for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:36:01 -0500 Received: from [2607:f8b0:4864:20::f32] (port=40694 helo=mail-qv1-xf32.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOS92-00034Q-A9 for qemu-devel@nongnu.org; Sun, 27 Feb 2022 17:36:01 -0500 Received: by mail-qv1-xf32.google.com with SMTP id fc19so11024115qvb.7 for ; Sun, 27 Feb 2022 14:35: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=d9UzsPeW4T7EXhLiuNPioNvRXgwZFWkJYEU5xtJM/Jk=; b=ES/CvqZuQUL6OaAzUDcjWUhlg3XKdzabIXiSlZixudBPiwfGjK/usaMS0SoWfYExqV 6R0K26rkz/7Ifg/Ve98zXmRjOwfzTLjU67MQM2nOMxK1a8HqhVFRWs0PBc5FP8kupyUJ mtsSxmSnK95lebOov8Tn7bksRil1H8v89XCOu6DINoFN8x6oIxZg1jExDTBxBS/pLepI i5rlUPSLofhbb/l1y/m2i2YI14zGtfT39CbkI6PwbqMr6cNsFXw5YNnXemi34D1OvaT4 Qbk7va20FkxVvuJB7piyGebLR3a8LSXiB3y56pl2WxHfBYFGJkeBL6h8qofPSnMQTday PpAg== 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=d9UzsPeW4T7EXhLiuNPioNvRXgwZFWkJYEU5xtJM/Jk=; b=EGlK/yQYq0nk7CjNoHCJQlBhT1LSAHvAvXW84L9dNg7sgJF1rLmj2JobJZMCalkm65 sztIi1Npe2BHvXzG/Xm99QY6FN0V0WdnzDCY5jSilx5kKKU0p+i+/rex3z6npa5IN8lW nS83zAMILgaEiZ5sZPw7542nnO2EXk7QC9549iKKhTBOTz6z8ELZh44F7drDnkPLSpf+ URZUCNLvrjDwSa9zKy/OCfJlg/a3iIEKCOGCKKoQEsHw29DnV1M6cpUuPGRRc61k1DNN BXO3ESbwAwDmZCS1VgMulDRf/MD7kQDSyC1kyWt5qUei34Amg96O0ZvRiTfm0Kp4o0mg y3YQ== X-Gm-Message-State: AOAM533Lk7JaWgPVAG5xqOcAy9Kk+5pFzcn2dJWpIdS6G6IfT6iKUGv9 dAVUV3gUKMB3BoHEDUYRNZ4h1uBzvhVjTQ== X-Google-Smtp-Source: ABdhPJzLdKwYUxtsKvOXQO080JK9GRH0G3CToneiORfIYpHCuV6HVcgPE4LwDCJgHMlX/RfvxoqlMw== X-Received: by 2002:a0c:bec8:0:b0:42c:2e00:78b3 with SMTP id f8-20020a0cbec8000000b0042c2e0078b3mr12384016qvj.32.1646001359178; Sun, 27 Feb 2022 14:35:59 -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 85-20020a370758000000b00648b7e3b8a4sm4206485qkh.111.2022.02.27.14.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 14:35:58 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v9 11/11] 9p: darwin: meson: Allow VirtFS on Darwin Date: Sun, 27 Feb 2022 17:35:22 -0500 Message-Id: <20220227223522.91937-12-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227223522.91937-1-wwcohen@gmail.com> References: <20220227223522.91937-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f32 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f32; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf32.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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.659, 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 , Greg Kurz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , 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 - Rebase to master] Signed-off-by: Will Cohen --- fsdev/meson.build | 1 + meson.build | 12 +++++++----- 2 files changed, 8 insertions(+), 5 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 3f8dca2c7a..ba52ed9e9a 100644 --- a/meson.build +++ b/meson.build @@ -1450,14 +1450,16 @@ dbus_display = get_option('dbus_display') \ .allowed() have_virtfs = get_option('virtfs') \ - .require(targetos == 'linux', - error_message: 'virtio-9p (virtfs) requires Linux') \ - .require(libattr.found() and libcap_ng.found(), - error_message: 'virtio-9p (virtfs) requires libcap-ng-devel and libattr-devel') \ + .require(targetos == 'linux' or targetos == 'darwin', + error_message: 'virtio-9p (virtfs) requires Linux or macOS') \ + .require(targetos == 'linux' or cc.has_function('pthread_fchdir_np'), + error_message: 'virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') \ + .require(targetos == 'darwin' or (libattr.found() and libcap_ng.found()), + error_message: 'virtio-9p (virtfs) on Linux requires libcap-ng-devel and libattr-devel') \ .disable_auto_if(not have_tools and not have_system) \ .allowed() -have_virtfs_proxy_helper = have_virtfs and have_tools +have_virtfs_proxy_helper = targetos != 'darwin' and have_virtfs and have_tools foreach k : get_option('trace_backends') config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true)