From patchwork Sun Feb 6 20:07:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12736692 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 6BA37C433F5 for ; Sun, 6 Feb 2022 20:09:40 +0000 (UTC) Received: from localhost ([::1]:59124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGnqt-0003gN-7b for qemu-devel@archiver.kernel.org; Sun, 06 Feb 2022 15:09:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGnp0-0000zV-Tw for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:44 -0500 Received: from [2607:f8b0:4864:20::82c] (port=45882 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 1nGnoy-0001Ll-Im for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:42 -0500 Received: by mail-qt1-x82c.google.com with SMTP id o3so10372740qtm.12 for ; Sun, 06 Feb 2022 12:07:38 -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=7VrP8O0AdqK/u4F+RuTSoaaT8lvAheKukWLQXUnaYck=; b=cm+7X2v0MPt1a476I73XvMI7ucwl0A/FyGARTbgMzXn2++C8PkHgZJh7VfppzoVPRX R2nUHpRl/PgYSZ0lwUYc6H9DRhaKWLDut/OdVwzNSlo+pBd3owAZaY7XSD4jCYEiGQpS kT39PDcUIZA3cq6TZZZGhhlkdS73EoNil2mwbvPOMsX8VbyXmp2ktUmyeTthyW7cgiC7 NujQuCUFVkadmGSoIHQ5NF02ZK4FR2Hd2Y2VNwcAvwdhKa+vA809SL7cEMlHLeubnfR/ rwQc59JMk/IocK8+ysPFBT/ELhCIC0l4SxU3JmoQWIR6C4wqNubgoe9prRnAOscFPoDq YTHw== 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=7VrP8O0AdqK/u4F+RuTSoaaT8lvAheKukWLQXUnaYck=; b=aZn4vSLZ104Hel4Pv1r1Eh137byKQ09hdnG+ISt5dUPnSwjdddBrU8MczWBtzR5A0u Dmdl6so8nVAf+IlXD/SrcBWZ+w4MSTGwu3rENqINIFxmhTcoHiJjDR8+LeeBNJGcu6RB FBrok8GuMKHjdbXPNYg6AnwKjhZLmyEkmYllViFEhXCRTydQS4zXgN8ps+mmlErJQM4A DSKWjq2cleVvUGIbsklrR05uLMdfatftxg8hy2vq4svuzwdlAyzMNrIEyq3TEhZebJHU Rcny0OmzY8i44tdX3xOCruVtQJqNlRBg9h81PvmllUarGVdtjRxO91X1PjjjOK9uEo7U n1Lg== X-Gm-Message-State: AOAM533e02pzfZBNjmhS/cpQRwtYrP3ltQWR/EBb1hSi5240E0bOvaWN zrTbCjB3tbwVcNS7oqEvE95tRpHQ57yjPw== X-Google-Smtp-Source: ABdhPJyXZJATsMpQTOQ8m/RJKsq8N8z+GxFmARlupAnnjkwHnQoKJwrwHNBAvaaQiyZqmEpZHJlSxw== X-Received: by 2002:ac8:6edb:: with SMTP id f27mr5923434qtv.372.1644178057676; Sun, 06 Feb 2022 12:07:37 -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 j11sm4625999qtj.74.2022.02.06.12.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 12:07:37 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v4 01/11] 9p: linux: Fix a couple Linux assumptions Date: Sun, 6 Feb 2022 15:07:09 -0500 Message-Id: <20220206200719.74464-2-wwcohen@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220206200719.74464-1-wwcohen@gmail.com> References: <20220206200719.74464-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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, 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 , 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 6 20:07:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12736696 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 BF1EEC433F5 for ; Sun, 6 Feb 2022 20:13:03 +0000 (UTC) Received: from localhost ([::1]:39390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGnuA-0000zK-Lf for qemu-devel@archiver.kernel.org; Sun, 06 Feb 2022 15:13:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGnp1-0000zY-D5 for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:44 -0500 Received: from [2607:f8b0:4864:20::833] (port=44969 helo=mail-qt1-x833.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGnoy-0001MP-PE for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:43 -0500 Received: by mail-qt1-x833.google.com with SMTP id b5so10370198qtq.11 for ; Sun, 06 Feb 2022 12:07:39 -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=SRawlGntANMvftiiUCe4tAsAdu6ihoZUG3xl9ZVAmto=; b=piE/I2vNBWfT2vQAkzIj/tUBeFgFlS0Sy+f15t/q8DtYiMW5jT3quc/Z4ZupncM7pk 24ss+N2MI63GTT15kw7viFmjq+eIBmmrSpWJG4A6PXjGkIpRE+AShV6TewuskuhUML/7 47oNcwZn2a6He9P+2wGV9t1VKDM4R68f7xv4iVshCLspjToYw63y95FmYkzbXHRY0HKu uqp4GrgIqQIiXsTuF9jnizZqMatGdqvLpNoj3vcFIbI2+JXtpVs8N3SkXFmTzftMg6V1 2DWt7fYkEXC/gS2N3FJ+ohscEgVg1eTRRcFL/FEqAqChLUX+2ptHyDV+wAPj7OGVYm4J e79w== 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=SRawlGntANMvftiiUCe4tAsAdu6ihoZUG3xl9ZVAmto=; b=uH3H7BThGfWhYhU84zvRrnOZ6OkzsFvnpka0DW12kXH1A6luMFVOSlqmljm9rBr5FR H3esvO6HicQkeNZT4s50/hqNASAftNVuxYtD/27NnV04EvqjIuI+/I6OKf/BbiIyhqav Cp4dPF+mgjIjrT4vSZ3QtnaSrnI3vaY8wR0leb69AUIs8Oe2U6Y57uCebCDNXkj6sr46 zDI0qBin/MlVk+DasqCXmQAaXYLV/Dzla/DAj206EXhYkUPFTtPSyIGHHg4hLeKwFr+2 Yazyq7KWyhqMFWAt/8uPD6I3ICVixN6pmaaOVOMEOmTHYsa0T7Xd64skvVrVoKKhlyC8 /s0A== X-Gm-Message-State: AOAM533Sl6oKJg/V09lSjPGo2A0vAwOUUrnlYyzmnf+Zei1YSu556tPo RqWDxymVvH6rOduW45NDjLlC0aQrbmzuGA== X-Google-Smtp-Source: ABdhPJxzIiOYUIRS5HbSHgxYmfxJowCbhnNpRXDUZtv6ur2kbsbgDaQppQut/GttjuMm0zlf4pZjEg== X-Received: by 2002:a05:622a:514:: with SMTP id l20mr5926523qtx.26.1644178059036; Sun, 06 Feb 2022 12:07: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 j11sm4625999qtj.74.2022.02.06.12.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 12:07:38 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v4 02/11] 9p: Rename 9p-util -> 9p-util-linux Date: Sun, 6 Feb 2022 15:07:10 -0500 Message-Id: <20220206200719.74464-3-wwcohen@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220206200719.74464-1-wwcohen@gmail.com> References: <20220206200719.74464-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::833 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x833.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, 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 , 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 6 20:07:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12736698 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 83EDFC433EF for ; Sun, 6 Feb 2022 20:13:06 +0000 (UTC) Received: from localhost ([::1]:39560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGnuD-00015e-6o for qemu-devel@archiver.kernel.org; Sun, 06 Feb 2022 15:13:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGnp1-0000zZ-N4 for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:44 -0500 Received: from [2607:f8b0:4864:20::82e] (port=40913 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 1nGnoz-0001NV-Hh for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:43 -0500 Received: by mail-qt1-x82e.google.com with SMTP id v5so10397514qto.7 for ; Sun, 06 Feb 2022 12:07:41 -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=/PP73rDd+L0mrT4S3PimAKm7HxWjvE6hAnQLDLlK/gY=; b=G7pEwco1bCtddanhet41AbHuGOHYFklWmPxPyk7xUIb7OCXIjckc3t5b5QFUkZ6bOK jfKwUj3+tfK1Yl/g7kcKALv18q5B5aB2NxQ2MumzieX8yz8iygvLCs7Vr3FYet4GxMrw ABzb1fFftc7ds3ou5IdEEQRga19H0Hl32RqzQmX0zssMy7xcaATkYJDu4qHfCOEp/Tck A/QCy7bh5sDxcGnHvtF+06ywmelL9iqhYkXVzSHPa6xmObDn1HIzYbH6UhaVdwyqVfTd qj+fBdgffrobqUANnj0kZrYTTXRXEUs/FXddx2eWbHA0C9VQv9pgtFKZw482MX1uAfko aIhQ== 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=/PP73rDd+L0mrT4S3PimAKm7HxWjvE6hAnQLDLlK/gY=; b=oF4ZG7PI7JxPxNhxVYAlP2WdCZz5jzZsMuIg2sx7L5tZCGG79+kwydDt2JnwZ0z/Nm aPEnNk4x3G4150tNTKqIC0PRoifRNWimvV9iDrSuODSUidQom5n6i3man5/fWQBBLKmt UaJp+mWj91lUVp3ysUPjk47+KAz+34ZPVmoEqALP7L2F/hCo8NHMG5PGjBtH3HtpvJ0v KtYIIbr80TsmmrstuEI8YS/9QrKTv0GmqH1B3RCth5jURb1FCVmQYUdsGJAfdUE69B5d 84ap/Fv4m6r5s5AoaljDuirQmw9aUoA2sefdyeGD/gcwzrwaNvOvtGVpfmiafuU/r/3d 3AaA== X-Gm-Message-State: AOAM533Jam0vApWi/V4FT1Y/y6yZGX1PWPcHwAyOhC87zZSQhZlnQJL1 7XSHQmkSzsAgz0B2P2B0KPkj6BzT7VdHjA== X-Google-Smtp-Source: ABdhPJzXtoKwWUw5D2Qn+KamUb6ouU/s9VdUwURO5p5c21ve4U4+xWVgSo/iLzVmq9P61rPPt+OhDg== X-Received: by 2002:a05:622a:2cb:: with SMTP id a11mr5835800qtx.425.1644178060309; Sun, 06 Feb 2022 12:07:40 -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 j11sm4625999qtj.74.2022.02.06.12.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 12:07:39 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v4 03/11] 9p: darwin: Handle struct stat(fs) differences Date: Sun, 6 Feb 2022 15:07:11 -0500 Message-Id: <20220206200719.74464-4-wwcohen@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220206200719.74464-1-wwcohen@gmail.com> References: <20220206200719.74464-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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, 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 , 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 Sun Feb 6 20:07:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12736694 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 F2DF7C43217 for ; Sun, 6 Feb 2022 20:09:40 +0000 (UTC) Received: from localhost ([::1]:59156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGnqt-0003hM-BJ for qemu-devel@archiver.kernel.org; Sun, 06 Feb 2022 15:09:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGnp2-000109-QI for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:46 -0500 Received: from [2607:f8b0:4864:20::835] (port=37853 helo=mail-qt1-x835.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGnp0-0001P0-QF for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:44 -0500 Received: by mail-qt1-x835.google.com with SMTP id k25so10416438qtp.4 for ; Sun, 06 Feb 2022 12:07: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=iJyODe9ehnMtKfd0wxTheYqR+Y6NpRJnSCt+IuPoDHE=; b=gpEPYa+PDercGaP89q5QsOhBpsuDhFmlhSGy5nY4FpQWiW7/wlwWFYd21sy/dBvC1c QRJ60ZJoPDDQGpk194JR5Mdsele81pWWp3nSPlCA/tkmC+LhACPSaA0vx2UULBrdZeWc 73/MDPrLxebSw1a3aso1LNJXqGlg/W3PFUCAv2RQrz+IhwDH3VBGhRPHjezTrkk+KnCn ntBtZNL4lDPcPAI+Xnmv3iQ0TOsMljNURdJnXHbNl7f0+2SYU+xOT6vdKin23HskJ9J7 zaq17zKCKQR25cKAVjY7lFWnlavzlB3x6qN9ZIy+TvXt5UgklJoApjTgBH6OKfrMLoIZ 7pDA== 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=iJyODe9ehnMtKfd0wxTheYqR+Y6NpRJnSCt+IuPoDHE=; b=HIhnDKFMvdhpAViv17ih6kYbJMa4nenk4aWYR8pe8LXujO64gK1SAF26LB6PQ1yTBz e2BC+IsQis6k8o58ja3QmVWlBT/oElRsSYZgRNjcpNEYOpzs0UNrmdn2Gxm531CP/A1Y a4IladbbUe/MdIWrna9cmqz9lPGzz0IWebeGmJk+245NBr2+s2ietK4wVpeqVqZjMqZf QdXHWC9ujTrGqAYNlImaVoxzUrYIn9Woa3lhPRBdzxcDltLW049mURXmQqY/QtQtb3qq JxJQiX/B0RuhfMeB7lwrryeLjbkgQcv2u7jq9XCho1nGBsbTtLnUYXYhkB9OFq2BN0wu xEYw== X-Gm-Message-State: AOAM530uD4+rMrkjTaJy92uTLvkH8RcQWqYQhJFhVae3kTILCjIaQ3dO FBgqWEP0a5G4/PxP8VGF8XddZ9Vfce1YiQ== X-Google-Smtp-Source: ABdhPJw8Vy1jqKThWDgmOmBSEC8PDI3rSajo/4Eyjz7kY25rFt9DyCBKPZkegzDhEtNYcVOnV9N9sg== X-Received: by 2002:ac8:7c43:: with SMTP id o3mr5955051qtv.103.1644178061663; Sun, 06 Feb 2022 12:07: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 j11sm4625999qtj.74.2022.02.06.12.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 12:07:41 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v4 04/11] 9p: darwin: Handle struct dirent differences Date: Sun, 6 Feb 2022 15:07:12 -0500 Message-Id: <20220206200719.74464-5-wwcohen@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220206200719.74464-1-wwcohen@gmail.com> References: <20220206200719.74464-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::835 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::835; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x835.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, 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 , 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] [Will Cohen: - Ensure that telldir error handling uses signed int] Signed-off-by: Fabian Franz 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 | 17 +++++++++++++++++ hw/9pfs/9p.c | 15 +++++++++++++-- hw/9pfs/codir.c | 7 +++++++ 6 files changed, 65 insertions(+), 3 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 1a5e3eed73..7137a28109 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -559,6 +559,15 @@ static struct dirent *local_readdir(FsContext *ctx, V9fsFidOpenState *fs) again: entry = readdir(fs->dir.stream); +#ifdef CONFIG_DARWIN + 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 if (!entry) { return NULL; } 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..accbec9987 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -79,3 +79,20 @@ 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..cf694da354 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,11 @@ 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); + if (saved_dir_pos < 0) { + err = saved_dir_pos; + break; + } } v9fs_readdir_unlock(&fidp->fs.dir); @@ -2420,6 +2425,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 +2486,17 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, qid.version = 0; } + off = qemu_dirent_off(dent); + if (off < 0) { + err = off; + break; + } 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..fac6759a64 100644 --- a/hw/9pfs/codir.c +++ b/hw/9pfs/codir.c @@ -167,7 +167,14 @@ static int do_readdir_many(V9fsPDU *pdu, V9fsFidState *fidp, } size += len; + /* This conditional statement is identical in + * function to qemu_dirent_off, described in 9p-util.h, + * since that header cannot be included here. */ +#ifdef CONFIG_DARWIN + saved_dir_pos = dent->d_seekoff; +#else saved_dir_pos = dent->d_off; +#endif } /* restore (last) saved position */ From patchwork Sun Feb 6 20:07:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12736702 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 B40A8C433FE for ; Sun, 6 Feb 2022 20:17:36 +0000 (UTC) Received: from localhost ([::1]:47244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGnyZ-0006Mp-Pp for qemu-devel@archiver.kernel.org; Sun, 06 Feb 2022 15:17:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGnp3-00010A-Qb for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:46 -0500 Received: from [2607:f8b0:4864:20::835] (port=41728 helo=mail-qt1-x835.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGnp2-0001Pk-1i for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:45 -0500 Received: by mail-qt1-x835.google.com with SMTP id y8so10404901qtn.8 for ; Sun, 06 Feb 2022 12:07: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=TjA/RsdUTSLR+v+0XwAk5IVoTXujYprMjK0qceiu15c=; b=nKDEo/ad/k5W3w1KAJm5dsOk+/FvuHA0xeolhFjfHCxeI124KSwyDSKTt000MXuZsz nyvTxiBCguJuztLilYdmUuUS5Ih4HJGyuXmN56gipSwgtaq/0GoP1mk5/4BljrlLZ//y nwVSHejcmhWUepYutEWLai+xNM5ESXebWjfLFkQF1eD2fiEKybPrB8992CEFshuhMf3+ 2zx6pwgZDsEFdYk7rfyTo81QJUnHRTltJXZLHVa+kFsZ1tu9EpToqaCIrsjTsmMso6S0 LOYW6Wt3QvyCCADtGcmB0JOmIteyYYHTtOfqIweV3dffYGQ5+8+uWEzovqiBl/+9Udnv +hIg== 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=TjA/RsdUTSLR+v+0XwAk5IVoTXujYprMjK0qceiu15c=; b=7d79qr0uGRxncbD7hCtyRg0/g0aDOnhLhwJV6Zxd5d1QEkx0gTAAGFj98/O2j4/sSI fyJe0avh6pcrBryIuhJymi+NEjuPLydn6Pd5AeO/tLK9jtAq1qy0JqnwaXVxLhFkBCXg 80/yitQ3MXPUnEs0uexlPgni2gI6ih5r/83GEzzXlzUuCRHfk8G0U/C2Ml5icwI8hhiO ifDvjkrBn4VbKJj3MIDHv4CwoQh0Xv8NvdzUDLIQrjmmiDBQ0NvcdpqCR8IUNfF76TzZ JteXpWl1IDU0trrD+UHuBfLP9KxKHykHwhWbQub9ZAFLy+V4NXLfKat220mGx8JZtK8s LHmw== X-Gm-Message-State: AOAM531lIrTo+uolkzsrPnw9tJMbjPQtmqMMllclAlh9QiQ8G2Q5fksx THE/b99uQCqiNvPSjWy2fapPSQbW9SXIwg== X-Google-Smtp-Source: ABdhPJzfbDshIEtEwU/hxIfHwr2kUlv3do0Zocn56YYeChdgeU5d7L3NonBjrusB36jIIIhU5Pf02g== X-Received: by 2002:a05:622a:1786:: with SMTP id s6mr6007530qtk.386.1644178062996; Sun, 06 Feb 2022 12:07: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 j11sm4625999qtj.74.2022.02.06.12.07.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 12:07:42 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v4 05/11] 9p: darwin: Ignore O_{NOATIME, DIRECT} Date: Sun, 6 Feb 2022 15:07:13 -0500 Message-Id: <20220206200719.74464-6-wwcohen@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220206200719.74464-1-wwcohen@gmail.com> References: <20220206200719.74464-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::835 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::835; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x835.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, 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 , 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 accbec9987..3b9c485414 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 cf694da354..f3b00d20a2 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 6 20:07: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: 12736697 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 6FD59C433EF for ; Sun, 6 Feb 2022 20:13:04 +0000 (UTC) Received: from localhost ([::1]:39532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGnuB-00014a-Jj for qemu-devel@archiver.kernel.org; Sun, 06 Feb 2022 15:13:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGnp5-00010i-8S for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:47 -0500 Received: from [2607:f8b0:4864:20::82f] (port=45885 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 1nGnp3-0001QG-FK for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:46 -0500 Received: by mail-qt1-x82f.google.com with SMTP id o3so10372860qtm.12 for ; Sun, 06 Feb 2022 12:07: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=7OsikZblJEO4FkeB434ZL2dxZiElY/T3vTaiGslty6k=; b=pKnwHtMoTz6mqViBmOdGUDVf873kOm5rQh6BsbA2jFqeaFEcBBwu37qrYEihTiDs5z 5fO28acl/wzkFAzvPzNM00Fcafu5TAbwIX+1aXqri2nQyGnE2YFEjuO3OgqJUR0vjrKL KzwOSQgGx87mHwWCsIUAtXjlLxWgHE/A7LkVZLD4vfQ8SFoJ1sDYBikbNJ7BUp+LOFQU 5WR8qokdFURKETYDz4ccffQ76hlMDj94PFQNqJtQXqFmbmWNNUpTn+vlH6WddHtvr4wZ hUBmdvUs9qbEDpq+CYBkZCJlbf+K/mWmMR3slgjaRpVrCjbrjYxMWULLleOqZns1WKzS AS8g== 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=7OsikZblJEO4FkeB434ZL2dxZiElY/T3vTaiGslty6k=; b=g3ihxtMSHfrFYgLI+SjWGUmb0dgchWBhWfahLGAbYIkNtAxlSFfFw6QtIXM76FwZa6 usWXeuV2QbGfxezzYgsuVeTWRToJAE/uSZQghjOYYMczkRXDzEtjJjCzds3O8ovQH6Xu 4RtU+knaEjWAGWbihpxwXT+WFckjYT0xc8YCIwqrhLoiQlkglczaEd2l92tWOW6sqVN1 4fKLmf/jewq+FLKTiZNAT2H/qAvaxkYwrL1zUZ0cwg/jvMZQgykOWoWqGTQW1v9ZDtcN DbUlxh/rcMgj+mIYAg0CYUCg/SwujAF/0jNxpAyvmrLvYLTNG4fAjwM9vWyZ0GQv3aUr DrTQ== X-Gm-Message-State: AOAM532DF5r+0vx7MWyLV91mq+isTiqT88AkCS67U6nCN0nlub+2MxhW 6vrVnFSirKvPIkK3Qo/KvvT4avBbdgROUg== X-Google-Smtp-Source: ABdhPJxL+Kjz9Q+UdMr61fXLBL48UQjOXkvjb+i9xoIDxpPZDQwY1OTpBG9Go/4FwCpdyZX9QOYXXA== X-Received: by 2002:a05:622a:1010:: with SMTP id d16mr5970587qte.632.1644178064313; Sun, 06 Feb 2022 12:07: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 j11sm4625999qtj.74.2022.02.06.12.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 12:07:43 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v4 06/11] 9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX Date: Sun, 6 Feb 2022 15:07:14 -0500 Message-Id: <20220206200719.74464-7-wwcohen@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220206200719.74464-1-wwcohen@gmail.com> References: <20220206200719.74464-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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, 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 , 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 --- hw/9pfs/9p.c | 2 +- hw/9pfs/9p.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index f3b00d20a2..440bf5c9e5 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3957,7 +3957,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..6a1856b4dc 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -479,4 +479,15 @@ struct V9fsTransport { void (*push_and_notify)(V9fsPDU *pdu); }; +/* + * 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 + #endif From patchwork Sun Feb 6 20:07: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: 12736700 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 628BDC433EF for ; Sun, 6 Feb 2022 20:17:31 +0000 (UTC) Received: from localhost ([::1]:47046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGnyU-0006FM-9g for qemu-devel@archiver.kernel.org; Sun, 06 Feb 2022 15:17:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGnp6-000115-Cf for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:51 -0500 Received: from [2607:f8b0:4864:20::f2f] (port=37676 helo=mail-qv1-xf2f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGnp4-0001Qe-Rc for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:48 -0500 Received: by mail-qv1-xf2f.google.com with SMTP id a19so3179343qvm.4 for ; Sun, 06 Feb 2022 12:07: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=SfDmPYg4RTmB3VAHnPteuLcf45MmDDEEAkNdkij4Il4=; b=Lvb5B8j/VF/BXw2ifBTX5J8FbJtaNNOeaRc9cMpt/tu1EV8nDIUnzOx9pLl68JVdOz 9zYxvRgi7ErZ125DJ6hEylZct1EkU2nsS545MRrVLY7lX/GpBdyaYJhakru7FDWI44AC ul8T6H6cLab5iqGRGWwrydloqW8XCX0IqpzkFzNllqaQac+WoYmqqDnCT5TPBG7OOlQ5 s95MoOHVw4UM4SG8BWGOdAyueFJ1xjt189ZxMszHdJrSpp4Ra52ALuiVOcisVwgj01zY KflNZYVKJGLsXwBjhJsi2kkf+kd24cgpsFEITdOn0XVBxp8prwa7yUXsvU9YyclLXFjd UVqA== 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=SfDmPYg4RTmB3VAHnPteuLcf45MmDDEEAkNdkij4Il4=; b=g8ZhYbqpWtVg/qLtsEEdRv7iFRkoys/6580Eyn6o0mFeS02qBHl2/2NESbD6r14VtL NpTWHW8us2TXIDBqScG48wZ/DlUYSMCWR2GuIgiSchQ3U7jWAPTaEZ2clGWUsXZHKS4a TCMg2c3t21sUIHL7UYUjSAFmtg4RiTxrmiGyrzI1VcAiYeYSBXv2HY34cGANTNAJopLz OTlne1mK7SxYhhibHBFHM9t5nGd6iX23e7AIyOa6tY9K3TXbFtCwA9ttoRuvH8FHI098 4KI4RsRC5Br7vwAX90fKenJ7Aehgf/91LAqwsDn4KcWuxhwDLfOPBXOlb5vnVnbc7ajn QHEQ== X-Gm-Message-State: AOAM532UR9HM3mV2gZy8VLIUO/DBDFFUnY6WUUbqNX7QhEHU8YpDeAow VBITh98jV1UNCw299RE+Ei6VQ+sNsGKw/A== X-Google-Smtp-Source: ABdhPJywUyBqyDCPyIX4wwcPa3BQiTDUceqaBc9GpZNidKDrtQd3/gtfrrLUrWp3nTjxXImoUIQazg== X-Received: by 2002:a05:6214:411d:: with SMTP id kc29mr1721177qvb.65.1644178065602; Sun, 06 Feb 2022 12:07: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 j11sm4625999qtj.74.2022.02.06.12.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 12:07:45 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v4 07/11] 9p: darwin: *xattr_nofollow implementations Date: Sun, 6 Feb 2022 15:07:15 -0500 Message-Id: <20220206200719.74464-8-wwcohen@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220206200719.74464-1-wwcohen@gmail.com> References: <20220206200719.74464-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f2f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2f; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf2f.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, 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 , 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 6 20:07: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: 12736701 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 8C7A2C433F5 for ; Sun, 6 Feb 2022 20:17:34 +0000 (UTC) Received: from localhost ([::1]:47102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGnyX-0006HT-ME for qemu-devel@archiver.kernel.org; Sun, 06 Feb 2022 15:17:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGnp8-000118-28 for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:51 -0500 Received: from [2607:f8b0:4864:20::829] (port=35622 helo=mail-qt1-x829.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGnp6-0001R5-Hr for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:49 -0500 Received: by mail-qt1-x829.google.com with SMTP id j12so10416235qtr.2 for ; Sun, 06 Feb 2022 12:07: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=Cz8XpkPOdA2WQMQ3HZuTliXREPjA7/5mOjW7Wh5oezE=; b=JtjEJcB3WU50O3pYVJrjsC+/ormf6Y0Ur5+zTY0wcWh/LCzw/iELCdJ+uk6VS58vB8 7gVvVRzn1PpCxRnkRbT6Ou1l88pH2003KsjWGeZIhy+l+IJwoYSEd4xybDDFLpLF07uH MQ0evJwUavsQIBkwpkRHSol2mrrlk+zt5OHllt1y57it5u9vcjReAk+HKI4QgACDyBgC aTZTSK/d7c/JCHG3CbS/e20hdsllvNp5eu9guttujNVcFgQC+UH5zmreVw6nGW0XbGxJ WchGu5cxYGzyZcTT9MbJP39IpJJNEEQeopk710Mwc4ZqKh1MEpTcTnWzf0O2uSKd2rZG Wm9g== 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=Cz8XpkPOdA2WQMQ3HZuTliXREPjA7/5mOjW7Wh5oezE=; b=KTUcoKKven0k9eE0yDnZRCdN44r6aNpdASHG0Si1wP1YAnjBgx2RYElyl3dbXFfL1e f361L9PMUxY5e1a+Mojpd71UqbGJeOgMH9OVSkivBrmH9ivzKbkAzu8+xOqIsxXEr0n0 IUYhLSHrRnLHBV3wy2QlFodAg/essb+3P1QiR40CUgN3FL+colIe43KB+aDXXproK7FB ro4kr6/5wKGNW0L1/kveR/zVwOdRLp58i8012XvFfbWVGI2SrDO7fb8HgQusFTdBn4P2 LJwhMljt6ehtNE9UlYtaebb4BOuVKgNhPi+RPRqPRHRjMfJnnMHWiL/NM85iLv6vBDxD dzrg== X-Gm-Message-State: AOAM533VDTzp8EN4mlIZTSrwD023vMUJJNWD8/fMtrbM2/oXZ/mWkGxV R/k8+V/+v8h4C1nNWI2/MhPYWCigzuMlcg== X-Google-Smtp-Source: ABdhPJyN8P252CxKGH8873bDqMSfjN8KKQHanb77y6YKZwYBOkxGQ+CH3+DOEwUN6gsfh0amAji0Lg== X-Received: by 2002:a05:622a:1389:: with SMTP id o9mr5999021qtk.192.1644178067356; Sun, 06 Feb 2022 12:07: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 j11sm4625999qtj.74.2022.02.06.12.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 12:07:46 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v4 08/11] 9p: darwin: Compatibility for f/l*xattr Date: Sun, 6 Feb 2022 15:07:16 -0500 Message-Id: <20220206200719.74464-9-wwcohen@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220206200719.74464-1-wwcohen@gmail.com> References: <20220206200719.74464-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::829 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=wwcohen@gmail.com; helo=mail-qt1-x829.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, 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 , 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 7137a28109..ea3ded5fca 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 3b9c485414..8e610ad224 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 6 20:07: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: 12736695 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 5B973C433EF for ; Sun, 6 Feb 2022 20:09:42 +0000 (UTC) Received: from localhost ([::1]:59336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGnqv-0003oj-Es for qemu-devel@archiver.kernel.org; Sun, 06 Feb 2022 15:09:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGnp9-00011F-Lx for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:51 -0500 Received: from [2607:f8b0:4864:20::f32] (port=37679 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 1nGnp7-0001RG-VK for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:51 -0500 Received: by mail-qv1-xf32.google.com with SMTP id a19so3179395qvm.4 for ; Sun, 06 Feb 2022 12:07: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=N8lMcBD/VnfwG9BkRPxYEUbTKuDoWhdtD4gEpoOssSE=; b=e6GvmrAsyuzuF0pvaJNE++qqAmSahj0pte0kM3hq/AlvkbrYrQzcMv6HLopeiTnWWF O2j+fRjU/km6BwyxZTYBcOCxxz3cP/400RMJeSf8+Ocqz3hu53OzfpNVvb2rMITCjBpp E4/fw7RPSzJfU4XWbDnbIEj6gE1wsFlEjCH8281mHsHcRrVXuvbsNAVO8+4jnj27iMSJ BF1tFCjewbN683+eVYLGkqBPMgBXGuzPBdSlCXPQryQ7aOnhNK0QdwBMwJHBYqa11MQU wRGgXOFg142LlgVjD52Z/RpVwyiP6rOdGEhPUkxmXdadu+pUUOU5VLUMM5Phn5IdEwBx RHTQ== 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=N8lMcBD/VnfwG9BkRPxYEUbTKuDoWhdtD4gEpoOssSE=; b=Ete3JeMPLH5rblV8dAgmPsmATotAHovlpQN2h5mOsbgkU9ZMolw19BTECiRYNo4mhE i/w2AsdWGtDha6JN5BPyvj9xlxXSsk98gWJW43FI8lt1c76CcuAiclqwhLpK/nEavlLu jiLGeku6Z4eOiQUtHvWgl3yZEJTKGCNi2dTWsym7VRDkRfg0Ns0OC+uw2x+BLNpCO56w REH7epiO/2LwXimNmIN9jZPCJ86KGHuW9e6d00wWomr8dBtCTaBCZgb6NE+y40BkpQ1i QFHAxon9j7GS0cNV5/LQHY7QVR3LirL/9ULcBfDAuCfYv93+63ohKPvBNikLrjEAYGIe aOqQ== X-Gm-Message-State: AOAM533Q6fH+lxXsMcB9JjSlzzjZsLI4+blKzwgskev7um/Dre9fjhPL xRe6rk+qnrfmkRTzI0M+I9LBMq9ZorNJ7g== X-Google-Smtp-Source: ABdhPJzKyHXJVmD/cSAV4Fx5Y/6+02u/Wnj3e/Vbz9y0EDzGDyWFKpTRBdc8/viACcMFDph6R6R4+g== X-Received: by 2002:ad4:5ca4:: with SMTP id q4mr8516147qvh.64.1644178068775; Sun, 06 Feb 2022 12:07:48 -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 j11sm4625999qtj.74.2022.02.06.12.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 12:07:48 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v4 09/11] 9p: darwin: Implement compatibility for mknodat Date: Sun, 6 Feb 2022 15:07:17 -0500 Message-Id: <20220206200719.74464-10-wwcohen@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220206200719.74464-1-wwcohen@gmail.com> References: <20220206200719.74464-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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, 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 , 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 tihs 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] Signed-off-by: Will Cohen Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- hw/9pfs/9p-local.c | 5 +++-- hw/9pfs/9p-util-darwin.c | 27 +++++++++++++++++++++++++++ hw/9pfs/9p-util-linux.c | 5 +++++ hw/9pfs/9p-util.h | 2 ++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index ea3ded5fca..0569a8b4de 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; } @@ -710,6 +710,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, err_end: unlinkat_preserve_errno(dirfd, name, 0); + out: close_preserve_errno(dirfd); return err; diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index cdb4c9e24c..128b6d87e8 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -5,6 +5,7 @@ * See the COPYING file in the top-level directory. */ +#include #include "qemu/osdep.h" #include "qemu/xattr.h" #include "9p-util.h" @@ -62,3 +63,29 @@ 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) + */ + +int pthread_fchdir_np(int fd) API_AVAILABLE(macosx(10.12)); + +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + int preserved_errno, err; + 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; +} diff --git a/hw/9pfs/9p-util-linux.c b/hw/9pfs/9p-util-linux.c index 398614a5d0..66e0ab1865 100644 --- a/hw/9pfs/9p-util-linux.c +++ b/hw/9pfs/9p-util-linux.c @@ -62,3 +62,8 @@ int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, 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 8e610ad224..f6fed963bf 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -97,6 +97,8 @@ ssize_t flistxattrat_nofollow(int dirfd, const char *filename, ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, const char *name); +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev); + #endif From patchwork Sun Feb 6 20:07: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: 12736699 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 2AAF1C433F5 for ; Sun, 6 Feb 2022 20:13:15 +0000 (UTC) Received: from localhost ([::1]:39716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGnuL-0001BI-9J for qemu-devel@archiver.kernel.org; Sun, 06 Feb 2022 15:13:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGnpC-00013R-ED for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:55 -0500 Received: from [2607:f8b0:4864:20::730] (port=34661 helo=mail-qk1-x730.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGnpA-0001Rg-KQ for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:54 -0500 Received: by mail-qk1-x730.google.com with SMTP id bs32so9456426qkb.1 for ; Sun, 06 Feb 2022 12:07: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=8AYPOR8HAOhr1GFHfcmIMGeLF8f5x6f9nduyWsx8q3E=; b=HKnfEzlu0FKuwX2Zx3f+O5sswQl28M7Rx2D7NDiSgbrhaV9N8eYPmg3lw78aJphDjM yF7fv0nM3B7Q7azjtcHXWw1MMbw3vab9aZMRGMf7gRWgmh1uqgIzAdYqBSKhxBM3zkVA ga2Yvxvk7vPqqUFRvg7uw/WVoh1Fx49I1Yk2DknkNDL8m8a3U+BPx1B7Fb8vgdC5NStG HT09g5HuwCY8wknFCeh4LMFAbkMwUl1ejiUG+fBnD5xr/ZI62dcHpBocMpDGbhaJBNb3 b66ZrcwLA9H8b+uWQVituzOa0nUb282nTMyb9ZdV56QxD85qrGeIWFbfz5RQux3zdKTP fPEQ== 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=8AYPOR8HAOhr1GFHfcmIMGeLF8f5x6f9nduyWsx8q3E=; b=t40VXUGdThRJgkYdwgsY7htp0v4cvjRkNqGqQJSZ/YLSL9H4iJUnjg+euXNTd5MiFK tJ4wu1kz8uxWHqr4KIrqrA2KsSadOyoxiABaFJ6KcHi5PsA3pi+5jl60Uvza3YIc+AXi c6XP29OFPW+PzmUc82aN1eDGHVSITmX7zZuN4Aq1156aEJWslkppcakdgoobz1SYw/Jf 0uhuTjrTuE0B5mxL5pSRNf+o6BXhVGXXfEwETJHTPbcjKlX2eoQYX4cneYu+WPF+KN4h T+O7D+t9RGqJgRxqYbSGsBdnmgH+UasRAssyj0d+/WEnJn4/W2XlscyTMAnY65nZTD0M X7zg== X-Gm-Message-State: AOAM533dolZomXCYFnSIbtGijW9th/wkJlLBIogF/bm5aX+y9fvjdD3t KFF+0kPXtmiKi6U1f8yWTUk7blEuK2CuJg== X-Google-Smtp-Source: ABdhPJwzURNLff58grYFFbTrLEU6CCSXegroz8/sltONYnTSIX9XgC4DWWXRV7w1+czH2t2NuQFNIw== X-Received: by 2002:a05:620a:4108:: with SMTP id j8mr4944051qko.131.1644178071383; Sun, 06 Feb 2022 12:07: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 j11sm4625999qtj.74.2022.02.06.12.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 12:07:50 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v4 10/11] 9p: darwin: meson: Allow VirtFS on Darwin Date: Sun, 6 Feb 2022 15:07:18 -0500 Message-Id: <20220206200719.74464-11-wwcohen@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220206200719.74464-1-wwcohen@gmail.com> References: <20220206200719.74464-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::730 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::730; envelope-from=wwcohen@gmail.com; helo=mail-qk1-x730.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, 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 , 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 [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] 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 5f43355071..6b4adf7e15 100644 --- a/meson.build +++ b/meson.build @@ -1421,17 +1421,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 == 'linux' 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 Darwin') + elif targetos == 'darwin' and not cc.has_function('pthread_fchdir_np') + error('virtio-9p (virtfs) on Darwin 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 From patchwork Sun Feb 6 20:07: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: 12736703 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 3FF11C433F5 for ; Sun, 6 Feb 2022 20:22:42 +0000 (UTC) Received: from localhost ([::1]:53110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGo3V-0002MP-33 for qemu-devel@archiver.kernel.org; Sun, 06 Feb 2022 15:22:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGnpE-000145-1L for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:56 -0500 Received: from [2607:f8b0:4864:20::f33] (port=36493 helo=mail-qv1-xf33.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGnpB-0001Rv-V9 for qemu-devel@nongnu.org; Sun, 06 Feb 2022 15:07:55 -0500 Received: by mail-qv1-xf33.google.com with SMTP id o5so2319403qvm.3 for ; Sun, 06 Feb 2022 12:07:53 -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=MGq4/Ht9AqWuy11QNx35IG6GRlK0CwA5Kr6JW4BVDuM=; b=pGZIvIuYnyhFp+ENY5UYk7sInlSvrNcK14XUybAmaVf7eBbLVyDAyVgkE5pGwYn4CR emuPmtJpM9xN6w6Zat2gZPmJ5nipq/QdGUlUJUZmQeGEGi7RmjLTeV4GrjK5Ckec+GiB LCUu/8laq3KWdUTz6sJ9Ip8ImJA9EX+SGjIs8R4CIgToOkJbE67mJ56kiOgmHYVgu02w 6H/4/4nucOr7T1+rS3A62jBzRtCgqwkJuafH36vJ0GhFi9JQ680INw1gl+EUd4KqKupJ HMiPcNSE4wXDnD4I+AaSoKcPyeJCxisTqaxUn5CQKKc5wj7QmGKQauddB58AlHgpHnPV Uj8Q== 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=MGq4/Ht9AqWuy11QNx35IG6GRlK0CwA5Kr6JW4BVDuM=; b=lF2EmyWFHRsiT3YXhR7R+CVLW710fG4N1eMEFwLQbb88EOiaWCQslKyN+s2XlMp4+t lRkgtd9AB+97SxtS7HN1q5ry8Ke2fuxWabCUQ3y5mE+bpJK9gZJmQwj2daIHIlyFgrUH oEjqtovI5uhkXsj4SamNO/zw4rZHHfsClbW/IqSelfn43cqBcCh3YlJy0LJPbRk2ljLI d1qo4aXj6pG2QPimXIzyIkZihapi1PihNDVI5jPufeA9LiMMSQFnUmIvMiGf8y18QM60 kyBps8wKL0VKTcePFwK/wRdGKux7wWdDfoGjBaJgvHeGwT6kvPk9oN2bspKRHCRnce0B p22Q== X-Gm-Message-State: AOAM532Fb4Awmsc/b9HaGsHxW30ikf+PC1rtzbfOPWbqtcORoiO9g/lQ CcdS9kHdKR24bKNFOunrLcvMM+xwqV8bwA== X-Google-Smtp-Source: ABdhPJz7nhbIwheahbjfYkjZy81AaokqHx/i2qLit0c/2dO5tOfR5+72HtliPhrQnVZIGT8n0JppUQ== X-Received: by 2002:a05:6214:d6a:: with SMTP id 10mr8517925qvs.59.1644178072742; Sun, 06 Feb 2022 12:07:52 -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 j11sm4625999qtj.74.2022.02.06.12.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 12:07:52 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v4 11/11] 9p: darwin: Adjust assumption on virtio-9p-test Date: Sun, 6 Feb 2022 15:07:19 -0500 Message-Id: <20220206200719.74464-12-wwcohen@gmail.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220206200719.74464-1-wwcohen@gmail.com> References: <20220206200719.74464-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f33 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f33; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf33.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, 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 , 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 --- 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);