From patchwork Thu Feb 10 13:29:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 1591243 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=n0Tbbjp3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JvjF141J2z9s0r for ; Fri, 11 Feb 2022 03:41:25 +1100 (AEDT) Received: from localhost ([::1]:52352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nICVX-0004fJ-CF for incoming@patchwork.ozlabs.org; Thu, 10 Feb 2022 11:41:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI9WP-0002yp-2d for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:06 -0500 Received: from [2607:f8b0:4864:20::735] (port=33421 helo=mail-qk1-x735.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI9WM-0004D8-Uq for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:04 -0500 Received: by mail-qk1-x735.google.com with SMTP id o10so4810888qkg.0 for ; Thu, 10 Feb 2022 05:30:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q/a52Ymyen9MRJFePDxCcyYr+mACfmfhjAFtBkPNnik=; b=n0Tbbjp3QCq17AsTkdIDm+cRmhLu2VNP6zflEFdn1qSoDbz2ynvcLLQCv/fecBBwVS gpeQUwqDBa7xg7651XvXby1iHKXFVSfwI+RNP9N5/ygFE+sypdX6aFs3a4WkkVkSSnyz bRrA9veHUptC7d7ccHfKAG/evIMxtfNbtRWIa2dL/Y+KBzw7SlyXvsHOTvQOQ5co3Xc6 2DERJ/LLgxfvZXXGIbjQNgXaIDP/tYlar3DiwqUq0faNJTNnWGpcdJ2OTXzGF8qY9RtI AZ5LPm3hbp2BBhOfJONRkH2+YPJw0Jhd2DSlzLJZ3AO0C+xwYihqePcjBtxv70fAHMnc OMUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q/a52Ymyen9MRJFePDxCcyYr+mACfmfhjAFtBkPNnik=; b=RugwZNuk6s8q07wA5s9nPZ06GzjCxjrh2zN0JbwLHx55cJs+mYagLPzCYJ3Pi0pb70 5HTCyX9SOSdwZ0CqK8wXG1b/ajqxHD+x3n0JyOpc9g3s+eE1s0B9aN6NBKbIW6XAq2Hz hCau34Y+qVNjzFZ7IWvj2xVPsQxD6fHChGZy4Qcto1dkGveip2j+BGXw1lxizLvcUrqJ Cu3bQSsH0oYsbvRdXvPWyB0oUnNVnDZH1uI2m24cEl0bffJe3VfpnsDj8Sif/knJlVxB eQ3zLly8KFE6PRrnfcyCb6dOe7faTIHUiFf8xMmKhPqFgj5gviJH/vDN/V+S8UqyoDtx LQMQ== X-Gm-Message-State: AOAM530AOhFnJ+PMD2LMROoFZ3sOe9nUe+TRD5rQ1jkEn9b4fSKn3zkq uxp1pBQy2/prh+vkWlFH3pvCBqw9rw6GYQ== X-Google-Smtp-Source: ABdhPJx9eSrIIVhBLGstZYIueB0zymaNtfDG0+6Y9F1QvfGrp+ZtOc4i6uT2bWUWtl6XGmPTw3wCdg== X-Received: by 2002:a05:620a:170e:: with SMTP id az14mr3682526qkb.780.1644499801220; Thu, 10 Feb 2022 05:30:01 -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 t1sm11289616qtc.48.2022.02.10.05.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 05:30:00 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v6 01/11] 9p: linux: Fix a couple Linux assumptions Date: Thu, 10 Feb 2022 08:29:36 -0500 Message-Id: <20220210132946.2303-2-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220210132946.2303-1-wwcohen@gmail.com> References: <20220210132946.2303-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::735 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::735; envelope-from=wwcohen@gmail.com; helo=mail-qk1-x735.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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 Thu Feb 10 13:29:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 1591192 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=eSDOFOCy; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jvh2k52WBz9s5B for ; Fri, 11 Feb 2022 02:47:26 +1100 (AEDT) Received: from localhost ([::1]:53782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIBfI-00040G-4V for incoming@patchwork.ozlabs.org; Thu, 10 Feb 2022 10:47:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI9X6-00037H-1F for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:49 -0500 Received: from [2607:f8b0:4864:20::f35] (port=35537 helo=mail-qv1-xf35.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI9WO-0004F4-MH for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:16 -0500 Received: by mail-qv1-xf35.google.com with SMTP id d7so4935699qvk.2 for ; Thu, 10 Feb 2022 05:30:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aU38QXrWIFeszm233oTiu8pqJG9R/BMWH8IeCEGMGvc=; b=eSDOFOCyyXy7FiJ3eNpjbDHdRZN16NikpCNGjpvDYSh+6vnH5A/kT8B1Qs+re6C5Jp AIswkxIop5UPfT+t09LlwIlRstWH1EyGjZeMG0W+6og41HolDwYjTnp3Q9elwmiPV1/D q/09rQMngT6ybGPYqB45DIvoq7VS/VYemF00o5US379AUBI6rBrjcH++ExJ2orWFu7fs QlbT/pZq2Q+0Y8NVFnX96Fho8JKM4gDgrIb32fgLHwv52Jx/3he7SrlAjd/9wQNj3DL1 oxWyBE8yEubXOx1qLHUcUqUUfxpc5LsFyst+Y51HVobtlXaHzfnHgUfz3svVuGDxfJzI H/4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aU38QXrWIFeszm233oTiu8pqJG9R/BMWH8IeCEGMGvc=; b=v4gHFwpHchVUYwFacpI1KCt+HAX+sQXT7z5pnNCgQnOLYjDARd1R2S8P3kPKZuTceM zIHvPR16wm89gPvsc3v8hTY5a42QyoK3TlkJr8RjH7OMPVvLcADynK8aDnxpURytDyvL FKerIRNSXsIi+Q/qDfabCP4lz1PcME7iPgzUC0DtONHgcXR6NIQjR+/I8Y5C3G049XMA lSIC6PjDHlln4ZxyTtjhTBsXsfEw7cB4n4gSDuPbT+7zvcfGTmpTKPFu2H2qwe8GUJDJ hjfpbXQjdZx6DgRwHuoQACVp/T1rEXwxN9R4B+huWUf1bmcJMKlZG5vg1ElQSzM9dwr+ dQpw== X-Gm-Message-State: AOAM5304R0gf/naeDfQ3dfp0zcuMvTOo2mnR56NksHbJ37QwuP68dTGv RqiN8com0yrZ6E4tqI39q/r7tRFseuip0g== X-Google-Smtp-Source: ABdhPJyOGNckJFWEecdYjkb5Ng0cYbvVuL3l+pAW/gsK+N117zAikOLOMUyH4vdLBrA1pzTR7T5B7A== X-Received: by 2002:a0c:e7d0:: with SMTP id c16mr2957298qvo.49.1644499803029; Thu, 10 Feb 2022 05:30:03 -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 t1sm11289616qtc.48.2022.02.10.05.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 05:30:02 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v6 02/11] 9p: Rename 9p-util -> 9p-util-linux Date: Thu, 10 Feb 2022 08:29:37 -0500 Message-Id: <20220210132946.2303-3-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220210132946.2303-1-wwcohen@gmail.com> References: <20220210132946.2303-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f35 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f35; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf35.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, 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+incoming=patchwork.ozlabs.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 Thu Feb 10 13:29:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 1591256 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=TEAcCPdU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jvjnt26ZBz9s8q for ; Fri, 11 Feb 2022 04:06:25 +1100 (AEDT) Received: from localhost ([::1]:56462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nICth-0002Go-O4 for incoming@patchwork.ozlabs.org; Thu, 10 Feb 2022 12:06:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI9WV-00031Z-DQ for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:12 -0500 Received: from [2607:f8b0:4864:20::f34] (port=40922 helo=mail-qv1-xf34.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI9WP-0004FO-UD for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:11 -0500 Received: by mail-qv1-xf34.google.com with SMTP id v10so4918220qvk.7 for ; Thu, 10 Feb 2022 05:30:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s9PuenkLpugsLgi/PBoKGw80paVQIWqbF1SUukEIRZI=; b=TEAcCPdUUkMF1SIiLY7K+8DwjGXxfZW7Vc55hrdOgOeECW3PzPqso6ZjrS9UBuszd6 uBBiR6uFKCXWkg9vmy1O0dL1xM3v4tXqIsJkiNa/TusEB8RDy2Uy61ZMQq2r0fYiIJn8 bOCZCBmlVtq16NY1Ruv1MhWDsDtIIJt47jCii5y8e7TANxcXdosbfLl8lh4m4dGy8Joi ud7ORMmxQTPacnrMzSLZb3nX/SAru07Tj6Hs6OAiNUELyWjUyk23xFkroXIiaPtm7Ezs iBGcXZjJA0QcW/8RcE6mB3amBwC9cZEAHzPumMRFJK3JpV4XxqJMjmrVzBkBy/+fJVVf Q4CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s9PuenkLpugsLgi/PBoKGw80paVQIWqbF1SUukEIRZI=; b=LLBOnKnHRnjPkA5GcZNJI12iRk73wlEKqYL4THjYSaz7T75zT6+fbz4g4ZmEnW6l1i zsfrfM+sQkD1uO2pcKatbsSROTKT7QVzITN+AyMT5vHGkeD/av6XkH5uUcF4mb9DNRNV ZKUTTkiCxYDuHdzgG0AyJOq2HR2dXTJqMrAapGtyANjc1CbCZQZyVdrWwxp+6ljLVJGI aAg+iuL6T3M1eeSufFCnnwa3JjdU7VNRiPSabiAqOQGy4m69IJHmZpj4sQULu8vSo64a bO/PQ1p71A7xTBEn/R6laARICppNgdiBGCRMv63QYG533ZMaXkVdHAxcTffYOLD9+mrF Mwww== X-Gm-Message-State: AOAM531vJuIbxH5Ynbkk1CdBXADuXI0gnuoIzqjAKYHe68LuwqVDR83b ZFPf61zN/63QsElek9VC8FqgwHqOIlxRUg== X-Google-Smtp-Source: ABdhPJxa2ujih2fBRQ12L5M6AUP8+uYsKYDTH3r8qksS60zqiMpyJD2xb3vFo6CYst8oq+Ze6wJyxg== X-Received: by 2002:a05:6214:c2f:: with SMTP id a15mr4752946qvd.0.1644499804758; Thu, 10 Feb 2022 05:30:04 -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 t1sm11289616qtc.48.2022.02.10.05.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 05:30:03 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v6 03/11] 9p: darwin: Handle struct stat(fs) differences Date: Thu, 10 Feb 2022 08:29:38 -0500 Message-Id: <20220210132946.2303-4-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220210132946.2303-1-wwcohen@gmail.com> References: <20220210132946.2303-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f34 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f34; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf34.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_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=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+incoming=patchwork.ozlabs.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 Thu Feb 10 13:29:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 1591245 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=DsMkQ4rb; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JvjJt4wfYz9s0r for ; Fri, 11 Feb 2022 03:44:46 +1100 (AEDT) Received: from localhost ([::1]:33028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nICYm-0002Eh-3L for incoming@patchwork.ozlabs.org; Thu, 10 Feb 2022 11:44:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI9WW-000328-PV for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:12 -0500 Received: from [2607:f8b0:4864:20::72a] (port=45772 helo=mail-qk1-x72a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI9WT-0004G0-3t for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:12 -0500 Received: by mail-qk1-x72a.google.com with SMTP id b22so4732198qkk.12 for ; Thu, 10 Feb 2022 05:30:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=usoXj/aS1VhYctCFHSsTirdJcm/7xjAPuTTAm7+v4eQ=; b=DsMkQ4rbrqdtWewZyUEhE/4IdM+NMO39Tnl3yAcNxuV0bb9++n2iUX1ubVMzsppbuE XhYGuaWoxFlYbeYjO27yiST3t86i2mtkdYzqnM52JKEpNcxwnNnCnSIMqnfARec7Eyaq CZWRB4ofcEGOmfdQVnQmJgBtLBXxR+kWcvoGqzGDkkrM9+mn1HlDvEl+H5R5BkOqtBB/ gmL4Ir/M7Tk5Kvk+x918v7Va0afunxpbza3frv4oHuZS3DZNHDXH/ilpm6sZ5PeoMn3o D2JHkk90htY8gutc68oqU856ij44HxJWB+MeFhryLA7XQDCh3KiEaI3nFBGioJMjlwOj xcoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=usoXj/aS1VhYctCFHSsTirdJcm/7xjAPuTTAm7+v4eQ=; b=5rhpBTevZuhBPUeA+sncQzjQ4t0Hf8LKUms6nkgLEvi57WvLYdbyCAtqjFcwx7c7xG Tg+CRW4tFWxgTUHXPxMx06rr+S4p3Ekz3/n7/I28N/QyMD+YOUOsl/XAdwR+8G4LXM2G q4GNv5YSomXO1fK6RECwm+g3wpBKMM6imzD7ORCatAsXx+jW3LrhNi2eA1QIKXj3v2Z1 tMULbmhWdf2FSXmizuL9+hG1YvUnLN5vk5zjfPDDQifCT4gp31a87nMx+545NHu/sIaw IeELy7pAAplZDb+SgjKSZmhNAXuySwwvhVTPEsiz9GB7hD5rHQXMH9El9iyJEQY2nTx6 o0KQ== X-Gm-Message-State: AOAM533iUtnUovq08r7B32Pt8/XTRctxzywKutOByjqz/4hntXIHluvs evH+SLQP9AnBRIW7fVeXZgEkabTX5Wbxww== X-Google-Smtp-Source: ABdhPJzeDf/+YYxZOkh0wUoN9OELDmMeRmnMsiAVTOSgDdxpnEdql9CvEVhIvZMd5+ujwq5bnnx5Cg== X-Received: by 2002:a05:620a:74e:: with SMTP id i14mr3708166qki.674.1644499806083; Thu, 10 Feb 2022 05:30:06 -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 t1sm11289616qtc.48.2022.02.10.05.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 05:30:05 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v6 04/11] 9p: darwin: Handle struct dirent differences Date: Thu, 10 Feb 2022 08:29:39 -0500 Message-Id: <20220210132946.2303-5-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220210132946.2303-1-wwcohen@gmail.com> References: <20220210132946.2303-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::72a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=wwcohen@gmail.com; helo=mail-qk1-x72a.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer On darwin d_seekoff exists, but is optional and does not seem to be commonly used by file systems. Use `telldir` instead to obtain the seek offset and inject it into d_seekoff, and create a qemu_dirent_off helper to call it appropriately when appropriate. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Adjust to pass testing - Ensure that d_seekoff is filled using telldir on darwin, and create qemu_dirent_off helper to decide which to access] [Fabian Franz: - Add telldir error handling for darwin] Signed-off-by: Fabian Franz [Will Cohen: - Ensure that telldir error handling uses signed int - Cleanup of telldir error handling - Remove superfluous error handling for qemu_dirent_off - Adjust formatting - Use qemu_dirent_off in codir.c] Signed-off-by: Will Cohen --- hw/9pfs/9p-local.c | 9 +++++++++ hw/9pfs/9p-proxy.c | 16 +++++++++++++++- hw/9pfs/9p-synth.c | 4 ++++ hw/9pfs/9p-util.h | 16 ++++++++++++++++ hw/9pfs/9p.c | 7 +++++-- hw/9pfs/codir.c | 4 +++- 6 files changed, 52 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 1a5e3eed73..f3272f0b43 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -562,6 +562,15 @@ again: if (!entry) { return NULL; } +#ifdef CONFIG_DARWIN + int off; + off = telldir(fs->dir.stream); + /* If telldir fails, fail the entire readdir call */ + if (off < 0) { + return NULL; + } + entry->d_seekoff = off; +#endif if (ctx->export_flags & V9FS_SM_MAPPED) { entry->d_type = DT_UNKNOWN; diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index b1664080d8..8b4b5cf7dc 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -706,7 +706,21 @@ static off_t proxy_telldir(FsContext *ctx, V9fsFidOpenState *fs) static struct dirent *proxy_readdir(FsContext *ctx, V9fsFidOpenState *fs) { - return readdir(fs->dir.stream); + struct dirent *entry; + entry = readdir(fs->dir.stream); +#ifdef CONFIG_DARWIN + if (!entry) { + return NULL; + } + int td; + td = telldir(fs->dir.stream); + /* If telldir fails, fail the entire readdir call */ + if (td < 0) { + return NULL; + } + entry->d_seekoff = td; +#endif + return entry; } static void proxy_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index 4a4a776d06..e264a03eef 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -222,7 +222,11 @@ static void synth_direntry(V9fsSynthNode *node, { strcpy(entry->d_name, node->name); entry->d_ino = node->attr->inode; +#ifdef CONFIG_DARWIN + entry->d_seekoff = off + 1; +#else entry->d_off = off + 1; +#endif } static struct dirent *synth_get_dentry(V9fsSynthNode *dir, diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 546f46dc7d..d41f37f085 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -79,3 +79,19 @@ ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, const char *name); #endif + + +/** + * Darwin has d_seekoff, which appears to function similarly to d_off. + * However, it does not appear to be supported on all file systems, + * so ensure it is manually injected earlier and call here when + * needed. + */ +inline off_t qemu_dirent_off(struct dirent *dent) +{ +#ifdef CONFIG_DARWIN + return dent->d_seekoff; +#else + return dent->d_off; +#endif +} diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 1563d7b7c6..caf3b240fe 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -27,6 +27,7 @@ #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" #include "9p-xattr.h" +#include "9p-util.h" #include "coth.h" #include "trace.h" #include "migration/blocker.h" @@ -2281,7 +2282,7 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu, count += len; v9fs_stat_free(&v9stat); v9fs_path_free(&path); - saved_dir_pos = dent->d_off; + saved_dir_pos = qemu_dirent_off(dent); } v9fs_readdir_unlock(&fidp->fs.dir); @@ -2420,6 +2421,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString name; int len, err = 0; int32_t count = 0; + off_t off; struct dirent *dent; struct stat *st; struct V9fsDirEnt *entries = NULL; @@ -2480,12 +2482,13 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, qid.version = 0; } + off = qemu_dirent_off(dent); v9fs_string_init(&name); v9fs_string_sprintf(&name, "%s", dent->d_name); /* 11 = 7 + 4 (7 = start offset, 4 = space for storing count) */ len = pdu_marshal(pdu, 11 + count, "Qqbs", - &qid, dent->d_off, + &qid, off, dent->d_type, &name); v9fs_string_free(&name); diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c index 032cce04c4..8e66205d9d 100644 --- a/hw/9pfs/codir.c +++ b/hw/9pfs/codir.c @@ -22,6 +22,8 @@ #include "qemu/coroutine.h" #include "qemu/main-loop.h" #include "coth.h" +#include "9p-xattr.h" +#include "9p-util.h" /* * Intended to be called from bottom-half (e.g. background I/O thread) @@ -167,7 +169,7 @@ static int do_readdir_many(V9fsPDU *pdu, V9fsFidState *fidp, } size += len; - saved_dir_pos = dent->d_off; + saved_dir_pos = qemu_dirent_off(dent); } /* restore (last) saved position */ From patchwork Thu Feb 10 13:29:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 1591253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=cSKrX0oi; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jvjhb2JJcz9s8q for ; Fri, 11 Feb 2022 04:01:51 +1100 (AEDT) Received: from localhost ([::1]:51342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nICpH-0006hF-Va for incoming@patchwork.ozlabs.org; Thu, 10 Feb 2022 12:01:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI9WY-00033X-9W for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:14 -0500 Received: from [2607:f8b0:4864:20::f35] (port=44806 helo=mail-qv1-xf35.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI9WT-0004GQ-0q for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:13 -0500 Received: by mail-qv1-xf35.google.com with SMTP id p7so4900870qvk.11 for ; Thu, 10 Feb 2022 05:30:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gIGVlFzwI+BOQT0G5tpy36kLec/z/FbtOyvz6GVCXtw=; b=cSKrX0oi9dpo5zP6HmrPMJxd79HcXSkLyDOdXzE8Rn+50TbYgtZVBH7hzkcQgE2nBv hJNSYrq7ArJ6WirNtdTqJ1m8s1xgYaAD5aIoYr/hzy29/B6LKwjH6XkO8beDDc0sf/Hh KIhfzbbPfJPFpgD92fBC2PNgRNNiWn/CNEbgHPhnFvDonEcRkuPESHCtnKSMXew3KDGj jRHv/Cm9AriZzT+nyJMvIkpsi8qkBtXiLixd0mLUIs0+3LAqI4UC1d9L/au1+uOc5o3S 3GRjBkKW/VyLjzGJzuXA6tDA5/3TT21DddLTqZ/A7shyfGol4s5Yzi7v8S8JeT7q0Zcx eoCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gIGVlFzwI+BOQT0G5tpy36kLec/z/FbtOyvz6GVCXtw=; b=JxSWsm769LS/1Zd7LeUX5lMWPVLKPIwnqQwATfewim1ncg0Vh+rOQgCwPKw9phgV5o N/4D/Ot8nkKGynO45FzGLDuRNtS3x4Poi3DrJ6wvCxI83kM9CmR1zif/ynw0VIRrcKwl jJz5X0nsAxhXws6A5vwO2tRAM+etyqVBSieHVyE7YzxVRjFWuT7/e+KGZexnpGzsOAiT W79W1IE0UOGowJ4l75oHZsZq/Uyg4/AhEhl8L9zBCjpyT5Kgr9xHnumtJcCw+Ag6+TTM xT1PPmATXPY84suxGsrSZ+tY+YlumDTAdFVtBl6wboiF484CX+ceBUbHX/Lq1Q6m/MzF dF5w== X-Gm-Message-State: AOAM5332XXlPDjUVx4HSQNXCaKWpREcoJq2Cz8LKSzScAUuNB9d1InPm SALQszTMoFmXOpbScd8zai1EEfrlbreK9Q== X-Google-Smtp-Source: ABdhPJxkR6gU1tllXpr4V/nwilwujn7nL6yvL4QpDaHDUuKBBnDIOxO6OCpqSn2UkMMxtJ2tvKZC5w== X-Received: by 2002:a05:6214:d82:: with SMTP id e2mr5056570qve.128.1644499807721; Thu, 10 Feb 2022 05:30:07 -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 t1sm11289616qtc.48.2022.02.10.05.30.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 05:30:07 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v6 05/11] 9p: darwin: Ignore O_{NOATIME, DIRECT} Date: Thu, 10 Feb 2022 08:29:40 -0500 Message-Id: <20220210132946.2303-6-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220210132946.2303-1-wwcohen@gmail.com> References: <20220210132946.2303-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f35 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f35; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf35.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Darwin doesn't have either of these flags. Darwin does have F_NOCACHE, which is similar to O_DIRECT, but has different enough semantics that other projects don't generally map them automatically. In any case, we don't support O_DIRECT on Linux at the moment either. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Adjust coding style] Signed-off-by: Will Cohen --- hw/9pfs/9p-util.h | 2 ++ hw/9pfs/9p.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index d41f37f085..0e445b5d52 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -41,6 +41,7 @@ again: fd = openat(dirfd, name, flags | O_NOFOLLOW | O_NOCTTY | O_NONBLOCK, mode); if (fd == -1) { +#ifndef CONFIG_DARWIN if (errno == EPERM && (flags & O_NOATIME)) { /* * The client passed O_NOATIME but we lack permissions to honor it. @@ -53,6 +54,7 @@ again: flags &= ~O_NOATIME; goto again; } +#endif return -1; } diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index caf3b240fe..14e84c3bcf 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -138,11 +138,20 @@ static int dotl_to_open_flags(int flags) { P9_DOTL_NONBLOCK, O_NONBLOCK } , { P9_DOTL_DSYNC, O_DSYNC }, { P9_DOTL_FASYNC, FASYNC }, +#ifndef CONFIG_DARWIN + { P9_DOTL_NOATIME, O_NOATIME }, + /* + * On Darwin, we could map to F_NOCACHE, which is + * similar, but doesn't quite have the same + * semantics. However, we don't support O_DIRECT + * even on linux at the moment, so we just ignore + * it here. + */ { P9_DOTL_DIRECT, O_DIRECT }, +#endif { P9_DOTL_LARGEFILE, O_LARGEFILE }, { P9_DOTL_DIRECTORY, O_DIRECTORY }, { P9_DOTL_NOFOLLOW, O_NOFOLLOW }, - { P9_DOTL_NOATIME, O_NOATIME }, { P9_DOTL_SYNC, O_SYNC }, }; @@ -171,10 +180,12 @@ static int get_dotl_openflags(V9fsState *s, int oflags) */ flags = dotl_to_open_flags(oflags); flags &= ~(O_NOCTTY | O_ASYNC | O_CREAT); +#ifndef CONFIG_DARWIN /* * Ignore direct disk access hint until the server supports it. */ flags &= ~O_DIRECT; +#endif return flags; } From patchwork Thu Feb 10 13:29:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 1591248 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=A6ak7nLj; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JvjSV5mvHz9s0r for ; Fri, 11 Feb 2022 03:51:22 +1100 (AEDT) Received: from localhost ([::1]:42066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nICf9-0008QK-TC for incoming@patchwork.ozlabs.org; Thu, 10 Feb 2022 11:51:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI9WY-00033F-4k for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:14 -0500 Received: from [2607:f8b0:4864:20::f2f] (port=35532 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 1nI9WU-0004Gv-Jm for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:13 -0500 Received: by mail-qv1-xf2f.google.com with SMTP id d7so4936007qvk.2 for ; Thu, 10 Feb 2022 05:30:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=42w8zH8fh4oqZPs0bvaBNjORXWqdsJUdc9cHlnfnog0=; b=A6ak7nLjQX2lOR5SicpzXxn34TwZBwsBTLUNmkP/uOn48q4PuZLXoTTwXz8VrZ5b5X yt8q0ZgMOhMQvfbl9ZiqlQk4mkD2MGiJY8JtFTaLaHQhKL+25Wljz1u6Jh2ReRuBP3v4 eCk26fD/yO1KtU7POkdRY7BSUmg2ReqOoIsFFfORexG6x/9+Gs2qRwVCZ3POPHJ36DRX wz0oRmU8Yj9JmweJilXzq7ICB5W/yoR9X5F7hiERBIjXGnyJH4GN5hW+FZ8LLOCC+lRV cMpv9jFKQe1o/3DNlMLcydODPYWLLhYQNLGYcQjrhoufYQmBUSlEmPd8S/3iiRc6JetH /FOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=42w8zH8fh4oqZPs0bvaBNjORXWqdsJUdc9cHlnfnog0=; b=gxX22W38H0H8FEHCJf9OzWknQwUs430wztKhoD0rLanmRfziNHSNF6xFonN/tamu63 kKd7fOPKv6R6eM25wsU4/27H2421vxgtFjI58rGjRUDKw4HSo/iKgH8pPk8KgdAEZAgf fttXPwHBsx5gIw81ku1CRaac+ToPlzmMwoCU8OoIpQRi2+lwsO2VO6hHYcCbJCy4smHA utiIfxb8N29jKyLmm4X/0b+xsYdRoRoh2C96RN0sGf6e+cWRrW2g1+AUfwqEQ2+yGzJl x3EaOfgpj91KlO8Hcoq7jfxLbiGEt/NtVA6sGDbVu5Ph1ZZaJgUlMJOJnyAUP+eg93Ne 5/WQ== X-Gm-Message-State: AOAM531sStQrZrXXqGJc95NGVxcZNL0YGBiahLjNLHDMAFtidWbrZGnS BN71/stwS0h5zoEhB6QXqp7E+yweoEJvFw== X-Google-Smtp-Source: ABdhPJwXgsHgi64nDMei6VGkqq/4pTbFYFxDTfAtHK2xEWv5rxI5EHsTPWkMrqsny5dBW7eMEDhWcw== X-Received: by 2002:a05:6214:2428:: with SMTP id gy8mr5077755qvb.122.1644499809389; Thu, 10 Feb 2022 05:30:09 -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 t1sm11289616qtc.48.2022.02.10.05.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 05:30:08 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v6 06/11] 9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX Date: Thu, 10 Feb 2022 08:29:41 -0500 Message-Id: <20220210132946.2303-7-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220210132946.2303-1-wwcohen@gmail.com> References: <20220210132946.2303-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 , Fabian Franz , Christian Schoenebeck , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.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 Thu Feb 10 13:29:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 1591182 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=G4ANToTO; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JvgxX3gDPz9sCD for ; Fri, 11 Feb 2022 02:42:56 +1100 (AEDT) Received: from localhost ([::1]:46064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIBaw-0006GX-1w for incoming@patchwork.ozlabs.org; Thu, 10 Feb 2022 10:42:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI9WZ-00034V-5k for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:25 -0500 Received: from [2607:f8b0:4864:20::82a] (port=34646 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 1nI9WW-0004HH-5l for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:14 -0500 Received: by mail-qt1-x82a.google.com with SMTP id g4so4513809qto.1 for ; Thu, 10 Feb 2022 05:30:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=axA+qxXpY8sKbyRbqVq801h3dnGKdNQsigejBH57FZ8=; b=G4ANToTONn4/nY8Zv5ObXqrnE5+OsD/pYNzG+m39T46pV+OBoAhpEuUAMf4aXCR6kr uhzdMW/N9yNd//iz156MIF1U2VQHSlyJTJYTDrp97FpZhQTPi9WZcVL9OpstD0Z31bs9 1uxJphRdjTCW5tSfKT0gXhD34jDkQrZ35Xpd0Ug36dv1HvopAP+/n+8agGc9M2C1N0Nt zC8n2LQrC1hX4Yl3FbtmQWnCWfxr3LY8+i1uH9zFKenKO3eAkn2Xy6qlAcYYAnVoBJPG ZNwpuKWEZAHll94dj0zGpDUmOT3fRBecUTow6lX+2myzl1llw3vrAFKmgVdtfUW6M9X/ /vfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=axA+qxXpY8sKbyRbqVq801h3dnGKdNQsigejBH57FZ8=; b=tgMuFAYpZAVCfKimaD24Ebr6fZ3/dc9depeL+LaUZbMBmgoic54YbJC4CVoZOggLtk yiI1qrj2kpLsK6ZPM6yAO+QAl75K2fftCb9D9vMVfN0zR4XtTDX1xMlrs2qP+Pe89qM5 dhny1vkbOD1tUsYTY3n0c31tKDKcB48EPiFt87FbavpBEN6h4kUJMUz4GSX4u9eTzfkl jiCr+v7laZCUCykhBEk4OjtvrvRDOyzO3aBZju6xYoJTeclMA310dmZRf4ZoAibZ0njg wnQZr33Dvrq4E/UNxVzFa7Txg+LgB1i+N9GFnJ3TgHRyDTRpq2xRHopFw2gagJAec2GO +1Vg== X-Gm-Message-State: AOAM532ZVVgBJHwipFRLrJAcdyoxSig2hv7IBFkxSKSGtTPDbvBnZCbD TGt7QVsNbvTB/nYDkZnpRXtBngwgpzkbiA== X-Google-Smtp-Source: ABdhPJxA+hL98RJDam7c9UpoNgKkRks+8hKEvTXAPe1E1QzQV+4+Bf+DKIbfvAFHUuWYB7gBd5AEoQ== X-Received: by 2002:a05:622a:488:: with SMTP id p8mr4829409qtx.97.1644499811013; Thu, 10 Feb 2022 05:30:11 -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 t1sm11289616qtc.48.2022.02.10.05.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 05:30:10 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v6 07/11] 9p: darwin: *xattr_nofollow implementations Date: Thu, 10 Feb 2022 08:29:42 -0500 Message-Id: <20220210132946.2303-8-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220210132946.2303-1-wwcohen@gmail.com> References: <20220210132946.2303-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: -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+incoming=patchwork.ozlabs.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 Thu Feb 10 13:29:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 1591259 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=TCUQNjq3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jvjvc5MVQz9s8q for ; Fri, 11 Feb 2022 04:11:24 +1100 (AEDT) Received: from localhost ([::1]:37540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nICyX-0000Ou-By for incoming@patchwork.ozlabs.org; Thu, 10 Feb 2022 12:11:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI9X7-00037J-9e for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:49 -0500 Received: from [2607:f8b0:4864:20::832] (port=40922 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 1nI9WY-0004Hh-3N for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:31 -0500 Received: by mail-qt1-x832.google.com with SMTP id l14so5149158qtp.7 for ; Thu, 10 Feb 2022 05:30:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9kM+hfKaNHkhAKW7qPhMom4aNnY+CTog/UjBQslxta0=; b=TCUQNjq3dO9K10od5qe4zDnXKUqpz6nLo8tzTTQEZA8GM7lRssCY88jH2TgKl/pfL3 8wVVjV4JRTo+Ser32MnDHl9vINE3ugFJ5WD4RIKLE8BX1qynnbsMi7j/JftEPAmFB23J rt8qFaU4Fd93f3CqnIX4QPlNMXmF2AJIXInywStBluF2NVai+trjZL6Ta7yyev3gbLpC JKqIyi/d0hF+DvhorzMC6zd738HbesF/wBI0ONfYENQ1ww2lC0uvmcifF7ciA0lHAGUi 1EE74WXZQk3tLXIg9OMLEipVVGLs/6yViGAy3JKcljjdNO36vG3ihqGLxxdnOthyRaMp GrwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9kM+hfKaNHkhAKW7qPhMom4aNnY+CTog/UjBQslxta0=; b=PdwdaKj7686qy5Cj2VPK0hKONghZjtNzGn+XaOhcmdnQ6Xu5fXvMWH9dcBSjF89dk8 9OeFSdy7CF/MDC0jnuEDkVRBiQWBg7cDE9tla4g/FDxVzf67sZJrh2SMbxpK7ZXNyaP4 /rNRO2FKnaMSmIrEH3ThvNeFHZ7WacGy/jLKrANEHxN+h05UaPTyyne4qsdjLbEi9E41 FEXezrSB4znUbgi0t3PvRlJYxcBMpNOfAslyoxA6yN/xJgth4SELp/M3NkH8ZHNQLaZL LNB2tKB/ND2MU7zhkYby7vH5i/mYjAqSNmW1ppdlJqrHam2Ee9NQsY13wVUOUv9amCs7 z7Mw== X-Gm-Message-State: AOAM530rpxx+YUwM+B2spiXV83Vc+ggFygj9hHAlBj0cgoni+1wl3zel 5qhFcTC0JSTA9DkHLn3b7qYY3+ncXilP1Q== X-Google-Smtp-Source: ABdhPJwEkdVDkwVthA3QW+ZiJQtjI5fgoJAxY+jk/HrbVIdEey6HFKD699wK6dLXBq//qe6urpFG5g== X-Received: by 2002:ac8:5a8f:: with SMTP id c15mr4718954qtc.271.1644499812900; Thu, 10 Feb 2022 05:30:12 -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 t1sm11289616qtc.48.2022.02.10.05.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 05:30:12 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v6 08/11] 9p: darwin: Compatibility for f/l*xattr Date: Thu, 10 Feb 2022 08:29:43 -0500 Message-Id: <20220210132946.2303-9-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220210132946.2303-1-wwcohen@gmail.com> References: <20220210132946.2303-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: -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, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer On darwin `fgetxattr` takes two extra optional arguments, and the l* variants are not defined (in favor of an extra flag to the regular variants. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- hw/9pfs/9p-local.c | 12 ++++++++---- hw/9pfs/9p-util.h | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index f3272f0b43..a0d08e5216 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -790,16 +790,20 @@ static int local_fstat(FsContext *fs_ctx, int fid_type, mode_t tmp_mode; dev_t tmp_dev; - if (fgetxattr(fd, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) { + if (qemu_fgetxattr(fd, "user.virtfs.uid", + &tmp_uid, sizeof(uid_t)) > 0) { stbuf->st_uid = le32_to_cpu(tmp_uid); } - if (fgetxattr(fd, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) { + if (qemu_fgetxattr(fd, "user.virtfs.gid", + &tmp_gid, sizeof(gid_t)) > 0) { stbuf->st_gid = le32_to_cpu(tmp_gid); } - if (fgetxattr(fd, "user.virtfs.mode", &tmp_mode, sizeof(mode_t)) > 0) { + if (qemu_fgetxattr(fd, "user.virtfs.mode", + &tmp_mode, sizeof(mode_t)) > 0) { stbuf->st_mode = le32_to_cpu(tmp_mode); } - if (fgetxattr(fd, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) { + if (qemu_fgetxattr(fd, "user.virtfs.rdev", + &tmp_dev, sizeof(dev_t)) > 0) { stbuf->st_rdev = le64_to_cpu(tmp_dev); } } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 0e445b5d52..82399702b9 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -19,6 +19,23 @@ #define O_PATH_9P_UTIL 0 #endif +#ifdef CONFIG_DARWIN +#define qemu_fgetxattr(...) fgetxattr(__VA_ARGS__, 0, 0) +#define qemu_lgetxattr(...) getxattr(__VA_ARGS__, 0, XATTR_NOFOLLOW) +#define qemu_llistxattr(...) listxattr(__VA_ARGS__, XATTR_NOFOLLOW) +#define qemu_lremovexattr(...) removexattr(__VA_ARGS__, XATTR_NOFOLLOW) +static inline int qemu_lsetxattr(const char *path, const char *name, + const void *value, size_t size, int flags) { + return setxattr(path, name, value, size, 0, flags | XATTR_NOFOLLOW); +} +#else +#define qemu_fgetxattr fgetxattr +#define qemu_lgetxattr lgetxattr +#define qemu_llistxattr llistxattr +#define qemu_lremovexattr lremovexattr +#define qemu_lsetxattr lsetxattr +#endif + static inline void close_preserve_errno(int fd) { int serrno = errno; From patchwork Thu Feb 10 13:29:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 1591257 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YDG+FR0m; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jvjrn0Hzzz9s8q for ; Fri, 11 Feb 2022 04:08:56 +1100 (AEDT) Received: from localhost ([::1]:60762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nICw9-0005KZ-JI for incoming@patchwork.ozlabs.org; Thu, 10 Feb 2022 12:08:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI9XG-0003E7-2D for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:59 -0500 Received: from [2607:f8b0:4864:20::f2d] (port=35531 helo=mail-qv1-xf2d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI9X7-0004X9-O1 for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:51 -0500 Received: by mail-qv1-xf2d.google.com with SMTP id d7so4936633qvk.2 for ; Thu, 10 Feb 2022 05:30:22 -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=TzjbpO9p8KRoVB5z+ohlhfny2IOfDnlQXdIOA6h5zXA=; b=YDG+FR0m8RCvCfUTaV9Msj5LJBxKDvZNEgdTdHouCzbaKPjtZYiR+XFS/ZBWGwg0g9 YSYTvURpSLkVXaE1Jl3NbsM05fXWSkzFJLfyh2OdfKlwWeGRm0LdrGbkCWVEEZOgYZg+ dj8gaBVX/tJWvBbX5l6YDh/lH5SsJ2HBC0KGdB2teWmO8bcoykC3nmsww23HAylGRHGc r2iwOIyTzlTnbogVNwpjjRzzlUxGp25ZwtRPQmK93Lw7Jjc7Q+twxmRUjxzsPnwRlmek IT5w+GnhUKErA5CbgsAm36W6LOptl66kkRJTNZJI4295zY1e8A6PgpoQ8YjkALwkIk6Y nS6g== 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=TzjbpO9p8KRoVB5z+ohlhfny2IOfDnlQXdIOA6h5zXA=; b=s6sybpyH+HarKQO/cfLH6sNtx9qKAumDWI8eBHbUuKxEU/n2rsgpTc1P5oMotHRCjA Q0GmHm1Z6jxqFiATwapYYByHDqKJ5kgeLF8nus6qn0ixKDjA0aCngjniHaiP5l3pS1QW wax4Bc/xMF35dIu6s3juYX9BzEkLrDoWJlcfns2e0arRN0/uaxQh3alsYarzAjCH14yu 1WgwOJdhrHcsUaZDesMqdRMvpE+14WQ1pPRjnV3YSFAX2X/DhpSLq5yhtK2VJPKCiv58 AsCh30R5jFlwCS1gInWLkka3RylNEd3uzQ/HdCeJG6rmXU7QqVD/hClCwC/vIBANfN70 vCvw== X-Gm-Message-State: AOAM532XTO5nWhuGxYIGg6wzgbVze6I0cx4bHoQ2yjKNoGnyKsjDF7lg Bck3tRTqLA9LcLvumn0KSMg7bJncpG3mqw== X-Google-Smtp-Source: ABdhPJy5/e0UmscFhHwUxLOxNr7aaHPpf2ARtHQZaUsTY8qZwVcvxsmRXMJYS4esU3ZW4gAspSu56g== X-Received: by 2002:a05:6214:238a:: with SMTP id fw10mr4829662qvb.15.1644499821320; Thu, 10 Feb 2022 05:30:21 -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 t1sm11289616qtc.48.2022.02.10.05.30.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 05:30:20 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v6 09/11] 9p: darwin: Implement compatibility for mknodat Date: Thu, 10 Feb 2022 08:29:44 -0500 Message-Id: <20220210132946.2303-10-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220210132946.2303-1-wwcohen@gmail.com> References: <20220210132946.2303-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f2d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2d; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf2d.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Darwin does not support mknodat. However, to avoid race conditions with later setting the permissions, we must avoid using mknod on the full path instead. We could try to fchdir, but that would cause problems if multiple threads try to call mknodat at the same time. However, luckily there is a solution: Darwin includes a function that sets the cwd for the current thread only. This should suffice to use mknod safely. This function (pthread_fchdir_np) is protected by a check in meson in a patch later in this series. Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch [Will Cohen: - Adjust coding style - Replace clang references with gcc - Note radar filed with Apple for missing syscall - Replace direct syscall with pthread_fchdir_np and adjust patch notes accordingly - Move qemu_mknodat from 9p-util to osdep and os-posix - Move pthread_fchdir_np declaration only to osdep - Declare pthread_fchdir_np with - __attribute__((weak_import)) to allow checking for its presence before usage - Move declarations above cplusplus guard] Signed-off-by: Will Cohen --- hw/9pfs/9p-local.c | 4 ++-- include/qemu/osdep.h | 12 ++++++++++++ os-posix.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index a0d08e5216..d42ce6d8b8 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -682,7 +682,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { - err = mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); + err = qemu_mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); if (err == -1) { goto out; } @@ -697,7 +697,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, } } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { - err = mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); + err = qemu_mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); if (err == -1) { goto out; } diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index d1660d67fa..d8cc7240ed 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -805,6 +805,18 @@ static inline int platform_does_not_support_system(const char *command) } #endif /* !HAVE_SYSTEM_FUNCTION */ +/* + * As long as mknodat is not available on macOS, this workaround + * using pthread_fchdir_np is needed. qemu_mknodat is defined in + * os-posix.c. pthread_fchdir_np is weakly linked here as a guard + * in case it disappears in future macOS versions, because it is + * is a private API. + */ +#ifdef CONFIG_DARWIN +int pthread_fchdir_np(int fd) __attribute__((weak_import)); +#endif +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev); + #ifdef __cplusplus } #endif diff --git a/os-posix.c b/os-posix.c index ae6c9f2a5e..28a294b8b3 100644 --- a/os-posix.c +++ b/os-posix.c @@ -332,3 +332,38 @@ int os_mlock(void) return -ENOSYS; #endif } + +/* + * As long as mknodat is not available on macOS, this workaround + * using pthread_fchdir_np is needed. + * + * Radar filed with Apple for implementing mknodat: + * rdar://FB9862426 (https://openradar.appspot.com/FB9862426) + */ +#ifdef CONFIG_DARWIN + +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + int preserved_errno, err; + if (!pthread_fchdir_np) { + error_report_once("pthread_fchdir_np() is not available on this version of macOS"); + return -ENOTSUP; + } + if (pthread_fchdir_np(dirfd) < 0) { + return -1; + } + err = mknod(filename, mode, dev); + preserved_errno = errno; + /* Stop using the thread-local cwd */ + pthread_fchdir_np(-1); + if (err < 0) { + errno = preserved_errno; + } + return err; +} +#else +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + return mknodat(dirfd, filename, mode, dev); +} +#endif From patchwork Thu Feb 10 13:29:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 1591198 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=WkQJLMrf; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jvh7b13YLz9s5B for ; Fri, 11 Feb 2022 02:51:39 +1100 (AEDT) Received: from localhost ([::1]:33484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIBjM-0001WY-Sa for incoming@patchwork.ozlabs.org; Thu, 10 Feb 2022 10:51:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI9XD-0003Cd-Bl for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:57 -0500 Received: from [2607:f8b0:4864:20::f30] (port=35534 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 1nI9X7-0004YB-R2 for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:51 -0500 Received: by mail-qv1-xf30.google.com with SMTP id d7so4936714qvk.2 for ; Thu, 10 Feb 2022 05:30:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VI0Ghpcxq8/Yi1AQXKCEmSeO6fHHyV1SL/EjKkI3wfk=; b=WkQJLMrfayBlDBgEQv9EtI5AMt6wmWOrziKIbRBgW81j/6HZ+9tiBf0uakwU87QG17 fYttMjTkLcTut5+oa32MVY4w31JEXzQ8b4qsGoZGe/em+Vp+nRP3F5VwbLO19nePElem FvD/XOU3vlO0uJEe3d3YtyGOBLKxvGEOeypGs/pdbQPpQVtRnsSFpGBDmDGX2S7ltZ4c fAIsoDfzPsuQJidKVzujJu7FjZOSpGjlwPxC1v8qyZbpdR3AgGMqrGWnDX+DWCexkmlW C+QXAhWkX0QbzacNpTKBN9kcHAKwYxe/qvCUg9XctAP5Z/3n4HaltMnt5nxvHWHYjq16 0/oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VI0Ghpcxq8/Yi1AQXKCEmSeO6fHHyV1SL/EjKkI3wfk=; b=vAuXKq5nLQSs2KFjnAZcsa+9KTbspkLhzekeeruhMXzq4oTN/6Xc61q0BRcZla7iXN JkXBWa+goqkL9Fy8nQaNfM1zxQ06VfMwrpf8SAm9eLYuXMXI68VnhYx3E0bRfa2IdQOF fx5Iya3diZRBeFlZjbEZcfP1mnYkCsu3jpF66e7hCfgQVdvOGSiOinomMAQQN3YvRpVd mNnr84kt/KMwaJg/wxoC/3N4pNDfYKpejLXCotY0DTVzPExsDMJ2BJSWfuThxhVeWujy Vqs5+ZAzXoUI0RoghCSGrPulihlNlpBal6VimYzs9SjlMWU4iNuDQ4BCNrjgdD+0rH0c S1pA== X-Gm-Message-State: AOAM533ZwapcMgdf17e6+1Dn8o/K5NLPSiNPQpImH6VAjxMepwyGo8tl oQhnu73kPP/uK+kAerLdU/RrqB/BpJ03hA== X-Google-Smtp-Source: ABdhPJx/QAke/7HE2yxp/CxG+Ix/3EmJ0fkMFD5dmRdwSoQPk9GjRvksl3pU7IjzOwVqp4es9rIEig== X-Received: by 2002:a05:6214:1c8f:: with SMTP id ib15mr5149303qvb.2.1644499822922; Thu, 10 Feb 2022 05:30:22 -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 t1sm11289616qtc.48.2022.02.10.05.30.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 05:30:22 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v6 10/11] 9p: darwin: Adjust assumption on virtio-9p-test Date: Thu, 10 Feb 2022 08:29:45 -0500 Message-Id: <20220210132946.2303-11-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220210132946.2303-1-wwcohen@gmail.com> References: <20220210132946.2303-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: -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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The previous test depended on the assumption that P9_DOTL_AT_REMOVEDIR and AT_REMOVEDIR have the same value. While this is true on Linux, it is not true everywhere, and leads to an incorrect test failure on unlink_at, noticed when adding 9p to darwin: Received response 7 (RLERROR) instead of 77 (RUNLINKAT) Rlerror has errno 22 (Invalid argument) ** ERROR:../tests/qtest/virtio-9p-test.c:305:v9fs_req_recv: assertion failed (hdr.id == id): (7 == 77) Bail out! ERROR:../tests/qtest/virtio-9p-test.c:305:v9fs_req_recv: assertion failed (hdr.id == id): (7 == 77) Signed-off-by: Fabian Franz [Will Cohen: - Add explanation of patch and description of pre-patch test failure] Signed-off-by: Will Cohen Acked-by: Thomas Huth [Will Cohen: - Move this patch before 9p: darwin: meson patch to avoid qtest breakage during bisecting] Signed-off-by: Will Cohen Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 41fed41de1..6bcf89f0f8 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -1270,7 +1270,7 @@ static void fs_unlinkat_dir(void *obj, void *data, QGuestAllocator *t_alloc) /* ... and is actually a directory */ g_assert((st.st_mode & S_IFMT) == S_IFDIR); - do_unlinkat(v9p, "/", "02", AT_REMOVEDIR); + do_unlinkat(v9p, "/", "02", P9_DOTL_AT_REMOVEDIR); /* directory should be gone now */ g_assert(stat(new_dir, &st) != 0); From patchwork Thu Feb 10 13:29:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 1591212 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=Yt+JKH02; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JvhVy6vyXz9s8s for ; Fri, 11 Feb 2022 03:08:26 +1100 (AEDT) Received: from localhost ([::1]:57262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIBzc-0002ZL-Q4 for incoming@patchwork.ozlabs.org; Thu, 10 Feb 2022 11:08:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI9XD-0003Cf-D4 for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:57 -0500 Received: from [2607:f8b0:4864:20::f36] (port=46011 helo=mail-qv1-xf36.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI9X7-0004YS-Nw for qemu-devel@nongnu.org; Thu, 10 Feb 2022 08:30:51 -0500 Received: by mail-qv1-xf36.google.com with SMTP id c14so4901260qvl.12 for ; Thu, 10 Feb 2022 05:30:25 -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=u/ht+vQw4r9PuGH4bqUrq8V2DDgtDKVJ6nbbLtrH+54=; b=Yt+JKH02/EbhJuwi0YXLF0nucviyrkDrmueIztf8/ymzA106iim9WM4h6Tt+TKai1T XgSl/dhmdCLlsXcLHQ0AocHaNNT+Lz5X7Zj/UQ4iAOlLX9VwuAvL8c+gmtL8ry9rQr2/ AkKugZBgTrgU7gfvXlbwVOHyiIsQ0dFAV7SACQcbjcNP389rmvWydc01YFvugs3nCb49 q/wt0Ray6PvH+6j/R2wXY41+ROIJEcIbCoiNR3juktXeVVq+XPvaWpS5D4iutvzFSPHv nWTql/f0ZWZVdiGBYD9B2x0znLbz1MJ9SGJyolKL+89FCkXCLTPa4b8bXFdMQqG9tJKe aDcQ== 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=u/ht+vQw4r9PuGH4bqUrq8V2DDgtDKVJ6nbbLtrH+54=; b=FuAKjWo3lUBJaT9K+uAmtgDgANQ9obfhYoNZwur1prV/nk4sLmx2QpEh4/tUkUegMu 8Q5fXM+jSrJmrdHiiV0LektKiz9CqLOKnppsqPLRY8bDi0w4r1EepPAD77R8GYNDm3pg 5sPIEbscrkLC13QwG7Zb00OCvCT06D94RYtdjRu8fZpGj9o6y82OqTFW4LAxR7bOzKvx nROC0ISGJMhUePFNt8d9BzjylHnhmMMbPi1yL2WRQsbYrEUdSqclJmEAC+9o18zqiVH3 aNrX1pu/XonglgGH2dveRaJcYgGB41Sn34Quqrx4TJVHsUSNCe/ONNlNhYpIp13TbutJ bCgQ== X-Gm-Message-State: AOAM533Lt4ULA7BCi97no0Ff1ZjgqaFPR3xFyt0TpWvRjicopjAqG8Vh ivW8XkzFPjld9YikJyZP8imyN8Fnj5svdw== X-Google-Smtp-Source: ABdhPJzgNuj3omw0IAa9JQ5I4jVK3XqfgoJJ1F49ZjIw8uq2Q/V7J/FPrIa6ViTiKTB0XC3RE6AxbQ== X-Received: by 2002:ad4:5ae8:: with SMTP id c8mr4947846qvh.83.1644499825060; Thu, 10 Feb 2022 05:30:25 -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 t1sm11289616qtc.48.2022.02.10.05.30.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 05:30:23 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v6 11/11] 9p: darwin: meson: Allow VirtFS on Darwin Date: Thu, 10 Feb 2022 08:29:46 -0500 Message-Id: <20220210132946.2303-12-wwcohen@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220210132946.2303-1-wwcohen@gmail.com> References: <20220210132946.2303-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f36 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f36; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf36.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer To allow VirtFS on darwin, we need to check that pthread_fchdir_np is available, which has only been available since macOS 10.12. Additionally, virtfs_proxy_helper is disabled on Darwin. This patch series does not currently provide an implementation of the proxy-helper, but this functionality could be implemented later on. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Rebase to master] Signed-off-by: Will Cohen Reviewed-by: Paolo Bonzini [Will Cohen: - Add check for pthread_fchdir_np to virtfs - Add comments to patch commit - Note that virtfs_proxy_helper does not work on macOS - Fully adjust meson virtfs error note to specify macOS] Signed-off-by: Will Cohen --- fsdev/meson.build | 1 + meson.build | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fsdev/meson.build b/fsdev/meson.build index adf57cc43e..b632b66348 100644 --- a/fsdev/meson.build +++ b/fsdev/meson.build @@ -7,6 +7,7 @@ fsdev_ss.add(when: ['CONFIG_FSDEV_9P'], if_true: files( 'qemu-fsdev.c', ), if_false: files('qemu-fsdev-dummy.c')) softmmu_ss.add_all(when: 'CONFIG_LINUX', if_true: fsdev_ss) +softmmu_ss.add_all(when: 'CONFIG_DARWIN', if_true: fsdev_ss) if have_virtfs_proxy_helper executable('virtfs-proxy-helper', diff --git a/meson.build b/meson.build index 5f43355071..3892079ae9 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 != 'darwin' and have_virtfs and have_tools if get_option('virtfs').enabled() if not have_virtfs - if targetos != 'linux' - error('virtio-9p (virtfs) requires Linux') + if targetos != 'linux' and targetos != 'darwin' + error('virtio-9p (virtfs) requires Linux or macOS') + elif targetos == 'darwin' and not cc.has_function('pthread_fchdir_np') + error('virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') elif not libcap_ng.found() or not libattr.found() error('virtio-9p (virtfs) requires libcap-ng-devel and libattr-devel') elif not have_system