From patchwork Sun Feb 20 16:50:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12752770 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 C0EC2C433FE for ; Sun, 20 Feb 2022 17:01:24 +0000 (UTC) Received: from localhost ([::1]:55770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLpaN-00081K-KM for qemu-devel@archiver.kernel.org; Sun, 20 Feb 2022 12:01:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLpQc-0007mI-NB for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:21 -0500 Received: from [2607:f8b0:4864:20::f30] (port=42629 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 1nLpQa-0000Ab-7Q for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:18 -0500 Received: by mail-qv1-xf30.google.com with SMTP id e22so26034578qvf.9 for ; Sun, 20 Feb 2022 08:51: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=NNqqtWfX+7r5Cvr34BgDX1k8to7b5IQs7giXGg/3I6o=; b=SiWK77BjrBLGLsNF3tZNFfHWpcqFzwPJRl5GWPbefoU9BzNE9aS+ZrzIC5zKs3jbYq hb5VGhYFSbekdhZ3uMTIMPm8hbXB9AY83/DEfIS4R8VznMIyd+jcefrfKY1QoW/tEVSw 5S0sZVEQtI2NgTH4gMDium2VeS1pJdHhdjIPHGq+LSkPcp91Os0ZQKoUaloAowvoD5tE UMVICI9K55kBDp9VdU69oUt7chOFOFgl9jU4rp2cTrqJPvhnuuGwtVwyRyOgemtJK2Nd /evYLgW1FMh0XaCh/rThQcDLRndyRC5oD9iiKH6g4N6GZzjiMFyiS75GwyfoovW97ZJy 7AKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NNqqtWfX+7r5Cvr34BgDX1k8to7b5IQs7giXGg/3I6o=; b=Dj/SSNj/uZL41t+Tu/2fIs2hUmtF2LjBEWwj0gLrQazhp9e77w8Gp6hPtRo4m9TI1J Yo2rCyaMCO4ZzV2StnCah7Q9wMkfnZOjeamSZX520TTYapMLxicsXoZrdwzBPEkltICk ew8jIMOwfXMfj/v4LfC1DHWpMzgfOJqONyS6QRAGGW73agrljNwkVbE9gAwDOtWqfD+m tH99FIxU56BOf9Sa8dCkLlAbLTkRDvUuLiajp/85ypSUMmpYJK7ZMcyc5F+iJuTeCfbg iZm0+xr0Ya3KLLUzgCP352AuAj/BzpRizwXD5B5MD42LjfMaRUufUEEIW0IuwucOu3Lk PLEA== X-Gm-Message-State: AOAM531DapyrdwMtUXXnD+oJDTY+b5WeBynEIb48+jK1PokHCoJfvbIG eeeGJ4X6uFcftS9DVX5v5w8MooUUwC6/mA== X-Google-Smtp-Source: ABdhPJzzoNE/vWnaeHmIRrbidNJca7mHb0db3tlsFxyADlm2tSTQL072UkSsb3M3rNvkqIABdMM8ww== X-Received: by 2002:a05:6214:a8a:b0:430:8fbc:6be2 with SMTP id ev10-20020a0562140a8a00b004308fbc6be2mr13042843qvb.7.1645375872649; Sun, 20 Feb 2022 08:51: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 n16sm3190995qkn.115.2022.02.20.08.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 08:51:12 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v8 01/11] 9p: linux: Fix a couple Linux assumptions Date: Sun, 20 Feb 2022 11:50:46 -0500 Message-Id: <20220220165056.72289-2-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220165056.72289-1-wwcohen@gmail.com> References: <20220220165056.72289-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f30 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f30; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf30.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer - Guard Linux only headers. - Add qemu/statfs.h header to abstract over the which headers are needed for struct statfs - Define `ENOATTR` only if not only defined (it's defined in system headers on Darwin). Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch While it might at first appear that fsdev/virtfs-proxy-header.c would need similar adjustment for darwin as file-op-9p here, a later patch in this series disables virtfs-proxy-helper for non-Linux. Allowing virtfs-proxy-helper on darwin could potentially be an additional optimization later. [Will Cohen: - Fix headers for Alpine - Integrate statfs.h back into file-op-9p.h - Remove superfluous header guards from file-opt-9p - Add note about virtfs-proxy-helper being disabled on non-Linux for this patch series] Signed-off-by: Will Cohen Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Greg Kurz --- fsdev/file-op-9p.h | 9 ++++++++- hw/9pfs/9p-local.c | 2 ++ hw/9pfs/9p.c | 4 ++++ include/qemu/xattr.h | 4 +++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h index 8fd89f0447..4997677460 100644 --- a/fsdev/file-op-9p.h +++ b/fsdev/file-op-9p.h @@ -16,10 +16,17 @@ #include #include -#include #include "qemu-fsdev-throttle.h" #include "p9array.h" +#ifdef CONFIG_LINUX +# include +#endif +#ifdef CONFIG_DARWIN +# include +# include +#endif + #define SM_LOCAL_MODE_BITS 0600 #define SM_LOCAL_DIR_MODE_BITS 0700 diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 210d9e7705..1a5e3eed73 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -32,10 +32,12 @@ #include "qemu/error-report.h" #include "qemu/option.h" #include +#ifdef CONFIG_LINUX #include #ifdef CONFIG_LINUX_MAGIC_H #include #endif +#endif #include #ifndef XFS_SUPER_MAGIC diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 15b3f4d385..9c63e14b28 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -32,7 +32,11 @@ #include "migration/blocker.h" #include "qemu/xxhash.h" #include +#ifdef CONFIG_LINUX #include +#else +#include +#endif int open_fd_hw; int total_open_fd; diff --git a/include/qemu/xattr.h b/include/qemu/xattr.h index a83fe8e749..f1d0f7be74 100644 --- a/include/qemu/xattr.h +++ b/include/qemu/xattr.h @@ -22,7 +22,9 @@ #ifdef CONFIG_LIBATTR # include #else -# define ENOATTR ENODATA +# if !defined(ENOATTR) +# define ENOATTR ENODATA +# endif # include #endif From patchwork Sun Feb 20 16:50:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12752768 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 67483C433EF for ; Sun, 20 Feb 2022 16:57:49 +0000 (UTC) Received: from localhost ([::1]:50542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLpWu-0004PM-4n for qemu-devel@archiver.kernel.org; Sun, 20 Feb 2022 11:57:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLpQd-0007mN-63 for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:21 -0500 Received: from [2607:f8b0:4864:20::f2c] (port=38779 helo=mail-qv1-xf2c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nLpQa-0000Ap-Al for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:18 -0500 Received: by mail-qv1-xf2c.google.com with SMTP id d3so26024398qvb.5 for ; Sun, 20 Feb 2022 08:51:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YhmCSOC3CM9NyDHcskObyMbpau9QkFn/fvg6ws80gds=; b=EiEBAdDljolCWXWy9M+2Z4GkJsbihWVUwKDsGnpU21mxcXA+b+85BRThD/8lfRR21j TY5qvu7SfBPekim93Z+a0VRgr5CkreNP1Z1dzGlFCWEg9zd+DpjYtbt9Bf34OpYd/D3G HzUdNyo65O9qY8MkpKXfeOJ+G/n9zpqW17JojTLq6SRiAnZtpGY58btsESp8zk1NNMou hLQaMSyzY4eRUO35R84CUS3tzJ53IY946F2yQmhTJemi/ayOFCKvHh7QLsFCqGvSGgNI veLzzj6mQ/WCnpahqJ8gOjyMtqdpVMLncN61Yphd870u4FBtaSjizLP0/6zcerr2Wvbz txxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YhmCSOC3CM9NyDHcskObyMbpau9QkFn/fvg6ws80gds=; b=BgR23HLIBB2KOoSMKnoUp3LhlcExb8bXMEwJfQMUYjUnZetTY/bH1+YV63KYDPD24I KXg1+zg73u8vNxG6k2A/WRXGsTVlyJYYqIipVnADZVImUNqvcBNYGD8jY8crTQzyzXkT /K3QjGzSEYp6zh1uHJFui3IowU9m1ucMncUwgCkk4MLEb5tK2T3VtP7AQl3ZjVNqBVPu bpZs8+Q68XWyJ8MgCCSTG1jzGG8LZ5w+bx1RZaSv1pWl2iIYsCWDwhTY2xm2p60tKJkT FVyNA4tgUhrULfBrvImxXZw/oVuTM2s31vc+6Bk9QdRDC6OaucKrPWbWjamb9Uu2Y4PJ J3IA== X-Gm-Message-State: AOAM530W6sfDpa/5koq47fALUlg3Re4vkRypbrs7WKupjl6FZLT/kM+W 5FCWqaV1Q5DMyTI0m026YjxVMYpZJdkONw== X-Google-Smtp-Source: ABdhPJxrkbAyuhf/xr7yh/B/e/Fyo3/buf0aQn0navRwcnXS+IJr8raalDRu71EYNC9gPXREl2w+3Q== X-Received: by 2002:ad4:5187:0:b0:42c:4f21:b91b with SMTP id b7-20020ad45187000000b0042c4f21b91bmr12488778qvp.104.1645375874948; Sun, 20 Feb 2022 08:51:14 -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 n16sm3190995qkn.115.2022.02.20.08.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 08:51:14 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v8 02/11] 9p: Rename 9p-util -> 9p-util-linux Date: Sun, 20 Feb 2022 11:50:47 -0500 Message-Id: <20220220165056.72289-3-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220165056.72289-1-wwcohen@gmail.com> References: <20220220165056.72289-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f2c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2c; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf2c.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer The current file only has the Linux versions of these functions. Rename the file accordingly and update the Makefile to only build it on Linux. A Darwin version of these will follow later in the series. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen Reviewed-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daudé --- hw/9pfs/{9p-util.c => 9p-util-linux.c} | 2 +- hw/9pfs/meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename hw/9pfs/{9p-util.c => 9p-util-linux.c} (97%) diff --git a/hw/9pfs/9p-util.c b/hw/9pfs/9p-util-linux.c similarity index 97% rename from hw/9pfs/9p-util.c rename to hw/9pfs/9p-util-linux.c index 3221d9b498..398614a5d0 100644 --- a/hw/9pfs/9p-util.c +++ b/hw/9pfs/9p-util-linux.c @@ -1,5 +1,5 @@ /* - * 9p utilities + * 9p utilities (Linux Implementation) * * Copyright IBM, Corp. 2017 * diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index 99be5d9119..1b28e70040 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -4,7 +4,6 @@ fs_ss.add(files( '9p-posix-acl.c', '9p-proxy.c', '9p-synth.c', - '9p-util.c', '9p-xattr-user.c', '9p-xattr.c', '9p.c', @@ -14,6 +13,7 @@ fs_ss.add(files( 'coth.c', 'coxattr.c', )) +fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-util-linux.c')) fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c')) softmmu_ss.add_all(when: 'CONFIG_FSDEV_9P', if_true: fs_ss) From patchwork Sun Feb 20 16:50:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12752769 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 2F115C433EF for ; Sun, 20 Feb 2022 16:58:06 +0000 (UTC) Received: from localhost ([::1]:51604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLpXB-0005GR-9y for qemu-devel@archiver.kernel.org; Sun, 20 Feb 2022 11:58:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLpQe-0007mS-4T for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:21 -0500 Received: from [2607:f8b0:4864:20::72c] (port=41759 helo=mail-qk1-x72c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nLpQb-0000Bp-PS for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:19 -0500 Received: by mail-qk1-x72c.google.com with SMTP id d84so13593046qke.8 for ; Sun, 20 Feb 2022 08:51:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/9yV7bRN6OBkNxsaJNqx6IRx9uWTGL8PDPo9dIDyd0E=; b=UjHFNShv6QOelYZYkUVylFr1M2eMtHgJFZ5XbKdwiZecyL6Vq67BBvfS3DmQtiH8Ob 8X55r8r3MIjOFk67XDTCG5qi49TAygRiF1V0lpoWtbUiPTCRp4FSgmVqLOKiY+bm2eSO PqFhYzulKkLYQpOMXeArtODblpKPRzvQ051jA4FnOhpVDmAxMv4D+Ky+ToyDM/AwUANT /Wrdx52ZvROJztdAYPYg1xztkXuR8JdjXO2Ppg04xvUKg8gqtCOTsW6wiOdFCHUHYmIx 3o1T/KfVb3mbvd7HEu3YATBGyW/3odIm9OyXxG3Nge+kKK5nZAs5SFlKQsh2LS7BhvTS 3Lmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/9yV7bRN6OBkNxsaJNqx6IRx9uWTGL8PDPo9dIDyd0E=; b=zxvzADVlB8wpfmdWrSwLWRgnWgiRSA4PSOcM/Bg8faX/EX9phcK6rHTJqtjdAu/RO+ O+U26eS3o9NTVouMIEISv3gwFNfZYx67t/NLEOjVglXHRtvfNzWEpJw64lWfDtVLQRCI n+dokfqeamIeN6zc1KOMIXdCZq8SAT1TnchIMRkc4mjblPhyHNYS5BMqpPLEL0SN1nKI 0MiZ083BWPIFFUzLor4NUEMt8hwCqeJYEDXtjub0jhIXNke1bM60Bv6lOdIdRA0PcgQM VgsgpPTwt5uPpAzFJJpk8CVt0DoWFybrQn6aV4xr9Hu5dEpaI/yOTII7AHQIb+Sr4IqG QtSA== X-Gm-Message-State: AOAM531rsBhpvgiZUI8Fhh3nsnqJWW1pjHd1Ust+K87DfPFBaqAR+jk3 BKnFvRKXddWJS5Qus2iLr4quXPuZ38duHg== X-Google-Smtp-Source: ABdhPJwp4OBRI3PQ8jRWcGFpZwagVOHoiZlPZ0Z1511ed/hZ68Ccy75XovxkJ3KzyXcw9HfEO56R2A== X-Received: by 2002:a05:620a:2699:b0:47d:753c:b8ff with SMTP id c25-20020a05620a269900b0047d753cb8ffmr9933561qkp.763.1645375876441; Sun, 20 Feb 2022 08:51:16 -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 n16sm3190995qkn.115.2022.02.20.08.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 08:51:15 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v8 03/11] 9p: darwin: Handle struct stat(fs) differences Date: Sun, 20 Feb 2022 11:50:48 -0500 Message-Id: <20220220165056.72289-4-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220165056.72289-1-wwcohen@gmail.com> References: <20220220165056.72289-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::72c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=wwcohen@gmail.com; helo=mail-qk1-x72c.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch [Will Cohen: - Note lack of f_namelen and f_frsize on Darwin - Ensure that tv_sec and tv_nsec are both initialized for Darwin and non-Darwin] Signed-off-by: Will Cohen --- hw/9pfs/9p-proxy.c | 22 ++++++++++++++++++++-- hw/9pfs/9p-synth.c | 2 ++ hw/9pfs/9p.c | 16 ++++++++++++++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index 09bd9f1464..b1664080d8 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -123,10 +123,16 @@ static void prstatfs_to_statfs(struct statfs *stfs, ProxyStatFS *prstfs) stfs->f_bavail = prstfs->f_bavail; stfs->f_files = prstfs->f_files; stfs->f_ffree = prstfs->f_ffree; +#ifdef CONFIG_DARWIN + /* f_namelen and f_frsize do not exist on Darwin */ + stfs->f_fsid.val[0] = prstfs->f_fsid[0] & 0xFFFFFFFFU; + stfs->f_fsid.val[1] = prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; +#else stfs->f_fsid.__val[0] = prstfs->f_fsid[0] & 0xFFFFFFFFU; stfs->f_fsid.__val[1] = prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU; stfs->f_namelen = prstfs->f_namelen; stfs->f_frsize = prstfs->f_frsize; +#endif } /* Converts proxy_stat structure to VFS stat structure */ @@ -143,12 +149,24 @@ static void prstat_to_stat(struct stat *stbuf, ProxyStat *prstat) stbuf->st_size = prstat->st_size; stbuf->st_blksize = prstat->st_blksize; stbuf->st_blocks = prstat->st_blocks; + stbuf->st_atime = prstat->st_atim_sec; + stbuf->st_mtime = prstat->st_mtim_sec; + stbuf->st_ctime = prstat->st_ctim_sec; +#ifdef CONFIG_DARWIN + stbuf->st_atimespec.tv_sec = prstat->st_atim_sec; + stbuf->st_mtimespec.tv_sec = prstat->st_mtim_sec; + stbuf->st_ctimespec.tv_sec = prstat->st_ctim_sec; + stbuf->st_atimespec.tv_nsec = prstat->st_atim_nsec; + stbuf->st_mtimespec.tv_nsec = prstat->st_mtim_nsec; + stbuf->st_ctimespec.tv_nsec = prstat->st_ctim_nsec; +#else stbuf->st_atim.tv_sec = prstat->st_atim_sec; + stbuf->st_mtim.tv_sec = prstat->st_mtim_sec; + stbuf->st_ctim.tv_sec = prstat->st_ctim_sec; stbuf->st_atim.tv_nsec = prstat->st_atim_nsec; - stbuf->st_mtime = prstat->st_mtim_sec; stbuf->st_mtim.tv_nsec = prstat->st_mtim_nsec; - stbuf->st_ctime = prstat->st_ctim_sec; stbuf->st_ctim.tv_nsec = prstat->st_ctim_nsec; +#endif } /* diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index 7a7cd5c5ba..bf9b0c5ddd 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -439,7 +439,9 @@ static int synth_statfs(FsContext *s, V9fsPath *fs_path, stbuf->f_bsize = 512; stbuf->f_blocks = 0; stbuf->f_files = synth_node_count; +#ifndef CONFIG_DARWIN stbuf->f_namelen = NAME_MAX; +#endif return 0; } diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 9c63e14b28..1563d7b7c6 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1313,11 +1313,17 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf, v9lstat->st_blksize = stat_to_iounit(pdu, stbuf); v9lstat->st_blocks = stbuf->st_blocks; v9lstat->st_atime_sec = stbuf->st_atime; - v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec; v9lstat->st_mtime_sec = stbuf->st_mtime; - v9lstat->st_mtime_nsec = stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_sec = stbuf->st_ctime; +#ifdef CONFIG_DARWIN + v9lstat->st_atime_nsec = stbuf->st_atimespec.tv_nsec; + v9lstat->st_mtime_nsec = stbuf->st_mtimespec.tv_nsec; + v9lstat->st_ctime_nsec = stbuf->st_ctimespec.tv_nsec; +#else + v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec; + v9lstat->st_mtime_nsec = stbuf->st_mtim.tv_nsec; v9lstat->st_ctime_nsec = stbuf->st_ctim.tv_nsec; +#endif /* Currently we only support BASIC fields in stat */ v9lstat->st_result_mask = P9_STATS_BASIC; @@ -3519,9 +3525,15 @@ static int v9fs_fill_statfs(V9fsState *s, V9fsPDU *pdu, struct statfs *stbuf) f_bavail = stbuf->f_bavail / bsize_factor; f_files = stbuf->f_files; f_ffree = stbuf->f_ffree; +#ifdef CONFIG_DARWIN + fsid_val = (unsigned int)stbuf->f_fsid.val[0] | + (unsigned long long)stbuf->f_fsid.val[1] << 32; + f_namelen = NAME_MAX; +#else fsid_val = (unsigned int) stbuf->f_fsid.__val[0] | (unsigned long long)stbuf->f_fsid.__val[1] << 32; f_namelen = stbuf->f_namelen; +#endif return pdu_marshal(pdu, offset, "ddqqqqqqd", f_type, f_bsize, f_blocks, f_bfree, From patchwork Sun Feb 20 16:50:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12752771 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 0CED2C433EF for ; Sun, 20 Feb 2022 17:01:39 +0000 (UTC) Received: from localhost ([::1]:56016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLpac-0008BX-PN for qemu-devel@archiver.kernel.org; Sun, 20 Feb 2022 12:01:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLpQg-0007mi-0c for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:22 -0500 Received: from [2607:f8b0:4864:20::730] (port=41763 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 1nLpQd-0000CT-0j for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:21 -0500 Received: by mail-qk1-x730.google.com with SMTP id d84so13593081qke.8 for ; Sun, 20 Feb 2022 08:51:18 -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=tYoP77FurlvuwztILnvVHYI4CslvWCvB2NtO3LJB/QE=; b=pLMhsHPB9/+zdIK0lRKMlZyMG8uyQd2uRfnRCoZQo8mriLHEhy23wijyR6SF8C9w2Q ik7DO6xiahPFymFGurN7ghtNw2XTLZNvIPYAIzoqNcz7HtStkue3k55HEFa8FgUAmef3 dPLDVMdfceGTCgn8sgLvQyUz4sta1A4YCRC/38xooWV9j0cqHz5Is4yAcaaV6/b4EXxQ rvwKZUfUz1n3+EC5jiF8p8J2GuBof+WUrMiPjWwBPE3rhiDvhyiuRLzUQ4U/fV1fWCz/ FHIHk8AL2mXskGTFRTtwpP3qCJMt6z4sO3hmCTMy1wop73IWVONoBFHkPjDp4hJP05wo Hrhg== 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=tYoP77FurlvuwztILnvVHYI4CslvWCvB2NtO3LJB/QE=; b=vpoWTd0Ea4Dm/7uT0wUYrM4o25bNPjSQRyehjxlzQHbzBjHy1Lv4vvWavgdMVFIvXQ ERCQUKRI/W+GzuCRjrqFsxOAAYUEuXSc10ROyRxzoplnx73+CKC0xnTX0rTmxbFEl6B2 06lmrWrodQMQkH1NLl7QxUaYU8LVTLpcNJanU3oYsTHEKO6Ue0wEzZciO23mxJY/niZK sJLsZjNmsbYGfp7m9bYuAhlv/5Yt22E7FfkmjE90spqyKOLUYiS8b67WJXlKSZPI2S+g vOX8pitLUDtqCQW8wL0/TL8oewR4/a8868Jsnsv3WqPV98QRbQ7+xlfm4CiH0gbo1W/i M5Xg== X-Gm-Message-State: AOAM531c1Z/xJA4qqvjX4K2VnezsGNmJjCH2m9z4aKE5CrmnID6e6qBO cGmFKAlaUgm1alK2bIas1mqPje0xOHo7nA== X-Google-Smtp-Source: ABdhPJygJZz/Q3TOwer5pcloCipH4+ukmW1VxQ6ICbAjMDtcYHloFmt2f2g7+tWA7qLvXxfEUj46ug== X-Received: by 2002:a37:9146:0:b0:507:d59c:6059 with SMTP id t67-20020a379146000000b00507d59c6059mr9980011qkd.593.1645375877810; Sun, 20 Feb 2022 08:51:17 -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 n16sm3190995qkn.115.2022.02.20.08.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 08:51:17 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v8 04/11] 9p: darwin: Handle struct dirent differences Date: Sun, 20 Feb 2022 11:50:49 -0500 Message-Id: <20220220165056.72289-5-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220165056.72289-1-wwcohen@gmail.com> References: <20220220165056.72289-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: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Fabian Franz , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer On darwin d_seekoff exists, but is optional and does not seem to be commonly used by file systems. Use `telldir` instead to obtain the seek offset and inject it into d_seekoff, and create a qemu_dirent_off helper to call it appropriately when appropriate. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Adjust to pass testing - Ensure that d_seekoff is filled using telldir on darwin, and create qemu_dirent_off helper to decide which to access] [Fabian Franz: - Add telldir error handling for darwin] Signed-off-by: Fabian Franz [Will Cohen: - Ensure that telldir error handling uses signed int - Cleanup of telldir error handling - Remove superfluous error handling for qemu_dirent_off - Adjust formatting - Use qemu_dirent_off in codir.c] Signed-off-by: Will Cohen --- hw/9pfs/9p-local.c | 9 +++++++++ hw/9pfs/9p-proxy.c | 16 +++++++++++++++- hw/9pfs/9p-synth.c | 4 ++++ hw/9pfs/9p-util.h | 16 ++++++++++++++++ hw/9pfs/9p.c | 7 +++++-- hw/9pfs/codir.c | 4 +++- 6 files changed, 52 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 1a5e3eed73..f3272f0b43 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -562,6 +562,15 @@ again: if (!entry) { return NULL; } +#ifdef CONFIG_DARWIN + int off; + off = telldir(fs->dir.stream); + /* If telldir fails, fail the entire readdir call */ + if (off < 0) { + return NULL; + } + entry->d_seekoff = off; +#endif if (ctx->export_flags & V9FS_SM_MAPPED) { entry->d_type = DT_UNKNOWN; diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index b1664080d8..8b4b5cf7dc 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -706,7 +706,21 @@ static off_t proxy_telldir(FsContext *ctx, V9fsFidOpenState *fs) static struct dirent *proxy_readdir(FsContext *ctx, V9fsFidOpenState *fs) { - return readdir(fs->dir.stream); + struct dirent *entry; + entry = readdir(fs->dir.stream); +#ifdef CONFIG_DARWIN + if (!entry) { + return NULL; + } + int td; + td = telldir(fs->dir.stream); + /* If telldir fails, fail the entire readdir call */ + if (td < 0) { + return NULL; + } + entry->d_seekoff = td; +#endif + return entry; } static void proxy_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index bf9b0c5ddd..b3080e415b 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -234,7 +234,11 @@ static void synth_direntry(V9fsSynthNode *node, offsetof(struct dirent, d_name) + sz); memcpy(entry->d_name, node->name, sz); entry->d_ino = node->attr->inode; +#ifdef CONFIG_DARWIN + entry->d_seekoff = off + 1; +#else entry->d_off = off + 1; +#endif } static struct dirent *synth_get_dentry(V9fsSynthNode *dir, diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 546f46dc7d..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 c0873bde16..f96d8ac4e6 100644 --- a/hw/9pfs/codir.c +++ b/hw/9pfs/codir.c @@ -22,6 +22,8 @@ #include "qemu/coroutine.h" #include "qemu/main-loop.h" #include "coth.h" +#include "9p-xattr.h" +#include "9p-util.h" /* * Intended to be called from bottom-half (e.g. background I/O thread) @@ -166,7 +168,7 @@ static int do_readdir_many(V9fsPDU *pdu, V9fsFidState *fidp, } size += len; - saved_dir_pos = dent->d_off; + saved_dir_pos = qemu_dirent_off(dent); } /* restore (last) saved position */ From patchwork Sun Feb 20 16:50:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12752767 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 9CBCDC433EF for ; Sun, 20 Feb 2022 16:54:10 +0000 (UTC) Received: from localhost ([::1]:47406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLpTN-0002EM-LX for qemu-devel@archiver.kernel.org; Sun, 20 Feb 2022 11:54:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLpQg-0007mj-9j for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:22 -0500 Received: from [2607:f8b0:4864:20::730] (port=46964 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 1nLpQe-0000Ck-Bc for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:21 -0500 Received: by mail-qk1-x730.google.com with SMTP id f21so2416256qke.13 for ; Sun, 20 Feb 2022 08:51:20 -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=OQsJdOHddV75uy/z8dRcrVTvB6Zu5S1Fp/PXYFh99jk=; b=a3LhpXyPAV2GwBgJVvxtcWVHcRHULvuV5VRybyQ3Czv2HDNjRyyNjND75NXYfaaftJ UI6jaYx30ceW1NX29E1+vuiN1IS5/3fgdIcKVpAWbzxLAAS6cij5t7SBSFxo+O3RJfQh p48vz8zunZtfXlbAFZPXG3P5BJ0kT4O+Oo2i8DxiFNdu11anrJKO+umNsLAj6xNOUYXN 7+v8/nL00DQ64Rqi6G+uCYgj0n9c/bl8fXG+hhOAb3QBe2QEPtqlaBReEpelQXDano/F VI0iC5XXqAVrAzZaepwN+ySXCRqy5oPpl0WELw9hwC5bA7LxeO+Pw1EdkPMuwHow8bXy rjrg== 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=OQsJdOHddV75uy/z8dRcrVTvB6Zu5S1Fp/PXYFh99jk=; b=f45ehzdi8+AijKY4wJrVw63TXWfmsZGVn4t7EcU5MKcKV1SEIjnuqUuXlM/6B2DNet aKuCSSlJ4iItqE6K0l0vopV6VZxMeN+P3mivQidYc7upZdrFHYdPau0x2/zFIPjhVXY2 4m2Ot0EwBfzHogqCz5hY3iO0L8qfdxNz646DWzk/TaW8JzPoGS5tZ7OhKOZOnhqi+F3Z NSPd1Soya+HoAuK/LGGRA3+N+YA++UFicvHDlhcTdsN9Nh1ZGJtbNO7cvE4OPUFNGN2P yWWj6IdohmTb3TgxxlicO1pmCZJ5ByOXYJ3e9yi0D0BarOJbWti4vH7pkZ9cRJWz9bnS PffA== X-Gm-Message-State: AOAM533+VW4eo+n5ej0jPN4cWZAJ3RSeDNmmOG+/RUe51J/pqdKRbmQk 8GJ55YKkCfVMva9QkIcLY5CElheamqAvfw== X-Google-Smtp-Source: ABdhPJxip9d0UjixHBhU86QilRuaSDSHobz6nBzlhvVxhLTUIb6JGtpI1zvVkBrE4ADRwmeJoBiqpw== X-Received: by 2002:a05:620a:13db:b0:62c:e591:fd9 with SMTP id g27-20020a05620a13db00b0062ce5910fd9mr6344278qkl.766.1645375879196; Sun, 20 Feb 2022 08:51:19 -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 n16sm3190995qkn.115.2022.02.20.08.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 08:51:18 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v8 05/11] 9p: darwin: Ignore O_{NOATIME, DIRECT} Date: Sun, 20 Feb 2022 11:50:50 -0500 Message-Id: <20220220165056.72289-6-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220165056.72289-1-wwcohen@gmail.com> References: <20220220165056.72289-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: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Darwin doesn't have either of these flags. Darwin does have F_NOCACHE, which is similar to O_DIRECT, but has different enough semantics that other projects don't generally map them automatically. In any case, we don't support O_DIRECT on Linux at the moment either. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Adjust coding style] Signed-off-by: Will Cohen --- hw/9pfs/9p-util.h | 2 ++ hw/9pfs/9p.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index d41f37f085..0e445b5d52 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -41,6 +41,7 @@ again: fd = openat(dirfd, name, flags | O_NOFOLLOW | O_NOCTTY | O_NONBLOCK, mode); if (fd == -1) { +#ifndef CONFIG_DARWIN if (errno == EPERM && (flags & O_NOATIME)) { /* * The client passed O_NOATIME but we lack permissions to honor it. @@ -53,6 +54,7 @@ again: flags &= ~O_NOATIME; goto again; } +#endif return -1; } diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index caf3b240fe..14e84c3bcf 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -138,11 +138,20 @@ static int dotl_to_open_flags(int flags) { P9_DOTL_NONBLOCK, O_NONBLOCK } , { P9_DOTL_DSYNC, O_DSYNC }, { P9_DOTL_FASYNC, FASYNC }, +#ifndef CONFIG_DARWIN + { P9_DOTL_NOATIME, O_NOATIME }, + /* + * On Darwin, we could map to F_NOCACHE, which is + * similar, but doesn't quite have the same + * semantics. However, we don't support O_DIRECT + * even on linux at the moment, so we just ignore + * it here. + */ { P9_DOTL_DIRECT, O_DIRECT }, +#endif { P9_DOTL_LARGEFILE, O_LARGEFILE }, { P9_DOTL_DIRECTORY, O_DIRECTORY }, { P9_DOTL_NOFOLLOW, O_NOFOLLOW }, - { P9_DOTL_NOATIME, O_NOATIME }, { P9_DOTL_SYNC, O_SYNC }, }; @@ -171,10 +180,12 @@ static int get_dotl_openflags(V9fsState *s, int oflags) */ flags = dotl_to_open_flags(oflags); flags &= ~(O_NOCTTY | O_ASYNC | O_CREAT); +#ifndef CONFIG_DARWIN /* * Ignore direct disk access hint until the server supports it. */ flags &= ~O_DIRECT; +#endif return flags; } From patchwork Sun Feb 20 16:50:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12752772 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 86BD3C433EF for ; Sun, 20 Feb 2022 17:03:44 +0000 (UTC) Received: from localhost ([::1]:59092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLpcc-00023l-PU for qemu-devel@archiver.kernel.org; Sun, 20 Feb 2022 12:03:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLpQh-0007nd-Fl for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:23 -0500 Received: from [2607:f8b0:4864:20::f35] (port=43884 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 1nLpQf-0000DD-NS for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:23 -0500 Received: by mail-qv1-xf35.google.com with SMTP id a28so26050593qvb.10 for ; Sun, 20 Feb 2022 08:51:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FIM26iDeobdaVDOFSCZhx4ufdUObSP6716TqaQ3mxlU=; b=LVw9XOtm30z6obMt1PBxaXipv2oqFaHO4kYzKqu6KRGjZvfrpURfpUc16GoR3GKLxT n0xPtdj12/ag5ifP3koSUHBoVdV57kOMuPiq/4vSdRkryDO3W+lOP6WT2OE/I+KXAaBP 5IoCyDeZR1uWRxfNEAEJz7pdXb6+dLApwewbg25DgUZGvyT5X8q/wAtTw53alV6hA79W JgIEsMNbX4QxuJE/K3zSMAV0har5d65Hrz0Z/VwQiZtBFm50fAi1UhO3nqdRn1n0iLt7 fFg4WiZtdsq3J2sKFw0XZhWT/rfjzDshzdNTSNpTZ9hC88/tSeRuEAsNGCtG2J1tj2a8 xdtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FIM26iDeobdaVDOFSCZhx4ufdUObSP6716TqaQ3mxlU=; b=CyUVsr+osnCMM1NnRmAV8xxGWFLWOUPsDc7klVU70koIYT1n/d433t82QBJ23EBdbF DFUb/E3bI2Q21KhJtI0KxBXsU8nX7gEqMOwZO1tBgtbKHcxNGRRRDtUcExf4xdHOYcma TQQHUlhopfa/yH6gC0HPUl+EuCFQHrv4KCKreJ0zyhosWjI6SfV2WI/L0cUV8Py0OAeY boMf8LhVh+7ICSlgNnX/5zajyZO94pZ4+nQXFMfI/ni7eAJb26cPebObZIHQxuuNOcEp rLSAUssYYd0Sj6nNVWJ+0BbE1HIdiDOxLPoQIbOoEkDpnL3YWaktRm1zzaykdHByRzV7 pdbw== X-Gm-Message-State: AOAM531xVyKBxSIMUESBXygxaKWrmauD/nfxbMEHm3dUaKS+FOoKDCOZ zrlCTAmITl2wC4KX7zxCNtJHpu569soaTw== X-Google-Smtp-Source: ABdhPJymhz/EKrKwGYLWmUkiG30JD0oc5BlvkkpJWARhkotdeS8vjloED1FSQCTb+A1J+q9m+z3jiQ== X-Received: by 2002:a0c:c601:0:b0:42c:dee7:486b with SMTP id v1-20020a0cc601000000b0042cdee7486bmr12826744qvi.97.1645375880624; Sun, 20 Feb 2022 08:51:20 -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 n16sm3190995qkn.115.2022.02.20.08.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 08:51:20 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v8 06/11] 9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX Date: Sun, 20 Feb 2022 11:50:51 -0500 Message-Id: <20220220165056.72289-7-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220165056.72289-1-wwcohen@gmail.com> References: <20220220165056.72289-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: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Fabian Franz , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch Because XATTR_SIZE_MAX is not defined on Darwin, create a cross-platform P9_XATTR_SIZE_MAX instead. [Will Cohen: - Adjust coding style - Lower XATTR_SIZE_MAX to 64k - Add explanatory context related to XATTR_SIZE_MAX] [Fabian Franz: - Move XATTR_SIZE_MAX reference from 9p.c to P9_XATTR_SIZE_MAX in 9p.h] Signed-off-by: Will Cohen Signed-off-by: Fabian Franz [Will Cohen: - For P9_XATTR_MAX, ensure that Linux uses XATTR_SIZE_MAX, Darwin uses 64k, and error out for undefined hosts] Signed-off-by: Will Cohen --- hw/9pfs/9p.c | 2 +- hw/9pfs/9p.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 14e84c3bcf..7405352c37 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3949,7 +3949,7 @@ static void coroutine_fn v9fs_xattrcreate(void *opaque) rflags |= XATTR_REPLACE; } - if (size > XATTR_SIZE_MAX) { + if (size > P9_XATTR_SIZE_MAX) { err = -E2BIG; goto out_nofid; } diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 1567b67841..94b273b3d0 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -479,4 +479,22 @@ struct V9fsTransport { void (*push_and_notify)(V9fsPDU *pdu); }; +#if defined(XATTR_SIZE_MAX) +/* Linux */ +#define P9_XATTR_SIZE_MAX XATTR_SIZE_MAX +#elif defined(CONFIG_DARWIN) +/* + * Darwin doesn't seem to define a maximum xattr size in its user + * space header, so manually configure it across platforms as 64k. + * + * Having no limit at all can lead to QEMU crashing during large g_malloc() + * calls. Because QEMU does not currently support macOS guests, the below + * preliminary solution only works due to its being a reflection of the limit of + * Linux guests. + */ +#define P9_XATTR_SIZE_MAX 65536 +#else +#error Missing definition for P9_XATTR_SIZE_MAX for this host system +#endif + #endif From patchwork Sun Feb 20 16:50:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12752775 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 BEA8CC433EF for ; Sun, 20 Feb 2022 17:08:40 +0000 (UTC) Received: from localhost ([::1]:39570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLphP-00080r-OF for qemu-devel@archiver.kernel.org; Sun, 20 Feb 2022 12:08:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLpQj-0007p1-UW for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:26 -0500 Received: from [2607:f8b0:4864:20::f2b] (port=44644 helo=mail-qv1-xf2b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nLpQh-0000Da-7e for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:24 -0500 Received: by mail-qv1-xf2b.google.com with SMTP id p7so26015680qvk.11 for ; Sun, 20 Feb 2022 08:51: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=5V3o5RrwtkJ65v1m3Fl9y6glfQnm4FrYqCfEyCvWZQg=; b=ouba6oUvDLxrMFyXvQErTYCAqIfkpT8Wx/pVWGTobgTAlyhMNtnyMdr7Cvm7AS5l/f WaOLaAPbH2hw5NpNaz1h5YdI+i0ZmxT1MQOusSO1CKFsd6BQLWtZ7Wtq0CFbqV7064tv frSlj6RMBvdYBLJW/BO0y7EbDpEvyps8EmhJO609MkTkhyiken/40TNFU09jBSGjm/cV qTZ++yFSMyGK7+1pIsTndyL4XRLdcOUxV9v2HJBQgnPMAq1vRsGp+jvX7bW1y9jjpkZ0 9mzZ8lnIMMWVZdgBhsBQZ6JbP70ncDkGuZO4PJLeD/9INxjv01UZoFf7H4mhyefCkAxA 3axw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5V3o5RrwtkJ65v1m3Fl9y6glfQnm4FrYqCfEyCvWZQg=; b=lCD11KTtbMMqewQNBJWIa4fwfmRNH7mlM3p/GB4c+BYRE5hoSXyRQdOjBH4LEmR4H2 3YG+14jUh0P0OJq7/7cB0E0vaRe9KY15i5pPbKCA/zjsVNlYQq+uMjA9Vb4HOsI9PrX0 BDG0n2QV3Ym/Xsmwv65wWthHR38lnrmQU8NRmVWRV3v+sBds4+v0JQY4rjMkolYwLXuf BAn0ByrsLiPWH3g2U+XDtDfMsMId6i2p5ELwxCCpmWbex1wtcW5sgav4e6V7LMqYndVC qdgzhLX7qtANwenCeoaq42Ro0Dasi0/Yr2aA6Tt6EngnuQFCxhINHIy5nPE84TZYszUd z0mA== X-Gm-Message-State: AOAM5333Ag2Ej17VI9Z3JXHhaECFW1/Ynlaig/GR4QbOuY2ocP7gqyUa JfA1lbRJjt+zKy+J6VHRE//EOp3xT3qWlw== X-Google-Smtp-Source: ABdhPJwjDSds2O+Yx4qb+ATTxhdYYBV5claocJdvVYRB4BZTnT4pGLC/X8TAqi04W48WPiXfeTIjfA== X-Received: by 2002:ac8:5b05:0:b0:2dd:1891:2758 with SMTP id m5-20020ac85b05000000b002dd18912758mr14619019qtw.361.1645375882001; Sun, 20 Feb 2022 08:51: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 n16sm3190995qkn.115.2022.02.20.08.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 08:51:21 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v8 07/11] 9p: darwin: *xattr_nofollow implementations Date: Sun, 20 Feb 2022 11:50:52 -0500 Message-Id: <20220220165056.72289-8-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220165056.72289-1-wwcohen@gmail.com> References: <20220220165056.72289-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f2b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2b; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf2b.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer This implements the darwin equivalent of the functions that were moved to 9p-util(-linux) earlier in this series in the new 9p-util-darwin file. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- hw/9pfs/9p-util-darwin.c | 64 ++++++++++++++++++++++++++++++++++++++++ hw/9pfs/meson.build | 1 + 2 files changed, 65 insertions(+) create mode 100644 hw/9pfs/9p-util-darwin.c diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c new file mode 100644 index 0000000000..cdb4c9e24c --- /dev/null +++ b/hw/9pfs/9p-util-darwin.c @@ -0,0 +1,64 @@ +/* + * 9p utilities (Darwin Implementation) + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/xattr.h" +#include "9p-util.h" + +ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size) +{ + int ret; + int fd = openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = fgetxattr(fd, name, value, size, 0, 0); + close_preserve_errno(fd); + return ret; +} + +ssize_t flistxattrat_nofollow(int dirfd, const char *filename, + char *list, size_t size) +{ + int ret; + int fd = openat_file(dirfd, filename, + O_RDONLY | O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = flistxattr(fd, list, size, 0); + close_preserve_errno(fd); + return ret; +} + +ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, + const char *name) +{ + int ret; + int fd = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = fremovexattr(fd, name, 0); + close_preserve_errno(fd); + return ret; +} + +int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, + void *value, size_t size, int flags) +{ + int ret; + int fd = openat_file(dirfd, filename, O_PATH_9P_UTIL | O_NOFOLLOW, 0); + if (fd == -1) { + return -1; + } + ret = fsetxattr(fd, name, value, size, 0, flags); + close_preserve_errno(fd); + return ret; +} diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index 1b28e70040..12443b6ad5 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -14,6 +14,7 @@ fs_ss.add(files( 'coxattr.c', )) fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-util-linux.c')) +fs_ss.add(when: 'CONFIG_DARWIN', if_true: files('9p-util-darwin.c')) fs_ss.add(when: 'CONFIG_XEN', if_true: files('xen-9p-backend.c')) softmmu_ss.add_all(when: 'CONFIG_FSDEV_9P', if_true: fs_ss) From patchwork Sun Feb 20 16:50:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12752774 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 2BA8BC433F5 for ; Sun, 20 Feb 2022 17:07:40 +0000 (UTC) Received: from localhost ([::1]:36382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLpgR-0005oP-24 for qemu-devel@archiver.kernel.org; Sun, 20 Feb 2022 12:07:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLpQm-0007sK-2y for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:28 -0500 Received: from [2607:f8b0:4864:20::f2c] (port=43876 helo=mail-qv1-xf2c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nLpQj-0000Dt-Jd for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:26 -0500 Received: by mail-qv1-xf2c.google.com with SMTP id a28so26050729qvb.10 for ; Sun, 20 Feb 2022 08:51:24 -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=8zBVPH3dh511MwRRE/82ibc/ADSXdWhxf3bf+FA82Mc=; b=QRWqo5oZVsNC6ihlzHvnp78t1JWV+br6bONRPAUgeFz9hYnVVTQii4PZRqNKDQFkyK 0rmBxW9Vwhgs5l7P9YmdlbKE9/1SsECgu0FU2pyQcEXpAbCdhMWoAq4h/hpZnVRUBLwH lD9qXq4FV87GM1vSotJb74sU2UtHIzpDiTEBh4/9Bngkzbv1WqFXyqGgV83uG5SdLUj0 XEyFcN10Deq2JUVKiD6FLhVvHZXB1hADboZ5k1xXcFPAet1wQC9MLVQ/BRkIyifwPvnE dWM6G7ecACRtbsoTHlOgpDqzqwbD+kXCclBt4F7zn7hvsuTcUzOAIgjvD/osuC7JE49/ EmNA== 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=8zBVPH3dh511MwRRE/82ibc/ADSXdWhxf3bf+FA82Mc=; b=m08KF+OtZgVJixBTI/gcyiKFl9GKL7zSLNjbsGX/mT7FY08Fwg552pMkF+D/Yb6UCU gYs7F6AthTCrThMp3YvDehHiVfyEXDLqPYkH01XDCgJOKWqGasf343ugi5rH33bxo0ND lSFN3aIQjojFDtDbFcZYrPTcGNJ6aXP0UJzXjUW9/smTQ756azIBa4d8NvqgKmuod9tj 6DBEGweQL6GQP70PhY+U0X/CyzIGMzfX2+JyVBTL8fqwRtT7gk8lGxRduyNsbuyCn2Lt 13iEj/oLGpdyiefPqk/GO0cewPaXwFjvQ+fUvCi1ly3KBME6mI4eMdUnyrzio40MCFdX gKsQ== X-Gm-Message-State: AOAM5338KHQeK1wYDkese9QrrFqEj0p97gg7DsjKNYk05weHP6zfSAui eqNL18hxMXKMYSVoKrqdcMwA+lbxjsDQoQ== X-Google-Smtp-Source: ABdhPJwxsbFiZmWU5uKD9QS/gBDYNpl8TrMWjsDnXWKkYHEeydcECAcKVkjbUaFKFIj7deHUf0j/JA== X-Received: by 2002:ad4:4711:0:b0:42b:fcfa:a2ef with SMTP id k17-20020ad44711000000b0042bfcfaa2efmr12386940qvz.68.1645375883294; Sun, 20 Feb 2022 08:51:23 -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 n16sm3190995qkn.115.2022.02.20.08.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 08:51:22 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v8 08/11] 9p: darwin: Compatibility for f/l*xattr Date: Sun, 20 Feb 2022 11:50:53 -0500 Message-Id: <20220220165056.72289-9-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220165056.72289-1-wwcohen@gmail.com> References: <20220220165056.72289-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f2c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2c; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf2c.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer On darwin `fgetxattr` takes two extra optional arguments, and the l* variants are not defined (in favor of an extra flag to the regular variants. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch Signed-off-by: Will Cohen --- hw/9pfs/9p-local.c | 12 ++++++++---- hw/9pfs/9p-util.h | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index f3272f0b43..a0d08e5216 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -790,16 +790,20 @@ static int local_fstat(FsContext *fs_ctx, int fid_type, mode_t tmp_mode; dev_t tmp_dev; - if (fgetxattr(fd, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) { + if (qemu_fgetxattr(fd, "user.virtfs.uid", + &tmp_uid, sizeof(uid_t)) > 0) { stbuf->st_uid = le32_to_cpu(tmp_uid); } - if (fgetxattr(fd, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) { + if (qemu_fgetxattr(fd, "user.virtfs.gid", + &tmp_gid, sizeof(gid_t)) > 0) { stbuf->st_gid = le32_to_cpu(tmp_gid); } - if (fgetxattr(fd, "user.virtfs.mode", &tmp_mode, sizeof(mode_t)) > 0) { + if (qemu_fgetxattr(fd, "user.virtfs.mode", + &tmp_mode, sizeof(mode_t)) > 0) { stbuf->st_mode = le32_to_cpu(tmp_mode); } - if (fgetxattr(fd, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) { + if (qemu_fgetxattr(fd, "user.virtfs.rdev", + &tmp_dev, sizeof(dev_t)) > 0) { stbuf->st_rdev = le64_to_cpu(tmp_dev); } } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 0e445b5d52..82399702b9 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -19,6 +19,23 @@ #define O_PATH_9P_UTIL 0 #endif +#ifdef CONFIG_DARWIN +#define qemu_fgetxattr(...) fgetxattr(__VA_ARGS__, 0, 0) +#define qemu_lgetxattr(...) getxattr(__VA_ARGS__, 0, XATTR_NOFOLLOW) +#define qemu_llistxattr(...) listxattr(__VA_ARGS__, XATTR_NOFOLLOW) +#define qemu_lremovexattr(...) removexattr(__VA_ARGS__, XATTR_NOFOLLOW) +static inline int qemu_lsetxattr(const char *path, const char *name, + const void *value, size_t size, int flags) { + return setxattr(path, name, value, size, 0, flags | XATTR_NOFOLLOW); +} +#else +#define qemu_fgetxattr fgetxattr +#define qemu_lgetxattr lgetxattr +#define qemu_llistxattr llistxattr +#define qemu_lremovexattr lremovexattr +#define qemu_lsetxattr lsetxattr +#endif + static inline void close_preserve_errno(int fd) { int serrno = errno; From patchwork Sun Feb 20 16:50:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12752773 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 509E8C433EF for ; Sun, 20 Feb 2022 17:05:12 +0000 (UTC) Received: from localhost ([::1]:60180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLpdt-0002lb-D5 for qemu-devel@archiver.kernel.org; Sun, 20 Feb 2022 12:05:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLpQm-0007sP-9l for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:28 -0500 Received: from [2607:f8b0:4864:20::f2f] (port=44648 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 1nLpQj-0000E4-OA for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:27 -0500 Received: by mail-qv1-xf2f.google.com with SMTP id p7so26015839qvk.11 for ; Sun, 20 Feb 2022 08:51: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=w0c1m62r37cps3SE4YtHaNnVH3ko3NP7UbCqOmgH+Bw=; b=Z9uy30n5olSE0quZ9vrPXrOXTPcZoLsB6lEZhwawslefIo4ZrLBPa6Fjkv0SXBn+5a W+psEM6joyOUcCI97GPBSdxhtTBT11gn6XtqW++J6VDk46ji1pJVsY036x9eVdZUMAbu beMwqo5C2YzX1AO7f+fVEDoRVqM3zOx4hUcA4Eh487YXIvVjBSQeW2WcsPASpLKNhk7C GHC7uvxeN0XC0Z2zqgYjeG56lirptccM3nQJmnKjo8Lx1CtG7E11mEoCTW2L5rJqzX5i 3pYyMOyh8ocdvIrxNEmR98e9nkg+1AQrcvijjVYtTHrHOHz02N5nNzcbHJ3B82sHEFEN igSw== 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=w0c1m62r37cps3SE4YtHaNnVH3ko3NP7UbCqOmgH+Bw=; b=U3KPgei8MtxPO+so1ehQL07/7uk8i7RozppB43awvGBvzZ+U0QjZ/uAzH94FZf6jhP YbKnzQ308lt5jV86IMD5Ah86A8SxdKbZuUizmeeWxI4KYm1sgh1LGe909sjFib/Xd5pw cPkpZSBUXe6GcO8FzuSSEMOdgWjsRg4pD5DGnretO/bedjwJXW0eB6hFEEfVnCbdtuYy 2B38qZFPytFL0K62M9T9B8XAnuBNGoFRHTcEvLofp54Z+mrmXN5ioBW4QW6VHYzaEYnH VudaN4MF9/q8FutNirYQsKRGmr0h+TVHu7AU4vsooZcv2ET4BV8lIE6PBIiP2r+Hnlrc QDOw== X-Gm-Message-State: AOAM533fv410Tw/Ry0Q02ICAulX/f5z5tdvYnGUpTh4RXvIOJGqgBVFN XzC/chA1P687T2tQG3vxLvCYUWBwWKUloA== X-Google-Smtp-Source: ABdhPJz3emzztBJ0HqCm/S89SVJD+9mqnokiRu2i7sHG0eALTzOlbC4fXBrwCCrslt3gL9WhwFokRQ== X-Received: by 2002:a05:6214:21ed:b0:42c:11d1:70cd with SMTP id p13-20020a05621421ed00b0042c11d170cdmr12525478qvj.115.1645375884547; Sun, 20 Feb 2022 08:51:24 -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 n16sm3190995qkn.115.2022.02.20.08.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 08:51:24 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v8 09/11] 9p: darwin: Implement compatibility for mknodat Date: Sun, 20 Feb 2022 11:50:54 -0500 Message-Id: <20220220165056.72289-10-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220165056.72289-1-wwcohen@gmail.com> References: <20220220165056.72289-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: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Darwin does not support mknodat. However, to avoid race conditions with later setting the permissions, we must avoid using mknod on the full path instead. We could try to fchdir, but that would cause problems if multiple threads try to call mknodat at the same time. However, luckily there is a solution: Darwin includes a function that sets the cwd for the current thread only. This should suffice to use mknod safely. This function (pthread_fchdir_np) is protected by a check in meson in a patch later in this series. Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch [Will Cohen: - Adjust coding style - Replace clang references with gcc - Note radar filed with Apple for missing syscall - Replace direct syscall with pthread_fchdir_np and adjust patch notes accordingly - Move qemu_mknodat from 9p-util to osdep and os-posix - Move pthread_fchdir_np declaration only to osdep - Declare pthread_fchdir_np with - __attribute__((weak_import)) to allow checking for its presence before usage - Move declarations above cplusplus guard - Add CONFIG_PTHREAD_FCHDIR_NP to meson and check for presence in osdep.h and os-posix.c - Rebase to apply cleanly on top of the 2022-02-10 changes to 9pfs] Signed-off-by: Will Cohen --- hw/9pfs/9p-local.c | 4 ++-- include/qemu/osdep.h | 12 ++++++++++++ meson.build | 1 + os-posix.c | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index a0d08e5216..d42ce6d8b8 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -682,7 +682,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { - err = mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); + err = qemu_mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); if (err == -1) { goto out; } @@ -697,7 +697,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, } } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { - err = mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); + err = qemu_mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); if (err == -1) { goto out; } diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index ce12f64853..c0f442d791 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -818,6 +818,18 @@ static inline int platform_does_not_support_system(const char *command) */ struct dirent *qemu_dirent_dup(struct dirent *dent); +/* + * As long as mknodat is not available on macOS, this workaround + * using pthread_fchdir_np is needed. qemu_mknodat is defined in + * os-posix.c. pthread_fchdir_np is weakly linked here as a guard + * in case it disappears in future macOS versions, because it is + * is a private API. + */ +#if defined CONFIG_DARWIN && defined CONFIG_PTHREAD_FCHDIR_NP +int pthread_fchdir_np(int fd) __attribute__((weak_import)); +#endif +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev); + #ifdef __cplusplus } #endif diff --git a/meson.build b/meson.build index ae5f7eec6e..6fdc0281ad 100644 --- a/meson.build +++ b/meson.build @@ -1557,6 +1557,7 @@ config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate' config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign')) config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll')) config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include ')) +config_host_data.set('CONFIG_PTHREAD_FCHDIR_NP', cc.has_function('pthread_fchdir_np')) config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads)) config_host_data.set('CONFIG_SENDFILE', cc.has_function('sendfile')) config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_function('unshare')) diff --git a/os-posix.c b/os-posix.c index ae6c9f2a5e..ccc3d1e9d3 100644 --- a/os-posix.c +++ b/os-posix.c @@ -332,3 +332,38 @@ int os_mlock(void) return -ENOSYS; #endif } + +/* + * As long as mknodat is not available on macOS, this workaround + * using pthread_fchdir_np is needed. + * + * Radar filed with Apple for implementing mknodat: + * rdar://FB9862426 (https://openradar.appspot.com/FB9862426) + */ +#if defined CONFIG_DARWIN && defined CONFIG_PTHREAD_FCHDIR_NP + +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + int preserved_errno, err; + if (!pthread_fchdir_np) { + error_report_once("pthread_fchdir_np() is not available on this version of macOS"); + return -ENOTSUP; + } + if (pthread_fchdir_np(dirfd) < 0) { + return -1; + } + err = mknod(filename, mode, dev); + preserved_errno = errno; + /* Stop using the thread-local cwd */ + pthread_fchdir_np(-1); + if (err < 0) { + errno = preserved_errno; + } + return err; +} +#else +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + return mknodat(dirfd, filename, mode, dev); +} +#endif From patchwork Sun Feb 20 16:50:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12752776 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 241D2C433F5 for ; Sun, 20 Feb 2022 17:09:18 +0000 (UTC) Received: from localhost ([::1]:40792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLpi0-0000Ot-VW for qemu-devel@archiver.kernel.org; Sun, 20 Feb 2022 12:09:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLpQo-0007zs-77 for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:30 -0500 Received: from [2607:f8b0:4864:20::f2e] (port=36695 helo=mail-qv1-xf2e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nLpQm-0000Ef-9D for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:29 -0500 Received: by mail-qv1-xf2e.google.com with SMTP id o5so26105801qvm.3 for ; Sun, 20 Feb 2022 08:51:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sYK+uU7D+zXBtVgQvVfFVkY65lZgfTz3L/tbii2QHnA=; b=bt5fpsuLHvPkEmV74+n1rnjIdWcC42s/jHXEZmBcoxa5/R/AhyAHVFhH7VcDbeHM9j Lii81GwY36yOG7Hv+ZSr+P+4rqRQeEM0Hh75C5F6abBeqK7C1EuUEbXl6as1zUcDqgMG EbZFUZSquIQtEsI850d9cHr/JhnNqsj8d+xLbij7lAPPo72ebf3RC3BDZYwKDZZQ02RO RvB6G4t6fHoOl6zwd5IpK2GOhEZIySnD9aFsv8Va+rjeTbrWzzUylUvLLKM4rsyNMHEg 2635OQqqpMDUl5QJypqYuoqh1pd1sXlS+P17PDDML+IbNu0fXQi5D22Sn6zwvo/H5Vzl hsCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sYK+uU7D+zXBtVgQvVfFVkY65lZgfTz3L/tbii2QHnA=; b=i5Hu9XLSvBVec8aTO+h/9JhkKEteRLoA0RwAQ7FdnJCos+yNlbHh3I8QPUkXDGaOvJ HmF96uaVIsgAKSMVLJAajos09AcCf+XpCP4RCG2NYgN9qTX5SG3E96Lxno/J2lZ0Ja42 rBVVQHSzLJhXGLCuz0+ZDTcaWJpGJ7SvXp+ddnUY6symEvmRWUnAWHF+N78l5XBPQJ4g NiJWms7gO4PXqfCTDUFANh3ApQ0J0iWz6VzpVnJD0e4VGqk3N+forZMbMhMkZEB3Hym1 paML9cu4fw8g2eWDy0jSKkU2ly1kjHMrfnwnjPOZNZPHL4T+UNrbAWyWkvTXeUCzBsTp C/tw== X-Gm-Message-State: AOAM532ETkurp37LEQ3czehF2IgW1wjw5B1d233S7g16QXTMchUSorgr dkXZOmII7h6p3vFU+E6OOwTv71OYXEDtTg== X-Google-Smtp-Source: ABdhPJwyidtnmyicUvdtFm0OI1KIp9QJtMlshF0exy+LboWTc4SE9do0SddFjgXd2irWcECYeiZwhg== X-Received: by 2002:a05:6214:1bc5:b0:42c:4d35:37e2 with SMTP id m5-20020a0562141bc500b0042c4d3537e2mr12700138qvc.90.1645375887043; Sun, 20 Feb 2022 08:51:27 -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 n16sm3190995qkn.115.2022.02.20.08.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 08:51:25 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v8 10/11] 9p: darwin: Adjust assumption on virtio-9p-test Date: Sun, 20 Feb 2022 11:50:55 -0500 Message-Id: <20220220165056.72289-11-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220165056.72289-1-wwcohen@gmail.com> References: <20220220165056.72289-1-wwcohen@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f2e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2e; envelope-from=wwcohen@gmail.com; helo=mail-qv1-xf2e.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Fabian Franz , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Will Cohen , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The previous test depended on the assumption that P9_DOTL_AT_REMOVEDIR and AT_REMOVEDIR have the same value. While this is true on Linux, it is not true everywhere, and leads to an incorrect test failure on unlink_at, noticed when adding 9p to darwin: Received response 7 (RLERROR) instead of 77 (RUNLINKAT) Rlerror has errno 22 (Invalid argument) ** ERROR:../tests/qtest/virtio-9p-test.c:305:v9fs_req_recv: assertion failed (hdr.id == id): (7 == 77) Bail out! ERROR:../tests/qtest/virtio-9p-test.c:305:v9fs_req_recv: assertion failed (hdr.id == id): (7 == 77) Signed-off-by: Fabian Franz [Will Cohen: - Add explanation of patch and description of pre-patch test failure] Signed-off-by: Will Cohen Acked-by: Thomas Huth [Will Cohen: - Move this patch before 9p: darwin: meson patch to avoid qtest breakage during bisecting] Signed-off-by: Will Cohen Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 502e5ad0c7..01ca076afe 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -1253,7 +1253,7 @@ static void fs_unlinkat_dir(void *obj, void *data, QGuestAllocator *t_alloc) /* ... and is actually a directory */ g_assert((st.st_mode & S_IFMT) == S_IFDIR); - do_unlinkat(v9p, "/", "02", AT_REMOVEDIR); + do_unlinkat(v9p, "/", "02", P9_DOTL_AT_REMOVEDIR); /* directory should be gone now */ g_assert(stat(new_dir, &st) != 0); } From patchwork Sun Feb 20 16:50:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Cohen X-Patchwork-Id: 12752777 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 E9A19C433F5 for ; Sun, 20 Feb 2022 17:12:14 +0000 (UTC) Received: from localhost ([::1]:47070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLpks-0004eq-1G for qemu-devel@archiver.kernel.org; Sun, 20 Feb 2022 12:12:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLpQp-00083b-4u for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:31 -0500 Received: from [2607:f8b0:4864:20::f36] (port=41545 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 1nLpQn-0000GC-Gl for qemu-devel@nongnu.org; Sun, 20 Feb 2022 11:51:30 -0500 Received: by mail-qv1-xf36.google.com with SMTP id x3so26032966qvd.8 for ; Sun, 20 Feb 2022 08:51:29 -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=1lSNKYTys5WwwDCa2B5w8TNgxukwfhzsKmBg6dB6bbw=; b=lujAglyYZiiyZMlkQl4+ja5/Qn43Eou3nshJcbSEdGTLRInLWWiZb33Gho2lJCSrOM vh/h8Tg2RiqKI6XzNZUOJI+MekxFVkRXR7obSb03XutagXHNG6NimMRQMuPrschR5UYN B8lNzUJ1lnmUpdeBfJpB1Z2NBr9jJvRkkiw1eeyrrpun+KJuvLUhBdzEZ0Q97OuH4bg2 iXnlQnNTLQsUAtX0Q1M/yN4XsYR58vIy2YUtEEztOCA/0bs/pki3EhSkqgZ4ySlMVhSf Wva5OS3X2Oe/W3hsK3uCYwF2gGa9eOLxnKh+kynJL4uUpgi2cq3Kvh0nKh2NfvBc+yhj 7JMA== 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=1lSNKYTys5WwwDCa2B5w8TNgxukwfhzsKmBg6dB6bbw=; b=CaMINqQl5+Z4m4qAZrehjVAdlfuZuVUorE2v33Pt4MIFRrVABPY16ukucjfzbgXvp0 QMFOtGoJHReI+NrpgFtDFZA10O2fADGXXs6Psoe0JzSYBL6KwY0UMh1k540TUwy8sJtI qMQrCJt+p2xFuWA5FZOVjqkXfEZaU8tcHMSdp7wG9fKuiB78Eerf293+Ys2moWHSP9PA yVVUIq2rnIw+KlofuS3L1MMnNWR0kGfYHGv7wFES/DOGfOVGTIfPZwD97E8CfkDyOOyu wHx/2o2qXY1v0aws5bNQ/Iid+/cAOewKAOTaar+e8ktcQAKwWs1D82GYQsVL93piTxCz 0tkA== X-Gm-Message-State: AOAM5333PII4IYHNP2AP8vtEsO4Jrp8k23erJH0eDKQsh5pbF2VdPFr7 2g8DYOx4OnaGK+6S/jAIQuxKRnTNbz0/ag== X-Google-Smtp-Source: ABdhPJyHAf5WED5WpSRSO9K1HWaMs8sXqQZsfQd9uxWEGacaQDwSpDy22XPrUqtuRCRCDPZFl0Z9jg== X-Received: by 2002:ad4:5d69:0:b0:42d:dc3e:951d with SMTP id fn9-20020ad45d69000000b0042ddc3e951dmr12854653qvb.2.1645375888330; Sun, 20 Feb 2022 08:51:28 -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 n16sm3190995qkn.115.2022.02.20.08.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 08:51:27 -0800 (PST) From: Will Cohen To: qemu-devel@nongnu.org Subject: [PATCH v8 11/11] 9p: darwin: meson: Allow VirtFS on Darwin Date: Sun, 20 Feb 2022 11:50:56 -0500 Message-Id: <20220220165056.72289-12-wwcohen@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220165056.72289-1-wwcohen@gmail.com> References: <20220220165056.72289-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: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Christian Schoenebeck , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Greg Kurz , hi@alyssa.is, Michael Roitzsch , Will Cohen , Paolo Bonzini , Keno Fischer Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer To allow VirtFS on darwin, we need to check that pthread_fchdir_np is available, which has only been available since macOS 10.12. Additionally, virtfs_proxy_helper is disabled on Darwin. This patch series does not currently provide an implementation of the proxy-helper, but this functionality could be implemented later on. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Rebase to master] Signed-off-by: Will Cohen Reviewed-by: Paolo Bonzini [Will Cohen: - Add check for pthread_fchdir_np to virtfs - Add comments to patch commit - Note that virtfs_proxy_helper does not work on macOS - Fully adjust meson virtfs error note to specify macOS] Signed-off-by: Will Cohen --- fsdev/meson.build | 1 + meson.build | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fsdev/meson.build b/fsdev/meson.build index adf57cc43e..b632b66348 100644 --- a/fsdev/meson.build +++ b/fsdev/meson.build @@ -7,6 +7,7 @@ fsdev_ss.add(when: ['CONFIG_FSDEV_9P'], if_true: files( 'qemu-fsdev.c', ), if_false: files('qemu-fsdev-dummy.c')) softmmu_ss.add_all(when: 'CONFIG_LINUX', if_true: fsdev_ss) +softmmu_ss.add_all(when: 'CONFIG_DARWIN', if_true: fsdev_ss) if have_virtfs_proxy_helper executable('virtfs-proxy-helper', diff --git a/meson.build b/meson.build index 6fdc0281ad..b6f5c57487 100644 --- a/meson.build +++ b/meson.build @@ -1416,17 +1416,23 @@ if not get_option('dbus_display').disabled() endif endif -have_virtfs = (targetos == 'linux' and +if targetos == 'darwin' and cc.has_function('pthread_fchdir_np') + have_virtfs = have_system +else + have_virtfs = (targetos == 'linux' and have_system and libattr.found() and libcap_ng.found()) +endif -have_virtfs_proxy_helper = have_virtfs and have_tools +have_virtfs_proxy_helper = targetos != 'darwin' and have_virtfs and have_tools if get_option('virtfs').enabled() if not have_virtfs - if targetos != 'linux' - error('virtio-9p (virtfs) requires Linux') + if targetos != 'linux' and targetos != 'darwin' + error('virtio-9p (virtfs) requires Linux or macOS') + elif targetos == 'darwin' and not cc.has_function('pthread_fchdir_np') + error('virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') elif not libcap_ng.found() or not libattr.found() error('virtio-9p (virtfs) requires libcap-ng-devel and libattr-devel') elif not have_system