From patchwork Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771632 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 E216FC433F5 for ; Mon, 7 Mar 2022 12:02:12 +0000 (UTC) Received: from localhost ([::1]:47094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRC43-0006Wq-HN for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 07:02:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRBzY-0000iH-NU for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:57:32 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:34857) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRBzX-0004Q5-6i for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:57:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:References:In-Reply-To:Message-Id:Content-ID: Content-Description; bh=KO3uCcDtoP8ypvHqVZeogjqwQxCYF7uWlWLOucj+apQ=; b=CDT90 R1XMJyayWqWK9zOA+/nAsoQJ24iB5jJpi1HigtE+rL/zUtGxHqV79pqB3vUSMTLTM+4aQj41Fn9jC owuyKYiOOCS/iQvfqcdTPSzzWFLb8cadhgK/SHhsZjwy8p++v/VPnJFa7ZcdT+ktRQAtCFdCWvt4x En6Y/WR6mNZdGnAMh63qVrg8dmSJRxMCLgB/ywbTPHc0u2GqltDTdKmy+SRWGmXXQ4w0ANk0iymBn udtPmWbwAgBYxN1Ij97eSgF4lk4QnkdjpVCXQrXgIn1aD9EqDrR/xjYlNmpzaiOcggtL+npz1+Ook vJKXPb0q7B0V/LmLrTlpbFTHQmi9Q==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 01/19] 9p: linux: Fix a couple Linux assumptions MIME-Version: 1.0 To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=e0bd743bb2dd4985791d4de880446bdbb4e04fed@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , 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 Message-Id: <20220227223522.91937-2-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck --- 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 Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771631 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 EDC2FC433FE for ; Mon, 7 Mar 2022 12:00:06 +0000 (UTC) Received: from localhost ([::1]:43920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRC21-0004NT-S0 for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 07:00:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <6450084a66b6cf72b9126a8c8ecead7ddca896e9@lizzy.crudebyte.com>) id 1nRBpi-00008F-TX for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:47:23 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:35455) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <6450084a66b6cf72b9126a8c8ecead7ddca896e9@lizzy.crudebyte.com>) id 1nRBph-0002ln-8S for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:47:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Content-Transfer-Encoding:Content-Type: MIME-Version:Subject:Date:From:References:In-Reply-To:Message-Id:Content-ID: Content-Description; bh=5oLuXWTJKZvpRWIxoiPJFUVce5lljtpqW3n1BbXrpOw=; b=PBwzf 8gcOAjiPv2NQPgnzHKOgfbgnzLgN0gQR8RQxQIA4OaT613ZsocBi3IZlONHTXwi3HsJf5VPHuMso8 F0q8sXL8WihHkFy9S3T2K6pP4N7neM6rouplDjHuU0KpqsA6Ssgit76GSDiwRFradhEMKxH0HUyfR V1IF2bR1sxMmTUCfnroQ49ON+/dDVoqQ3hHBF3170N7uRu2QuRUPDYGw8ImguWVh7w1lBQqdrGdLv 6vXq8/0s7RsmkkClIh0wpLnvx0DI7eeUjmeeUguGsrA0jfvp2fmdej3aT/FLrO36oDExJE/pbmAr5 trwjcz4muOigw8hs0GSsQ6lfpaBgg==; Message-Id: <6450084a66b6cf72b9126a8c8ecead7ddca896e9.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 02/19] 9p: Rename 9p-util -> 9p-util-linux MIME-Version: 1.0 To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=6450084a66b6cf72b9126a8c8ecead7ddca896e9@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , 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é Message-Id: <20220227223522.91937-3-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck --- 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 Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771638 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 B7A57C433FE for ; Mon, 7 Mar 2022 12:06:43 +0000 (UTC) Received: from localhost ([::1]:52520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRC8Q-000292-GE for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 07:06:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRBUL-0005Ot-43 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:25:19 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:57653) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRBUC-00070d-PV for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:25:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=Q5FQJ2Reo2gOK3Lkjz7qs1014MSz8wpQlPECzV97A/A=; b=YdKgI PWP7bYzbszzc0rtInaHSXvZaoM/NAzZSTvuxQpL+6xFWyxMuCGi/U+anmbCYRTZSx3V49z/4jNs/K lnlUi09hQq79fsOXGrf45GHIgMSoTnxjITdNpRTla0V6U+FbURygWd2SnzLZvsWxTxE3h2UsYuAWN uxy0CneR+DWoqmGCx4YXy+nejfc3po3bJVtQeOz4SZRHXd3ZPI4O/XM9Z/wOx1G+nnD81hjN0968F Vq+pOFplQmQDezM2PlmIR1wjFjiaNmtNnie/5U9PCMBsNryQMS1mig1DU39kG6tywUZOWBQi9OvuI A9YDwwro+YHcRj2AaY1y0mxZJz5GQ==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 03/19] 9p: darwin: Handle struct stat(fs) differences To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=f41db099c71151291c269bf48ad006de9cbd9ca6@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , 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 Message-Id: <20220227223522.91937-4-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck Reviewed-by: Christian Schoenebeck --- 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 Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771610 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 DF95AC433EF for ; Mon, 7 Mar 2022 11:42:57 +0000 (UTC) Received: from localhost ([::1]:56854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRBlR-0000JO-0k for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 06:42:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <6b3b279bd670c6a2fa23c9049820c814f0e2c846@lizzy.crudebyte.com>) id 1nRBUY-0005Vh-Tn for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:25:32 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:45295) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <6b3b279bd670c6a2fa23c9049820c814f0e2c846@lizzy.crudebyte.com>) id 1nRBUK-00072i-Ti for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:25:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=3u34sir+ZeZHfQZGfZ8IvSlB23QK/T53fLss006PEqs=; b=MSt1j gf2zWnFbIQkw3hgZ2KcfRMed14z6Dij7qzu4/GbmrO2rDjezNv1xTDXK63C+Il9Ee7Chuk1TDfhxX Nezf734zhusFkwoSYlFa6dAFrgajmqhGb+WiaCTTYhuuX+G9VPbyh3tyLhUFeC2n2LwMwy1Mng0CM ncj8U866UrsAkR4FqNth77/4o6HdbGEttkmggB+RZYN0R71V3fP775HbMfzruxl9/yn6O7HPiQG8d AYRSs1NYo0YLfRMwuenbt4TYY8aCVxsRohu39py+OXOqABWNr16S2FE7U1DXKtfJ/qZPnfRUsKyy9 M1x1Gax1816SiBdcPL5mKx5NMe0sg==; Message-Id: <6b3b279bd670c6a2fa23c9049820c814f0e2c846.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 04/19] 9p: darwin: Handle struct dirent differences To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=6b3b279bd670c6a2fa23c9049820c814f0e2c846@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer On darwin d_seekoff exists, but is optional and does not seem to be commonly used by file systems. Use `telldir` instead to obtain the seek offset and inject it into d_seekoff, and create a qemu_dirent_off helper to call it appropriately when appropriate. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Adjust to pass testing - Ensure that d_seekoff is filled using telldir on darwin, and create qemu_dirent_off helper to decide which to access] [Fabian Franz: - Add telldir error handling for darwin] Signed-off-by: Fabian Franz [Will Cohen: - Ensure that telldir error handling uses signed int - Cleanup of telldir error handling - Remove superfluous error handling for qemu_dirent_off - Adjust formatting - Use qemu_dirent_off in codir.c - Declare qemu_dirent_off as static to prevent linker error - Move qemu_dirent_off above the end-of-file endif to fix compilation] Signed-off-by: Will Cohen Message-Id: <20220227223522.91937-5-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck Reviewed-by: Christian Schoenebeck --- hw/9pfs/9p-local.c | 9 +++++++++ hw/9pfs/9p-proxy.c | 16 +++++++++++++++- hw/9pfs/9p-synth.c | 4 ++++ hw/9pfs/9p-util.h | 16 ++++++++++++++++ hw/9pfs/9p.c | 7 +++++-- hw/9pfs/codir.c | 4 +++- 6 files changed, 52 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 1a5e3eed73..f3272f0b43 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -562,6 +562,15 @@ again: if (!entry) { return NULL; } +#ifdef CONFIG_DARWIN + int off; + off = telldir(fs->dir.stream); + /* If telldir fails, fail the entire readdir call */ + if (off < 0) { + return NULL; + } + entry->d_seekoff = off; +#endif if (ctx->export_flags & V9FS_SM_MAPPED) { entry->d_type = DT_UNKNOWN; diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index b1664080d8..8b4b5cf7dc 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -706,7 +706,21 @@ static off_t proxy_telldir(FsContext *ctx, V9fsFidOpenState *fs) static struct dirent *proxy_readdir(FsContext *ctx, V9fsFidOpenState *fs) { - return readdir(fs->dir.stream); + struct dirent *entry; + entry = readdir(fs->dir.stream); +#ifdef CONFIG_DARWIN + if (!entry) { + return NULL; + } + int td; + td = telldir(fs->dir.stream); + /* If telldir fails, fail the entire readdir call */ + if (td < 0) { + return NULL; + } + entry->d_seekoff = td; +#endif + return entry; } static void proxy_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index bf9b0c5ddd..b3080e415b 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -234,7 +234,11 @@ static void synth_direntry(V9fsSynthNode *node, offsetof(struct dirent, d_name) + sz); memcpy(entry->d_name, node->name, sz); entry->d_ino = node->attr->inode; +#ifdef CONFIG_DARWIN + entry->d_seekoff = off + 1; +#else entry->d_off = off + 1; +#endif } static struct dirent *synth_get_dentry(V9fsSynthNode *dir, diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 546f46dc7d..7449733c15 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -78,4 +78,20 @@ ssize_t flistxattrat_nofollow(int dirfd, const char *filename, ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, const char *name); +/** + * Darwin has d_seekoff, which appears to function similarly to d_off. + * However, it does not appear to be supported on all file systems, + * so ensure it is manually injected earlier and call here when + * needed. + */ +static inline off_t qemu_dirent_off(struct dirent *dent) +{ +#ifdef CONFIG_DARWIN + return dent->d_seekoff; +#else + return dent->d_off; +#endif +} + + #endif diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 1563d7b7c6..caf3b240fe 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -27,6 +27,7 @@ #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" #include "9p-xattr.h" +#include "9p-util.h" #include "coth.h" #include "trace.h" #include "migration/blocker.h" @@ -2281,7 +2282,7 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu, count += len; v9fs_stat_free(&v9stat); v9fs_path_free(&path); - saved_dir_pos = dent->d_off; + saved_dir_pos = qemu_dirent_off(dent); } v9fs_readdir_unlock(&fidp->fs.dir); @@ -2420,6 +2421,7 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, V9fsString name; int len, err = 0; int32_t count = 0; + off_t off; struct dirent *dent; struct stat *st; struct V9fsDirEnt *entries = NULL; @@ -2480,12 +2482,13 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, qid.version = 0; } + off = qemu_dirent_off(dent); v9fs_string_init(&name); v9fs_string_sprintf(&name, "%s", dent->d_name); /* 11 = 7 + 4 (7 = start offset, 4 = space for storing count) */ len = pdu_marshal(pdu, 11 + count, "Qqbs", - &qid, dent->d_off, + &qid, off, dent->d_type, &name); v9fs_string_free(&name); diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c index c0873bde16..f96d8ac4e6 100644 --- a/hw/9pfs/codir.c +++ b/hw/9pfs/codir.c @@ -22,6 +22,8 @@ #include "qemu/coroutine.h" #include "qemu/main-loop.h" #include "coth.h" +#include "9p-xattr.h" +#include "9p-util.h" /* * Intended to be called from bottom-half (e.g. background I/O thread) @@ -166,7 +168,7 @@ static int do_readdir_many(V9fsPDU *pdu, V9fsFidState *fidp, } size += len; - saved_dir_pos = dent->d_off; + saved_dir_pos = qemu_dirent_off(dent); } /* restore (last) saved position */ From patchwork Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771640 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 C75FCC433F5 for ; Mon, 7 Mar 2022 12:08:56 +0000 (UTC) Received: from localhost ([::1]:60918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRCAZ-0007wc-Rk for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 07:08:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <67a71e3b71a2834d028031a92e76eb9444e423c6@lizzy.crudebyte.com>) id 1nRBUa-0005Wj-Uv for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:25:33 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:48867) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <67a71e3b71a2834d028031a92e76eb9444e423c6@lizzy.crudebyte.com>) id 1nRBUT-000752-SU for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:25:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=gEkMfmU/1Fn/SSfM8FnRnK2abQo4v0plT/myHJeapCw=; b=CQ+gL Oj2EYTNMoUVD9Z8mfWDlznIDBjpXbBc7k04sD3Iu9q3Ym0uXI3+RT6xnZZW0jJGC5EtHEGEvUPRfA cPPhI+SHjKWA9StZWuDO0ziuBFt6030RsIH1eM1kJBzrdE44vVQ/8jjZ/D9NxrIcjU+Qa0pm/FtJR 2aZCpCdJ2IcTumtTLLf1FdNZdDHvR3CUMuG53SNRJhG0iC1E3UJFy5P6IHT2f4RhqKDxAjKRkQpfX 1BdX9OTMmByiC8ncbehztRJOLmXaUDHus+/jzPTcAnO8Fq46Go8FqQqp1/RTmjwHyFoK29IIBnLhl GEJxogLitK/aS9004irPyuAyFP8Iw==; Message-Id: <67a71e3b71a2834d028031a92e76eb9444e423c6.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 05/19] 9p: darwin: Ignore O_{NOATIME, DIRECT} To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=67a71e3b71a2834d028031a92e76eb9444e423c6@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , 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 Message-Id: <20220227223522.91937-6-wwcohen@gmail.com> [C.S.: - Fix compiler warning "unused label 'again'". ] Link: https://lore.kernel.org/qemu-devel/11201492.CjeqJxXfGd@silver/ Signed-off-by: Christian Schoenebeck Reviewed-by: Christian Schoenebeck --- hw/9pfs/9p-util.h | 4 ++++ hw/9pfs/9p.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 7449733c15..a48da32f04 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -37,10 +37,13 @@ static inline int openat_file(int dirfd, const char *name, int flags, { int fd, serrno, ret; +#ifndef CONFIG_DARWIN again: +#endif 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 +56,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 Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771597 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 00D75C433F5 for ; Mon, 7 Mar 2022 11:35:48 +0000 (UTC) Received: from localhost ([::1]:37648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRBeW-00046k-2J for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 06:35:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <38d7fd68b0c8775b5253ab84367419621aa032e6@lizzy.crudebyte.com>) id 1nRBUd-0005Y1-3V for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:25:37 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:41381) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <38d7fd68b0c8775b5253ab84367419621aa032e6@lizzy.crudebyte.com>) id 1nRBUY-000761-R6 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:25:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=E9U8f+CE/a5/AN3TPLs6/9FG2x5Jkw+GdC7Z0ig5vNY=; b=TieuR 9Hnh238l020bjL+vqLWJvES9vM2rM1NT9J2E6fctWAkLawfEyltvQxGATGMTI4/HD3FScFP72KOPo v4EGKrMldRZzUbHc13cX+YG02Iuzxk63Yt0+8UGTKz/f54Kg0lanlHFPS7IHJkOkm8drkfcnVq1P5 ZeIhYy0LQ0DJ/bMbHBi0V1c0cAAiqyzt9MS8Joe0HCelqvVHafm+9wKFfHXv7qSFzTFu7z6JMxQzY A1JJk5FUsPqGqe8aQyiapIu4a2xFdvx7nJ7atRbEQT5SJHTaH1GKH1n3ahxAcFThFASrAp+Djab8I 9toQaAaz6xze8nBQ8g8OAma55mhTw==; Message-Id: <38d7fd68b0c8775b5253ab84367419621aa032e6.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 06/19] 9p: darwin: Move XATTR_SIZE_MAX->P9_XATTR_SIZE_MAX To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=38d7fd68b0c8775b5253ab84367419621aa032e6@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , 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 Message-Id: <20220227223522.91937-7-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck Reviewed-by: Christian Schoenebeck --- 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 Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771622 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 98D1CC433F5 for ; Mon, 7 Mar 2022 11:58:04 +0000 (UTC) Received: from localhost ([::1]:38188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRC03-0000aU-Ir for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 06:58:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <57b3910bc3513ab515296692daafd1c546f3c115@lizzy.crudebyte.com>) id 1nRByU-0006Bx-6Q for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:56:26 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:54591) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <57b3910bc3513ab515296692daafd1c546f3c115@lizzy.crudebyte.com>) id 1nRByS-0004Im-L0 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:56:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=89Gbgq/kest9e+BQG9UtS5uVE2I3QP9MTMPZSp2J16Y=; b=XB3b1 p6bpOwAu2A5dBE6PQF+EJYKUmPtYaWyuoyzGyMKn3KZNZfVpzbqOQRw0gNO8zw0Dul4HqnctZhBlz APAHQ9H5ppu+EJy/b6x9dQnKvLP3J46xCUcxF7js2M9q8x4fXkfqyfhea2Rja9wBX9XUN2G1KQB+a oIvSwfQqzjUPsnCEp++gvCY+av39WyjlRt0dcVDxfSB+MqV6avhu65HFuLZdDmB5gdeIF3UqLaUro lEoyDy5Fx6dP4XP9RSWiexdUMLzegJnlQl0VYCVRt7RGxUtOHCymmUXcnJqRJCSWu9bztGb1NYeC7 Zio3borJ6rtcXv2bVZjdRQ8Qwsjjg==; Message-Id: <57b3910bc3513ab515296692daafd1c546f3c115.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 07/19] 9p: darwin: *xattr_nofollow implementations To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=57b3910bc3513ab515296692daafd1c546f3c115@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , 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 Message-Id: <20220227223522.91937-8-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck Acked-by: Christian Schoenebeck --- 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 Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771683 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 141B2C433F5 for ; Mon, 7 Mar 2022 12:20:28 +0000 (UTC) Received: from localhost ([::1]:59688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRCLk-0001V6-0x for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 07:20:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRBtB-0005bL-J7 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:50:57 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:56571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRBt6-00039N-Gm for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:50:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=yCG8mfUuZb4ASX+9n9SbWhBnUD8nd9nbfeLYRBwUpm4=; b=Tvc// xwWBQf9iC5eXcTYiTyIlWVXpuE8POh9ruRgj5RNMNkq5GFvD+oSartctghNvzXnyCILhRG+YZ7UKa LjbFMr+IKaHo6ZVxDMBqpwEd93ZxUZYhq1l5q5wwEWWjLl+uqE6TXctK9ZYvXtNtqFBJRt7qPuAor ujDeBLeTRg/qh23MFzx3QjSVsf7muy+Dd6+4Dlgcdg0w2h0wYcDYfTaT/22zivHmAXktmwNcbC4jm U3MEAaFajLtORlN3nJhiEQaW/r5qT+mRnVE8J5GeJqqOskv2Rqg+/Lu/xebsJdxe7XolDxEjLofnm 5um57UJwtNJEdVn+7VHCWnRdai1DA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 08/19] 9p: darwin: Compatibility for f/l*xattr To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=b5989326f558faedd2511f29459112cced2ca8f5@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , 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 Message-Id: <20220227223522.91937-9-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck Acked-by: Christian Schoenebeck --- 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 a48da32f04..be8dc1a43a 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 Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771684 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 34BBCC433EF for ; Mon, 7 Mar 2022 12:22:42 +0000 (UTC) Received: from localhost ([::1]:35124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRCNt-00045x-Bq for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 07:22:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <029ed1bd9defa33a80bb40cdcd003699299af8db@lizzy.crudebyte.com>) id 1nRCHg-0002jm-Kr for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:16:16 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:34619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <029ed1bd9defa33a80bb40cdcd003699299af8db@lizzy.crudebyte.com>) id 1nRCHe-0007a4-M1 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:16:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=MSuNWzMRc8KYD7UTwnKgKBQ7UJltx57Fx3duo5Tg36A=; b=Kj7oB 1tRxT9Zo6AAF4fYBINqvDSn26D1XbsrMGDDBLUQvsAMkvQiEoTp4W+QQ4FOKRaN3jQFUfJN38mII3 jubsI+LEw6ppdK7DpXE08PRnzdlbpXH+L6e1Kkkt4L1vcscWw2IVm4gxJT97kgTHcMV0VD0ydWSIM uGNyn2xDvZlNnaXHnOUaN1Ub9QqT6watpdqff0BSVlas07iN7Hucn5PewTl6DgLK2xf/SOeKCBgMk KKCYWXW8iqPiXUS4etEkd8YeEvzoH1RELt9Cs05x0hz/1jydxY14rRWneEDye4HRa19gz8AGh5KUV MO+lg/6sXGmlLVUH0DxNagd9OMjRg==; Message-Id: <029ed1bd9defa33a80bb40cdcd003699299af8db.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 09/19] 9p: darwin: Implement compatibility for mknodat To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=029ed1bd9defa33a80bb40cdcd003699299af8db@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer Darwin does not support mknodat. However, to avoid race conditions with later setting the permissions, we must avoid using mknod on the full path instead. We could try to fchdir, but that would cause problems if multiple threads try to call mknodat at the same time. However, luckily there is a solution: Darwin includes a function that sets the cwd for the current thread only. This should suffice to use mknod safely. This function (pthread_fchdir_np) is protected by a check in meson in a patch later in this series. Signed-off-by: Keno Fischer Signed-off-by: Michael Roitzsch [Will Cohen: - Adjust coding style - Replace clang references with gcc - Note radar filed with Apple for missing syscall - Replace direct syscall with pthread_fchdir_np and adjust patch notes accordingly - Declare pthread_fchdir_np with - __attribute__((weak_import)) to allow checking for its presence before usage - Move declarations above cplusplus guard - Add CONFIG_PTHREAD_FCHDIR_NP to meson and check for presence in 9p-util - Rebase to apply cleanly on top of the 2022-02-10 changes to 9pfs - Fix line over 90 characters formatting error] Signed-off-by: Will Cohen Message-Id: <20220227223522.91937-10-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck Reviewed-by: Christian Schoenebeck --- hw/9pfs/9p-local.c | 4 ++-- hw/9pfs/9p-util-darwin.c | 33 +++++++++++++++++++++++++++++++++ hw/9pfs/9p-util-linux.c | 6 ++++++ hw/9pfs/9p-util.h | 11 +++++++++++ meson.build | 1 + 5 files changed, 53 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index a0d08e5216..d42ce6d8b8 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -682,7 +682,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, if (fs_ctx->export_flags & V9FS_SM_MAPPED || fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { - err = mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); + err = qemu_mknodat(dirfd, name, fs_ctx->fmode | S_IFREG, 0); if (err == -1) { goto out; } @@ -697,7 +697,7 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath *dir_path, } } else if (fs_ctx->export_flags & V9FS_SM_PASSTHROUGH || fs_ctx->export_flags & V9FS_SM_NONE) { - err = mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); + err = qemu_mknodat(dirfd, name, credp->fc_mode, credp->fc_rdev); if (err == -1) { goto out; } diff --git a/hw/9pfs/9p-util-darwin.c b/hw/9pfs/9p-util-darwin.c index cdb4c9e24c..bec0253474 100644 --- a/hw/9pfs/9p-util-darwin.c +++ b/hw/9pfs/9p-util-darwin.c @@ -7,6 +7,8 @@ #include "qemu/osdep.h" #include "qemu/xattr.h" +#include "qapi/error.h" +#include "qemu/error-report.h" #include "9p-util.h" ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name, @@ -62,3 +64,34 @@ int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, close_preserve_errno(fd); return ret; } + +/* + * As long as mknodat is not available on macOS, this workaround + * using pthread_fchdir_np is needed. + * + * Radar filed with Apple for implementing mknodat: + * rdar://FB9862426 (https://openradar.appspot.com/FB9862426) + */ +#if defined CONFIG_PTHREAD_FCHDIR_NP + +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + int preserved_errno, err; + if (!pthread_fchdir_np) { + error_report_once("pthread_fchdir_np() not available on this version of macOS"); + return -ENOTSUP; + } + if (pthread_fchdir_np(dirfd) < 0) { + return -1; + } + err = mknod(filename, mode, dev); + preserved_errno = errno; + /* Stop using the thread-local cwd */ + pthread_fchdir_np(-1); + if (err < 0) { + errno = preserved_errno; + } + return err; +} + +#endif diff --git a/hw/9pfs/9p-util-linux.c b/hw/9pfs/9p-util-linux.c index 398614a5d0..db451b0784 100644 --- a/hw/9pfs/9p-util-linux.c +++ b/hw/9pfs/9p-util-linux.c @@ -61,4 +61,10 @@ int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, ret = lsetxattr(proc_path, name, value, size, flags); g_free(proc_path); return ret; + +} + +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev) +{ + return mknodat(dirfd, filename, mode, dev); } diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index be8dc1a43a..73b08c5561 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -114,5 +114,16 @@ static inline off_t qemu_dirent_off(struct dirent *dent) #endif } +/* + * As long as mknodat is not available on macOS, this workaround + * using pthread_fchdir_np is needed. qemu_mknodat is defined in + * os-posix.c. pthread_fchdir_np is weakly linked here as a guard + * in case it disappears in future macOS versions, because it is + * is a private API. + */ +#if defined CONFIG_DARWIN && defined CONFIG_PTHREAD_FCHDIR_NP +int pthread_fchdir_np(int fd) __attribute__((weak_import)); +#endif +int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev); #endif diff --git a/meson.build b/meson.build index 038502714a..40598630e6 100644 --- a/meson.build +++ b/meson.build @@ -1622,6 +1622,7 @@ config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate' config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign')) config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll')) config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include ')) +config_host_data.set('CONFIG_PTHREAD_FCHDIR_NP', cc.has_function('pthread_fchdir_np')) config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads)) config_host_data.set('CONFIG_SENDFILE', cc.has_function('sendfile')) config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_function('unshare')) From patchwork Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771822 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 7809DC433F5 for ; Mon, 7 Mar 2022 13:04:18 +0000 (UTC) Received: from localhost ([::1]:49416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRD29-0002U0-Fr for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 08:04:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRCGe-000174-29 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:15:12 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:34619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRCGc-0007a4-5E for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:15:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=yKS8v7D5O2e+Blqy1u72eKRpQqfklC5OzihiNL/eqwU=; b=K0Tf2 xJWKJ63wYH0w8sAad6vlqIP7L8OzX7nmkL6VmH4oA0zYA+YdexvNo2VQLDoXiTyLUKko4LqxfZUwa N12RiMpSJ1OpfCJ26uiNha1/+jMG3FT8nl/Kg83AfPvfboX5ghkauOlD3GWTwz2qplL+5Jbq5Kipu YuAxW333uzm5UFpYlglN8WpPXMBtie5/UNXGLyadk5j31XW9Tj+GO1870GhgfjeDyN5HcNKA2YjfH d5a3aQqHNdVQknU0eO2ERvA4CSqgTXoyhS1/K4rI/GrwZ8nW23yK9uxBKM/EwnLH3f5MZHv9LPe42 voMf/erklSLj990B2F6F55V5cFvhA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 10/19] 9p: darwin: Adjust assumption on virtio-9p-test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=d3671fd972cd185a6923433aa4802f54d8b62112@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Will Cohen 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 Message-Id: <20220227223522.91937-11-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck --- 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 Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771722 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 7CAEDC433F5 for ; Mon, 7 Mar 2022 12:29:20 +0000 (UTC) Received: from localhost ([::1]:59048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRCUJ-0003J8-LV for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 07:29:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <0fb1e19d78536e23b650ca72decdc29c98f2dcc1@lizzy.crudebyte.com>) id 1nRCFb-0008S2-AH for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:14:07 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:34619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <0fb1e19d78536e23b650ca72decdc29c98f2dcc1@lizzy.crudebyte.com>) id 1nRCFZ-0007a4-Gv for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:14:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=InoFH/i7Y64UnxSHU/aQSNBQnxBKbIBG0d1DlNHVBsc=; b=Wve5b wwKIrY5pk3BXCdgohdKVOVZwixvN8E9S0Y5Dxk3rwfROYzoSxVDE1r/Nt3OMZvw5o34UoAVT37iRg kMM0AWmfylmsqydNPKoh8wJZU5P8tyLGkV//X96mDrD8K0obo6Wa1kLdzUDje3pK5C7Vs0TQJn/BC g39pddvu6pJ+Q48rO2NxgkTo34UxzQNgmS8rSF7vxQNC1ffvRmY0phbGK7kNFVPqfmU3JIIQsODY5 yssB/MDD0u4eRxcSh5sJW5FLtjmNM0dZxjoYzpB3/aH3ULXfphNVkMJgM5KJJhg1CtWfX8QzjSebM Cay/qwu6Kmd4gAeP7hh6/ZMOvEy2g==; Message-Id: <0fb1e19d78536e23b650ca72decdc29c98f2dcc1.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 11/19] 9p: darwin: meson: Allow VirtFS on Darwin To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=0fb1e19d78536e23b650ca72decdc29c98f2dcc1@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Keno Fischer To allow VirtFS on darwin, we need to check that pthread_fchdir_np is available, which has only been available since macOS 10.12. Additionally, virtfs_proxy_helper is disabled on Darwin. This patch series does not currently provide an implementation of the proxy-helper, but this functionality could be implemented later on. Signed-off-by: Keno Fischer [Michael Roitzsch: - Rebase for NixOS] Signed-off-by: Michael Roitzsch [Will Cohen: - Rebase to master] Signed-off-by: Will Cohen Reviewed-by: Paolo Bonzini [Will Cohen: - Add check for pthread_fchdir_np to virtfs - Add comments to patch commit - Note that virtfs_proxy_helper does not work on macOS - Fully adjust meson virtfs error note to specify macOS - Rebase to master] Signed-off-by: Will Cohen Message-Id: <20220227223522.91937-12-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck Acked-by: Christian Schoenebeck --- fsdev/meson.build | 1 + meson.build | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fsdev/meson.build b/fsdev/meson.build index adf57cc43e..b632b66348 100644 --- a/fsdev/meson.build +++ b/fsdev/meson.build @@ -7,6 +7,7 @@ fsdev_ss.add(when: ['CONFIG_FSDEV_9P'], if_true: files( 'qemu-fsdev.c', ), if_false: files('qemu-fsdev-dummy.c')) softmmu_ss.add_all(when: 'CONFIG_LINUX', if_true: fsdev_ss) +softmmu_ss.add_all(when: 'CONFIG_DARWIN', if_true: fsdev_ss) if have_virtfs_proxy_helper executable('virtfs-proxy-helper', diff --git a/meson.build b/meson.build index 40598630e6..8a50ec191f 100644 --- a/meson.build +++ b/meson.build @@ -1462,14 +1462,16 @@ dbus_display = get_option('dbus_display') \ .allowed() have_virtfs = get_option('virtfs') \ - .require(targetos == 'linux', - error_message: 'virtio-9p (virtfs) requires Linux') \ - .require(libattr.found() and libcap_ng.found(), - error_message: 'virtio-9p (virtfs) requires libcap-ng-devel and libattr-devel') \ + .require(targetos == 'linux' or targetos == 'darwin', + error_message: 'virtio-9p (virtfs) requires Linux or macOS') \ + .require(targetos == 'linux' or cc.has_function('pthread_fchdir_np'), + error_message: 'virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') \ + .require(targetos == 'darwin' or (libattr.found() and libcap_ng.found()), + error_message: 'virtio-9p (virtfs) on Linux requires libcap-ng-devel and libattr-devel') \ .disable_auto_if(not have_tools and not have_system) \ .allowed() -have_virtfs_proxy_helper = have_virtfs and have_tools +have_virtfs_proxy_helper = targetos != 'darwin' and have_virtfs and have_tools foreach k : get_option('trace_backends') config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true) From patchwork Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771823 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 9F7FBC433EF for ; Mon, 7 Mar 2022 13:08:27 +0000 (UTC) Received: from localhost ([::1]:54208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRD6A-00067B-1M for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 08:08:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1983d8b0d6b013f025905c7d37e3f0261edc328b@lizzy.crudebyte.com>) id 1nRCgq-0000rI-GI for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:42:19 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:47275) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1983d8b0d6b013f025905c7d37e3f0261edc328b@lizzy.crudebyte.com>) id 1nRCga-0004DK-BP for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:42:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=m3rxyJIWUSZsunwAVPLXFSOKT6ApHv/hF1xLM+mgQMU=; b=c+zU1 RBYqDRDhiX5cB1m/b7e+ZvHAjkJuEGGiNKHaz13PceIVMzCIdzU+WzuH0XxtMpi1bKu+tQTPXdyID 408fMeSL7BJidM2eCHfhDUoMXarAkDNT/ugQqHjqDEmd5T7JxAhRrRpVxjssiIodWOYxAQWOqF+uV 5ntn8UfEJIXHuk/Ti0hH3fntdPKMYQiZe3PHI8C9iJOnvA1WScTOx0i8dP11y1XjTO7r4aPJ87xPY KQ3EfCx8SURqtviHbGD8jkPg+lC3GhdTqOntu1GqQcr5LS7AgQKT/esgTvh0C27C+a2xuixZqxcL/ JBUO20ngqRGhC8hUgLHW4NMT2DsWg==; Message-Id: <1983d8b0d6b013f025905c7d37e3f0261edc328b.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 12/19] 9pfs: move qemu_dirent_dup() from osdep -> 9p-util To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=1983d8b0d6b013f025905c7d37e3f0261edc328b@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Function qemu_dirent_dup() is currently only used by 9pfs server, so move it from project global header osdep.h to 9pfs specific header 9p-util.h. Link: https://lore.kernel.org/qemu-devel/CAFEAcA_=HAUNomKD2wurSVaAHa5mrk22A1oHKLWUDjk7v6Khmg@mail.gmail.com/ Based-on: <20220227223522.91937-12-wwcohen@gmail.com> Signed-off-by: Christian Schoenebeck Reviewed-by: Peter Maydell Message-Id: --- hw/9pfs/9p-util.h | 30 ++++++++++++++++++++++++++++++ include/qemu/osdep.h | 13 ------------- util/osdep.c | 21 --------------------- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 73b08c5561..408d71c8f7 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -114,6 +114,36 @@ static inline off_t qemu_dirent_off(struct dirent *dent) #endif } +/** + * Duplicate directory entry @dent. + * + * It is highly recommended to use this function instead of open coding + * duplication of @c dirent objects, because the actual @c struct @c dirent + * size may be bigger or shorter than @c sizeof(struct dirent) and correct + * handling is platform specific (see gitlab issue #841). + * + * @dent - original directory entry to be duplicated + * @returns duplicated directory entry which should be freed with g_free() + */ +static inline struct dirent *qemu_dirent_dup(struct dirent *dent) +{ + size_t sz = 0; +#if defined _DIRENT_HAVE_D_RECLEN + /* Avoid use of strlen() if platform supports d_reclen. */ + sz = dent->d_reclen; +#endif + /* + * Test sz for zero even if d_reclen is available + * because some drivers may set d_reclen to zero. + */ + if (sz == 0) { + /* Fallback to the most portable way. */ + sz = offsetof(struct dirent, d_name) + + strlen(dent->d_name) + 1; + } + return g_memdup(dent, sz); +} + /* * As long as mknodat is not available on macOS, this workaround * using pthread_fchdir_np is needed. qemu_mknodat is defined in diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 7bcce3bceb..650ba1aa50 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -673,19 +673,6 @@ static inline int platform_does_not_support_system(const char *command) } #endif /* !HAVE_SYSTEM_FUNCTION */ -/** - * Duplicate directory entry @dent. - * - * It is highly recommended to use this function instead of open coding - * duplication of @c dirent objects, because the actual @c struct @c dirent - * size may be bigger or shorter than @c sizeof(struct dirent) and correct - * handling is platform specific (see gitlab issue #841). - * - * @dent - original directory entry to be duplicated - * @returns duplicated directory entry which should be freed with g_free() - */ -struct dirent *qemu_dirent_dup(struct dirent *dent); - #ifdef __cplusplus } #endif diff --git a/util/osdep.c b/util/osdep.c index 723cdcb004..7c4deda6fe 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -33,7 +33,6 @@ extern int madvise(char *, size_t, int); #endif -#include #include "qemu-common.h" #include "qemu/cutils.h" #include "qemu/sockets.h" @@ -619,23 +618,3 @@ writev(int fd, const struct iovec *iov, int iov_cnt) return readv_writev(fd, iov, iov_cnt, true); } #endif - -struct dirent * -qemu_dirent_dup(struct dirent *dent) -{ - size_t sz = 0; -#if defined _DIRENT_HAVE_D_RECLEN - /* Avoid use of strlen() if platform supports d_reclen. */ - sz = dent->d_reclen; -#endif - /* - * Test sz for zero even if d_reclen is available - * because some drivers may set d_reclen to zero. - */ - if (sz == 0) { - /* Fallback to the most portable way. */ - sz = offsetof(struct dirent, d_name) + - strlen(dent->d_name) + 1; - } - return g_memdup(dent, sz); -} From patchwork Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771814 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 F2D81C433FE for ; Mon, 7 Mar 2022 12:59:33 +0000 (UTC) Received: from localhost ([::1]:44368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRCxY-0007I4-Qc for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 07:59:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <63ce31c35da18f9dbd9b7dbea5b6e1d2b85deb24@lizzy.crudebyte.com>) id 1nRCDU-0004Ou-D2 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:11:56 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:33469) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <63ce31c35da18f9dbd9b7dbea5b6e1d2b85deb24@lizzy.crudebyte.com>) id 1nRCDR-0006fX-MW for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:11:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=DrohWPsFuDZVi2PkDVvJ6WDmj/4RKl9cI6t4GNGbvL8=; b=GfmZ7 Q9smAVLH7lQoGuzliztzOLGCd2CEeXbq8ALp9OBnyUXLm8oSAUKDGJZ18zc9lfnKhTbFImroybvov Y1l1FygFU8p/iJsdJE7Qsr0jY96A5pQLk6rsw57yxVXCUhCAAfRFs/cFkr3gSNkx42GzlMfeicVCP 0CiJi2PtHeQNNcuGrBRZV0eCIfyL+J5FjqFCPMeehkCluC1Dkgn3oJbGbtNCqPZ6VZqPYrvMFv2Aq +96CXuaIG1NaVFE4ytWyyOai3LEH0fxCe8lgRCuz3kv+qf7t702n9LtnbGJXHc1N1STJ5/Mjmlr+n SB9Zyi0MkaVbcMYWXYL6fhpO1NlQg==; Message-Id: <63ce31c35da18f9dbd9b7dbea5b6e1d2b85deb24.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 13/19] 9pfs: drop Doxygen format from qemu_dirent_dup() API comment To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=63ce31c35da18f9dbd9b7dbea5b6e1d2b85deb24@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" API doc comments in QEMU are supposed to be in kerneldoc format, so drop occurrences of "@c" which is Doxygen format for fixed-width text. Link: https://lore.kernel.org/qemu-devel/CAFEAcA89+ENOM6x19OEF53Kd2DWkhN5SN21Va0D7yepJSa3Jyg@mail.gmail.com/ Based-on: Signed-off-by: Christian Schoenebeck Reviewed-by: Peter Maydell Reviewed-by: Greg Kurz Message-Id: --- hw/9pfs/9p-util.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 408d71c8f7..d0de6be3e2 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -118,8 +118,8 @@ static inline off_t qemu_dirent_off(struct dirent *dent) * Duplicate directory entry @dent. * * It is highly recommended to use this function instead of open coding - * duplication of @c dirent objects, because the actual @c struct @c dirent - * size may be bigger or shorter than @c sizeof(struct dirent) and correct + * duplication of dirent objects, because the actual struct dirent + * size may be bigger or shorter than sizeof(struct dirent) and correct * handling is platform specific (see gitlab issue #841). * * @dent - original directory entry to be duplicated From patchwork Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771788 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 19190C433F5 for ; Mon, 7 Mar 2022 12:52:02 +0000 (UTC) Received: from localhost ([::1]:56256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRCqG-0004ga-V3 for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 07:52:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <39db33471909f8ab083e1a079eeae6975b55df13@lizzy.crudebyte.com>) id 1nRCfW-0000My-03 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:41:01 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:52063) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <39db33471909f8ab083e1a079eeae6975b55df13@lizzy.crudebyte.com>) id 1nRCfS-0003mu-Eg for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:40:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=xcMKupBZTTL5NgBB0GSoIFyvqJ9eeQK3NYRIyylRKDs=; b=bkqFt 4jZ1Sxoqa3Tl/lUFFEBDfv1xgUC82CV/KBS4rx2BOg2iY7hTA9P5l1eg0xlvq+9Axnmjh7FEfT7LA NUC9PWmCsL8ogLS8W67ZiN5AbJE9sCBaf2SbAJxUv1njX6iiA5m0UgchVlv4jwthSlCj/+7zrv7AU bB3n+0qGQ87MQxMofw5F4yjF0AaUXRwncB0DI67Ftfsl4VWrl/Suvyh+PXC4t2PdVzCKgZw6kQFYI KycwsWJd6wshhBWHk9Jxu9FHf7p4vtkhArPDJa0GxVif9gQBgRD8enoJecIYyazLNYQvbfF5NjKgc vm6gHHpV1ZDwxpDvB1lTa9seuRouQ==; Message-Id: <39db33471909f8ab083e1a079eeae6975b55df13.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 14/19] 9pfs/9p.h: convert Doxygen -> kerneldoc format To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=39db33471909f8ab083e1a079eeae6975b55df13@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" API doc comments in QEMU are supposed to be in kerneldoc format, so convert API doc comments from Doxygen format to kerneldoc format. Based-on: Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: <2b8f91de7bac3d3bc85d60eb08830a35a394be75.1646314856.git.qemu_oss@crudebyte.com> --- hw/9pfs/9p.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 94b273b3d0..af2635fae9 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -100,8 +100,8 @@ typedef enum P9ProtoVersion { V9FS_PROTO_2000L = 0x02, } P9ProtoVersion; -/** - * @brief Minimum message size supported by this 9pfs server. +/* + * Minimum message size supported by this 9pfs server. * * A client establishes a session by sending a Tversion request along with a * 'msize' parameter which suggests the server a maximum message size ever to be @@ -231,7 +231,7 @@ static inline void v9fs_readdir_init(P9ProtoVersion proto_version, V9fsDir *dir) } } -/** +/* * Type for 9p fs drivers' (a.k.a. 9p backends) result of readdir requests, * which is a chained list of directory entries. */ @@ -289,8 +289,8 @@ typedef enum AffixType_t { AffixType_Suffix, /* A.k.a. postfix. */ } AffixType_t; -/** - * @brief Unique affix of variable length. +/* + * Unique affix of variable length. * * An affix is (currently) either a suffix or a prefix, which is either * going to be prepended (prefix) or appended (suffix) with some other @@ -304,7 +304,7 @@ typedef struct VariLenAffix { AffixType_t type; /* Whether this affix is a suffix or a prefix. */ uint64_t value; /* Actual numerical value of this affix. */ /* - * Lenght of the affix, that is how many (of the lowest) bits of @c value + * Lenght of the affix, that is how many (of the lowest) bits of ``value`` * must be used for appending/prepending this affix to its final resulting, * unique number. */ From patchwork Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771678 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 174AAC433EF for ; Mon, 7 Mar 2022 12:15:32 +0000 (UTC) Received: from localhost ([::1]:46120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRCGx-0000nd-38 for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 07:15:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1a7f2400148fd273536daa0adba5ecdea35c4bfb@lizzy.crudebyte.com>) id 1nRCEY-0006Tp-TA for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:13:02 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:34619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <1a7f2400148fd273536daa0adba5ecdea35c4bfb@lizzy.crudebyte.com>) id 1nRCEX-0007a4-2Q for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:13:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=Vl2X3WYggHpA/TJOsUhXcKaCskBk2BTJ7HU+dytgZhY=; b=Mj3z6 vERWVViegYaegb3q+0raO/CGHp2z/ToGcwZYJ5uxIlOYLc5VmVUC6gGFcvoX0aXOb7TKTOu7K0VZY 6cDkPRVazWoZgfIKeQXM6X6v4KTpJiucxKDDrCkvOrUnoNmf9BpNa4NvpV+KwJYLyxQ0nXwNWPu4z T3Xp0v2si+i8xHdkBbFQZqgNZ5bdfaR4ElHFTFcXHiM7RYLXmajjEe42nPF8LNOFUqjksTD6Nruou 6irlmLheu1hXacKPjzqOdVOtJnfcMlVV5jj0BYEw+j0DQ9Fta/cIk1tb7VvZ3v1DuPEGLPNVyfyg9 JqpWjgkmyLJUTG0YOrpIXYsMiCWNg==; Message-Id: <1a7f2400148fd273536daa0adba5ecdea35c4bfb.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 15/19] 9pfs/codir.c: convert Doxygen -> kerneldoc format To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=1a7f2400148fd273536daa0adba5ecdea35c4bfb@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" API doc comments in QEMU are supposed to be in kerneldoc format, so convert API doc comments from Doxygen format to kerneldoc format. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: --- hw/9pfs/codir.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c index f96d8ac4e6..75148bc985 100644 --- a/hw/9pfs/codir.c +++ b/hw/9pfs/codir.c @@ -184,14 +184,25 @@ out: } /** - * @brief Reads multiple directory entries in one rush. + * v9fs_co_readdir_many() - Reads multiple directory entries in one rush. + * + * @pdu: the causing 9p (T_readdir) client request + * @fidp: already opened directory where readdir shall be performed on + * @entries: output for directory entries (must not be NULL) + * @offset: initial position inside the directory the function shall + * seek to before retrieving the directory entries + * @maxsize: maximum result message body size (in bytes) + * @dostat: whether a stat() should be performed and returned for + * each directory entry + * Return: resulting response message body size (in bytes) on success, + * negative error code otherwise * * Retrieves the requested (max. amount of) directory entries from the fs * driver. This function must only be called by the main IO thread (top half). * Internally this function call will be dispatched to a background IO thread * (bottom half) where it is eventually executed by the fs driver. * - * @discussion Acquiring multiple directory entries in one rush from the fs + * Acquiring multiple directory entries in one rush from the fs * driver, instead of retrieving each directory entry individually, is very * beneficial from performance point of view. Because for every fs driver * request latency is added, which in practice could lead to overall @@ -199,20 +210,9 @@ out: * directory) if every directory entry was individually requested from fs * driver. * - * @note You must @b ALWAYS call @c v9fs_free_dirents(entries) after calling + * NOTE: You must ALWAYS call v9fs_free_dirents(entries) after calling * v9fs_co_readdir_many(), both on success and on error cases of this - * function, to avoid memory leaks once @p entries are no longer needed. - * - * @param pdu - the causing 9p (T_readdir) client request - * @param fidp - already opened directory where readdir shall be performed on - * @param entries - output for directory entries (must not be NULL) - * @param offset - initial position inside the directory the function shall - * seek to before retrieving the directory entries - * @param maxsize - maximum result message body size (in bytes) - * @param dostat - whether a stat() should be performed and returned for - * each directory entry - * @returns resulting response message body size (in bytes) on success, - * negative error code otherwise + * function, to avoid memory leaks once @entries are no longer needed. */ int coroutine_fn v9fs_co_readdir_many(V9fsPDU *pdu, V9fsFidState *fidp, struct V9fsDirEnt **entries, From patchwork Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771680 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 43322C433F5 for ; Mon, 7 Mar 2022 12:17:12 +0000 (UTC) Received: from localhost ([::1]:50794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRCIZ-000408-A5 for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 07:17:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRCCR-0002r7-2o for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:10:51 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:33469) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRCCP-0006fX-3d for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:10:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=JxwJG9r+Tf4XE67kO24LxoQgtYGtj/d4r4gjFVEHVJ0=; b=mWRJf l6SIcvzFc3PSVpQq7BvOnbQzHfp9WiM5uHM7yQkl3NTythf9Pz5GoOAm6tCottM4KHbVyAQ1nj2AU l639PQ235Kd+2OuP+PULQXnL2Y3pibity6QAmqwyJty6lvrlbk4FTd7dt1vjDLUKe2aW2rcAy/HG/ wHxBd0P5pwj3HAlP4bv84weShWnbFbDGezsg7PGjXk8JM7Ov4qkfcEdZ2CPx1Th/rH1ZbHV75teFX 7pk+t/obqiqAWwQqlRtyuKSBoKz4Ky8sbZPQoeRMVv+YaFVeOrvnlgE6s0axAOIvbW4rJ4v6ZbFVA qEPL8XPFEDOziD9wnZNSPHb0PTJhA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 16/19] 9pfs/9p.c: convert Doxygen -> kerneldoc format To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=e16fea4156b6f0877df45104320164501ca689f6@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" API doc comments in QEMU are supposed to be in kerneldoc format, so convert API doc comments from Doxygen format to kerneldoc format. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: <4ece6ffa4465c271c6a7c42a3040f42780fcce87.1646314856.git.qemu_oss@crudebyte.com> --- hw/9pfs/9p.c | 62 +++++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 7405352c37..a6d6b3f835 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -628,8 +628,8 @@ static inline uint64_t mirror64bit(uint64_t value) ((uint64_t)mirror8bit((value >> 56) & 0xff)); } -/** - * @brief Parameter k for the Exponential Golomb algorihm to be used. +/* + * Parameter k for the Exponential Golomb algorihm to be used. * * The smaller this value, the smaller the minimum bit count for the Exp. * Golomb generated affixes will be (at lowest index) however for the @@ -642,28 +642,30 @@ static inline uint64_t mirror64bit(uint64_t value) * should be small, for a large amount of devices k might be increased * instead. The default of k=0 should be fine for most users though. * - * @b IMPORTANT: In case this ever becomes a runtime parameter; the value of + * IMPORTANT: In case this ever becomes a runtime parameter; the value of * k should not change as long as guest is still running! Because that would * cause completely different inode numbers to be generated on guest. */ #define EXP_GOLOMB_K 0 /** - * @brief Exponential Golomb algorithm for arbitrary k (including k=0). + * expGolombEncode() - Exponential Golomb algorithm for arbitrary k + * (including k=0). * - * The Exponential Golomb algorithm generates @b prefixes (@b not suffixes!) + * @n: natural number (or index) of the prefix to be generated + * (1, 2, 3, ...) + * @k: parameter k of Exp. Golomb algorithm to be used + * (see comment on EXP_GOLOMB_K macro for details about k) + * Return: prefix for given @n and @k + * + * The Exponential Golomb algorithm generates prefixes (NOT suffixes!) * with growing length and with the mathematical property of being * "prefix-free". The latter means the generated prefixes can be prepended * in front of arbitrary numbers and the resulting concatenated numbers are * guaranteed to be always unique. * * This is a minor adjustment to the original Exp. Golomb algorithm in the - * sense that lowest allowed index (@param n) starts with 1, not with zero. - * - * @param n - natural number (or index) of the prefix to be generated - * (1, 2, 3, ...) - * @param k - parameter k of Exp. Golomb algorithm to be used - * (see comment on EXP_GOLOMB_K macro for details about k) + * sense that lowest allowed index (@n) starts with 1, not with zero. */ static VariLenAffix expGolombEncode(uint64_t n, int k) { @@ -677,7 +679,9 @@ static VariLenAffix expGolombEncode(uint64_t n, int k) } /** - * @brief Converts a suffix into a prefix, or a prefix into a suffix. + * invertAffix() - Converts a suffix into a prefix, or a prefix into a suffix. + * @affix: either suffix or prefix to be inverted + * Return: inversion of passed @affix * * Simply mirror all bits of the affix value, for the purpose to preserve * respectively the mathematical "prefix-free" or "suffix-free" property @@ -701,16 +705,16 @@ static VariLenAffix invertAffix(const VariLenAffix *affix) } /** - * @brief Generates suffix numbers with "suffix-free" property. + * affixForIndex() - Generates suffix numbers with "suffix-free" property. + * @index: natural number (or index) of the suffix to be generated + * (1, 2, 3, ...) + * Return: Suffix suitable to assemble unique number. * * This is just a wrapper function on top of the Exp. Golomb algorithm. * * Since the Exp. Golomb algorithm generates prefixes, but we need suffixes, * this function converts the Exp. Golomb prefixes into appropriate suffixes * which are still suitable for generating unique numbers. - * - * @param n - natural number (or index) of the suffix to be generated - * (1, 2, 3, ...) */ static VariLenAffix affixForIndex(uint64_t index) { @@ -810,8 +814,8 @@ static int qid_inode_prefix_hash_bits(V9fsPDU *pdu, dev_t dev) return val->prefix_bits; } -/** - * @brief Slow / full mapping host inode nr -> guest inode nr. +/* + * Slow / full mapping host inode nr -> guest inode nr. * * This function performs a slower and much more costly remapping of an * original file inode number on host to an appropriate different inode @@ -823,7 +827,7 @@ static int qid_inode_prefix_hash_bits(V9fsPDU *pdu, dev_t dev) * qid_path_suffixmap() failed. In practice this slow / full mapping is not * expected ever to be used at all though. * - * @see qid_path_suffixmap() for details + * See qid_path_suffixmap() for details * */ static int qid_path_fullmap(V9fsPDU *pdu, const struct stat *stbuf, @@ -864,8 +868,8 @@ static int qid_path_fullmap(V9fsPDU *pdu, const struct stat *stbuf, return 0; } -/** - * @brief Quick mapping host inode nr -> guest inode nr. +/* + * Quick mapping host inode nr -> guest inode nr. * * This function performs quick remapping of an original file inode number * on host to an appropriate different inode number on guest. This remapping @@ -1281,12 +1285,15 @@ static int coroutine_fn stat_to_v9stat(V9fsPDU *pdu, V9fsPath *path, /** - * Convert host filesystem's block size into an appropriate block size for - * 9p client (guest OS side). The value returned suggests an "optimum" block - * size for 9p I/O, i.e. to maximize performance. + * blksize_to_iounit() - Block size exposed to 9p client. + * Return: block size * * @pdu: 9p client request * @blksize: host filesystem's block size + * + * Convert host filesystem's block size into an appropriate block size for + * 9p client (guest OS side). The value returned suggests an "optimum" block + * size for 9p I/O, i.e. to maximize performance. */ static int32_t blksize_to_iounit(const V9fsPDU *pdu, int32_t blksize) { @@ -2398,10 +2405,11 @@ out_nofid: } /** - * Returns size required in Rreaddir response for the passed dirent @p name. + * v9fs_readdir_response_size() - Returns size required in Rreaddir response + * for the passed dirent @name. * - * @param name - directory entry's name (i.e. file name, directory name) - * @returns required size in bytes + * @name: directory entry's name (i.e. file name, directory name) + * Return: required size in bytes */ size_t v9fs_readdir_response_size(V9fsString *name) { From patchwork Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771724 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 9E7CFC433F5 for ; Mon, 7 Mar 2022 12:33:18 +0000 (UTC) Received: from localhost ([::1]:37490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRCY9-0007x1-N5 for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 07:33:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <041b0945f98821fe4b1a3caf5c081ca35032279c@lizzy.crudebyte.com>) id 1nRCJo-0007iL-5e for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:18:32 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:33137) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <041b0945f98821fe4b1a3caf5c081ca35032279c@lizzy.crudebyte.com>) id 1nRCJm-0008SA-Lt for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:18:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=rknlHOgpwDruDxO5phb53nMbnqNJL5CSSyJUNGTZy5I=; b=UnK2A Npj8ybRMv+c8G00unkXTeLA6VscoeHw66GNb1pknCJYiQlErCni4bxdmYweC4fMxYCMzfaBM2l28z 3PcKSRvQLIIq2oCqjA/+yuuCS5oDSv/OmzI3d1Nhmh1MyNKKRcfKTuEv6BCaNBDnXCi5x0RzOAxPN OCiVrFeqF6MaMfjBtGcPseOpy3xu1OD6zx/9N1OGUtcezi4QoqiGpvKh1bFC4gC4lYga1v065pyjt dM5f20tKGWfBKbGEJTH0zk/2Adlio+oJ8SsmvfOR/bhXLOcVYwtD5joRHwXokj7nFEg8N4OkBDIb5 653JLix3/rDbalaupYAUr57TrFUog==; Message-Id: <041b0945f98821fe4b1a3caf5c081ca35032279c.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 17/19] 9pfs/9p-util.h: convert Doxygen -> kerneldoc format To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=041b0945f98821fe4b1a3caf5c081ca35032279c@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" API doc comments in QEMU are supposed to be in kerneldoc format, so convert API doc comments from Doxygen format to kerneldoc format. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: --- hw/9pfs/9p-util.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index d0de6be3e2..97e681e167 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -99,7 +99,7 @@ ssize_t flistxattrat_nofollow(int dirfd, const char *filename, ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, const char *name); -/** +/* * Darwin has d_seekoff, which appears to function similarly to d_off. * However, it does not appear to be supported on all file systems, * so ensure it is manually injected earlier and call here when @@ -115,15 +115,15 @@ static inline off_t qemu_dirent_off(struct dirent *dent) } /** - * Duplicate directory entry @dent. + * qemu_dirent_dup() - Duplicate directory entry @dent. + * + * @dent: original directory entry to be duplicated + * Return: duplicated directory entry which should be freed with g_free() * * It is highly recommended to use this function instead of open coding * duplication of dirent objects, because the actual struct dirent * size may be bigger or shorter than sizeof(struct dirent) and correct * handling is platform specific (see gitlab issue #841). - * - * @dent - original directory entry to be duplicated - * @returns duplicated directory entry which should be freed with g_free() */ static inline struct dirent *qemu_dirent_dup(struct dirent *dent) { From patchwork Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771693 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 CFC5AC433F5 for ; Mon, 7 Mar 2022 12:24:50 +0000 (UTC) Received: from localhost ([::1]:43328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRCPx-0001BR-R7 for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 07:24:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <09d19d58078767f14f9a602eb939743d0a7c7a85@lizzy.crudebyte.com>) id 1nRCIn-0005eQ-RI for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:17:25 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:60501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <09d19d58078767f14f9a602eb939743d0a7c7a85@lizzy.crudebyte.com>) id 1nRCIm-0008HM-FQ for qemu-devel@nongnu.org; Mon, 07 Mar 2022 07:17:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=Dis0cFCt3Kt62wTSFGnP7lUDxDeSvq1HWoewP11CBIo=; b=dhLWx VRX1mdJJ996PiaaeTSDuxkdi+RTv1FkD9it+BTu0022iO6wttC6AQN3DmMZgQYLZfQf1LQp/4AGa7 m90pT8azDu+1n2TM6g1JloshOP7ATEyKJOHLN163DKFe0co7eUhOyJJFM9HMEmpXba7zwcG9L4R6M iCn+4xy6gh4jpPzK/XQnwFQY249ZCZtIFSWKLoV7ljXo1UVcgmNtALtCsZ8A/5wMBuuEWimnZkmqH qCM/ZPKcTbZhvEOa/VeBSXWvKdWoYv6Y/vpgrSAD8u0SU3VReno5Fj2A94XLMGvExfTTJ0ShEYCXA nQvyYzw5peB407s8ANBJ/OSYih75A==; Message-Id: <09d19d58078767f14f9a602eb939743d0a7c7a85.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 18/19] 9pfs/coth.h: drop Doxygen format on v9fs_co_run_in_worker() To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=09d19d58078767f14f9a602eb939743d0a7c7a85@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" API doc comments in QEMU are supposed to be in kerneldoc format, so drop Doxygen format used on v9fs_co_run_in_worker() macro. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: --- hw/9pfs/coth.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/coth.h b/hw/9pfs/coth.h index f83c7dda7b..1a1edbdc2a 100644 --- a/hw/9pfs/coth.h +++ b/hw/9pfs/coth.h @@ -19,7 +19,7 @@ #include "qemu/coroutine.h" #include "9p.h" -/** +/* * we want to use bottom half because we want to make sure the below * sequence of events. * @@ -29,7 +29,7 @@ * we cannot swap step 1 and 2, because that would imply worker thread * can enter coroutine while step1 is still running * - * @b PERFORMANCE @b CONSIDERATIONS: As a rule of thumb, keep in mind + * PERFORMANCE CONSIDERATIONS: As a rule of thumb, keep in mind * that hopping between threads adds @b latency! So when handling a * 9pfs request, avoid calling v9fs_co_run_in_worker() too often, because * this might otherwise sum up to a significant, huge overall latency for From patchwork Mon Mar 7 11:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12771612 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 EFC07C433EF for ; Mon, 7 Mar 2022 11:48:14 +0000 (UTC) Received: from localhost ([::1]:42528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRBqX-0001Cf-T3 for qemu-devel@archiver.kernel.org; Mon, 07 Mar 2022 06:48:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <35b6466459f9234b9cb30296f243a70b6f1b44b7@lizzy.crudebyte.com>) id 1nRBnR-0004l0-Kw for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:45:01 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:53379) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <35b6466459f9234b9cb30296f243a70b6f1b44b7@lizzy.crudebyte.com>) id 1nRBnP-00029D-Vq for qemu-devel@nongnu.org; Mon, 07 Mar 2022 06:45:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=b0kJJvQRJXiKQl93Iwsx0o6lTjxaRMH0jAe0PwTHfuQ=; b=AVzvI KRecvIX0WRvwvVNOHw4cXrYMih3tPbhIJDK50KmMFfgV9dGxQl7Hhghd2Dvm2qCTauTehX5ebjDJQ gvo8zx3psS3jtnLDVuZgxXSDjyd9VN/3bxf90gTUJa3cuuA4YRv6B2CzKKdQnK05E4bksxzeCPD/1 ly+8iQuGwW6p39EB/DFZc/Bpouf5rRpBh10W8hhKTa06ZjGkUkdH4gylKbMdFcWjtsSYif6IX5tII HRCtPMiZrt99moq7pC0v+ErygLhTeTF4M1hGVkKKeFDGUTIrKkEVselH0MA0CB5hXe8kG7KPNEP0D yuNj1+5TDgHKLTSDHiPp3+p02ppxQ==; Message-Id: <35b6466459f9234b9cb30296f243a70b6f1b44b7.1646651700.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Mon, 07 Mar 2022 12:15:00 +0100 Subject: [PULL v2 19/19] fsdev/p9array.h: convert Doxygen -> kerneldoc format To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Will Cohen , Keno Fischer , Michael Roitzsch , Fabian Franz , Paolo Bonzini Received-SPF: none client-ip=91.194.90.13; envelope-from=35b6466459f9234b9cb30296f243a70b6f1b44b7@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" API doc comments in QEMU are supposed to be in kerneldoc format, so convert API doc comments from Doxygen format to kerneldoc format. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: <2e2d46a402560f155de322d95789ba107d728885.1646314856.git.qemu_oss@crudebyte.com> --- fsdev/p9array.h | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/fsdev/p9array.h b/fsdev/p9array.h index 6aa25327ca..90e83a7c7b 100644 --- a/fsdev/p9array.h +++ b/fsdev/p9array.h @@ -81,11 +81,11 @@ */ /** - * Declares an array type for the passed @a scalar_type. + * P9ARRAY_DECLARE_TYPE() - Declares an array type for the passed @scalar_type. * - * This is typically used from a shared header file. + * @scalar_type: type of the individual array elements * - * @param scalar_type - type of the individual array elements + * This is typically used from a shared header file. */ #define P9ARRAY_DECLARE_TYPE(scalar_type) \ typedef struct P9Array##scalar_type { \ @@ -97,14 +97,14 @@ void p9array_auto_free_##scalar_type(scalar_type **auto_var); \ /** - * Defines an array type for the passed @a scalar_type and appropriate - * @a scalar_cleanup_func. + * P9ARRAY_DEFINE_TYPE() - Defines an array type for the passed @scalar_type + * and appropriate @scalar_cleanup_func. * - * This is typically used from a C unit file. + * @scalar_type: type of the individual array elements + * @scalar_cleanup_func: appropriate function to free memory dynamically + * allocated by individual array elements before * - * @param scalar_type - type of the individual array elements - * @param scalar_cleanup_func - appropriate function to free memory dynamically - * allocated by individual array elements before + * This is typically used from a C unit file. */ #define P9ARRAY_DEFINE_TYPE(scalar_type, scalar_cleanup_func) \ void p9array_new_##scalar_type(scalar_type **auto_var, size_t len) \ @@ -132,23 +132,27 @@ } \ /** + * P9ARRAY_REF() - Declare a reference variable for an array. + * + * @scalar_type: type of the individual array elements + * * Used to declare a reference variable (unique pointer) for an array. After * leaving the scope of the reference variable, the associated array is * automatically freed. - * - * @param scalar_type - type of the individual array elements */ #define P9ARRAY_REF(scalar_type) \ __attribute((__cleanup__(p9array_auto_free_##scalar_type))) scalar_type* /** - * Allocates a new array of passed @a scalar_type with @a len number of array - * elements and assigns the created array to the reference variable - * @a auto_var. + * P9ARRAY_NEW() - Allocate a new array. * - * @param scalar_type - type of the individual array elements - * @param auto_var - destination reference variable - * @param len - amount of array elements to be allocated immediately + * @scalar_type: type of the individual array elements + * @auto_var: destination reference variable + * @len: amount of array elements to be allocated immediately + * + * Allocates a new array of passed @scalar_type with @len number of array + * elements and assigns the created array to the reference variable + * @auto_var. */ #define P9ARRAY_NEW(scalar_type, auto_var, len) \ QEMU_BUILD_BUG_MSG( \