From nobody Sun Jul 26 13:25:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1781362971; cv=none; d=zohomail.com; s=zohoarc; b=cf6ZsKQoNQNpJ5X6ls1AJ2JIABC3h1X3Scrq97OX+6eYiUndOBeLMenG2PSJX6gsi6L4rloBZ0H8pLoH0DRZScEAvmfdNsogLX/vhThHu7CUAejlUPAbv35g/f/zxCGwa+6UpAFEcPoHwA3fObmyZnUmDeLyTdT4QPkzT1cxzFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781362971; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MfenymRhk48IxUTxbFS7vY9DrB63qmTI315WRZ5gsUk=; b=M4fRS9sAFOnqfIA/rr8W7YASOEmVRa7nvVuR06O8MCdG09np9K5th5n+rURbuH6RQ2TAB5X4UhnpkqIvTHjL0QqjisJW5VO2EoMyExD3HOY2QdWKLVVPOj3NO/tBCFQSfhIIW+wB5b6vzHfxq8EmRTp8A3g7s7XAsjU08Rc3Gow= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781362971835610.4695003789142; Sat, 13 Jun 2026 08:02:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wYPsf-0004qy-Nf; Sat, 13 Jun 2026 11:02:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wYPse-0004qm-7H; Sat, 13 Jun 2026 11:02:40 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wYPsc-0003xs-Ik; Sat, 13 Jun 2026 11:02:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=MfenymRhk48IxUTxbFS7vY9DrB63qmTI315WRZ5gsUk=; b=cITay iQi5St9/vzOKchwLTshYTEarm/O53HwqfDqg5jrCi3tB8vag4vRXLO3axOPlnkWzispmN7kpcZcJ2 Aho5ols0FwLTYvL/JNEcw+QRkF4+z/CoPHeEpAAjHUmgF5dzxzqviBHfgRznKe2/b1kmRz7U+kOMT DkeT2xhC44U3btAwxxh8SswDqojdG0BXoTh4L1gj0hAOcWx4GR14+PNppMPrGKUlDcieJpjq0r30F ToAqGvavPYq/66vd+td9YjsQv9C/KFocIlrl31o3MSJYGPSHWvsH8npZB3Y22qxyFOVsE1lBeFpmR UKumJcWiaKAQ6adGks7Kse4oqqxI4gPgSu93ntVN2HFwxgrLFRVV7T9q2UWy9Lmu3b29uWHd8k6MU YeQFDv33tQNAcj9F6J6ETjZC9ckW0tsxr5jaRQ4Zyyat8NpE9w20yPCWgDi17R9EtKYp7DHfeiIOw m/X68avZu6x2i0Ahq4yHqNGBXqao/dM38L8DRW8YpliX5sOyFIL3xUoty++/0WksOaEy4Cu62H5zR HAWNuc9NA4X7gg23EFEQjx07H79fd/5AqZfvzOHdBzEPdXS37ZyCXW2O7q3z1EN6wtgJx6e4zb+rO 3ex4gYbjHR5uIEFcde8iBdIfBFWX4/rS4tjMOKsqQjcRQMX2YB/updNoEYj4LI=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 13 Jun 2026 16:55:49 +0200 Subject: [PATCH v3 01/12] hw/9pfs: add xattr FID limit to prevent memory exhaustion To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Greg Kurz , Feifan Qian Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.189.157.229; envelope-from=eb3787869745d47234fb662600187bf773e1ef8a@kylie.crudebyte.com; helo=kylie.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_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1781362973647158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a limit on the number of simultaneously open xattr FIDs to prevent host memory exhaustion attacks. Each xattr FID contains a buffer for the xattr value, and without a limit, a malicious priviliged guest with direct communication access to 9p server could create a huge number of xattr FIDs until host memory is eventually exhausted. Fix this by: - add xattr_fid_limit to struct FsContext for the max. amount - add xattr_fid_count to struct FsContext for the current amount - init xattr_fid_limit with 1024 - init xattr_fid_count with 0 - add function xattr_fid_count_inc() to increment the count - add function xattr_fid_count_decr() to decrement the count - call xattr_fid_count_inc() in Txattrcreate handler - call xattr_fid_count_inc() in Txattrwalk handler - call xattr_fid_count_decr() when a xattr FID is freed Additionally: - reset the xattr FID counter in virtfs_reset() When the limit is reached then xattr_fid_count_inc() returns -ENOSPC and the request handler is aborted on its error path without turning the FID into an xattr type and without allocating memory for the xattr. The default value of 1024 was chosen, as (sane usage of) xattr requests in the 9p protocol are usually very short-lived, and even machines with 128 cores with very high xattr activity should have plenty of head room without ever hitting this limit. Fixes: 10b468bdc5 ("virtio-9p: Implement TXATTRCREATE") Fixes: CVE-2026-8348 Reported-by: Feifan Qian Signed-off-by: Christian Schoenebeck --- fsdev/file-op-9p.h | 9 +++++++ hw/9pfs/9p.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h index e8d0661c4b..454761d81d 100644 --- a/fsdev/file-op-9p.h +++ b/fsdev/file-op-9p.h @@ -81,6 +81,11 @@ typedef struct ExtendedOps { =20 #define V9FS_SEC_MASK 0x0000003C =20 +/* + * Limits the maximum amount of simultaneously open xattr FIDs to prevent + * host memory exhaustion (as each xattr FID contains a xattr value buffer= ). + */ +#define V9FS_MAX_XATTR_DEFAULT 1024 =20 typedef struct FileOperations FileOperations; typedef struct XattrOperations XattrOperations; @@ -109,6 +114,10 @@ struct FsContext { void *private; mode_t fmode; mode_t dmode; + /* max. amount of simultaneously open xattr FIDs */ + uint32_t xattr_fid_limit; + /* current amount of open xattr FIDs */ + uint32_t xattr_fid_count; }; =20 struct V9fsPath { diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index b4314d2549..053f0cc64b 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -265,6 +265,31 @@ static size_t v9fs_string_size(V9fsString *str) return str->size; } =20 +static int xattr_fid_count_inc(V9fsPDU *pdu) +{ + V9fsState *s =3D pdu->s; + + if (s->ctx.xattr_fid_limit > 0 && + s->ctx.xattr_fid_count >=3D s->ctx.xattr_fid_limit) { + error_report_once("9pfs: xattr_fid_count limit exceeded " + "(configurable by option 'max_xattr')."); + return -ENOSPC; + } + s->ctx.xattr_fid_count++; + return 0; +} + +static void xattr_fid_count_decr(V9fsPDU *pdu) +{ + V9fsState *s =3D pdu->s; + + if (s->ctx.xattr_fid_count > 0) { + s->ctx.xattr_fid_count--; + } else { + error_report_once("9pfs: xattr_fid_count underflow detected"); + } +} + /* * returns 0 if fid got re-opened, 1 if not, < 0 on error */ @@ -397,6 +422,7 @@ static int coroutine_fn free_fid(V9fsPDU *pdu, V9fsFidS= tate *fidp) } } else if (fidp->fid_type =3D=3D P9_FID_XATTR) { retval =3D v9fs_xattr_fid_clunk(pdu, fidp); + xattr_fid_count_decr(pdu); } v9fs_path_free(&fidp->path); g_free(fidp); @@ -634,6 +660,14 @@ static void coroutine_fn virtfs_reset(V9fsPDU *pdu) fidp->clunked =3D true; put_fid(pdu, fidp); } + + /* + * Explicitly reset the xattr FID counter. + * + * free_fid() already decrements the counter for each P9_FID_XATTR, so= the + * counter should already be zero, hence this is just a defensive meas= ure. + */ + s->ctx.xattr_fid_count =3D 0; } =20 #define P9_QID_TYPE_DIR 0x80 @@ -4006,6 +4040,14 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque) clunk_fid(s, xattr_fidp->fid); goto out; } + + /* Check xattr FID limit */ + err =3D xattr_fid_count_inc(pdu); + if (err < 0) { + clunk_fid(s, xattr_fidp->fid); + goto out; + } + /* * Read the xattr value */ @@ -4013,6 +4055,7 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque) xattr_fidp->fid_type =3D P9_FID_XATTR; xattr_fidp->fs.xattr.xattrwalk_fid =3D true; xattr_fidp->fs.xattr.value =3D g_malloc0(size); + if (size) { err =3D v9fs_co_llistxattr(pdu, &xattr_fidp->path, xattr_fidp->fs.xattr.value, @@ -4039,6 +4082,14 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque) clunk_fid(s, xattr_fidp->fid); goto out; } + + /* Check xattr FID limit */ + err =3D xattr_fid_count_inc(pdu); + if (err < 0) { + clunk_fid(s, xattr_fidp->fid); + goto out; + } + /* * Read the xattr value */ @@ -4046,6 +4097,7 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque) xattr_fidp->fid_type =3D P9_FID_XATTR; xattr_fidp->fs.xattr.xattrwalk_fid =3D true; xattr_fidp->fs.xattr.value =3D g_malloc0(size); + if (size) { err =3D v9fs_co_lgetxattr(pdu, &xattr_fidp->path, &name, xattr_fidp->fs.xattr.value, @@ -4147,6 +4199,12 @@ static void coroutine_fn v9fs_xattrcreate(void *opaq= ue) goto out_put_fid; } =20 + /* Check xattr FID limit */ + err =3D xattr_fid_count_inc(pdu); + if (err < 0) { + goto out_put_fid; + } + /* Make the file fid point to xattr */ xattr_fidp =3D file_fidp; xattr_fidp->fid_type =3D P9_FID_XATTR; @@ -4408,6 +4466,10 @@ int v9fs_device_realize_common(V9fsState *s, const V= 9fsTransport *t, =20 s->reclaiming =3D false; =20 + /* init xattr FID limit */ + s->ctx.xattr_fid_limit =3D V9FS_MAX_XATTR_DEFAULT; + s->ctx.xattr_fid_count =3D 0; + rc =3D 0; out: if (rc) { --=20 2.47.3 From nobody Sun Jul 26 13:25:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1781364707; cv=none; d=zohomail.com; s=zohoarc; b=kIMLCb7GGZlrlE5wwS/mr9jEePSlOFvvv1UC5irfw1AgBhzhpMtcRCCph5MYNIIrawLTGEgeQIRhIMTpiz77w7jH4Or8LlzP/muQSVfFno8tfDc45dVQ7USMPeuCEHHGnBca59wUzVxlVG7ux/0JPMRep+0sTF4tvyOuU5rEfnk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781364707; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EI+AkBjx1TiTmWuRC4iIGqhkKvsK0mc9umkW2C8ve8c=; b=Sm7HXJgWp07z57df2Txu1y+V/TZSWiz7MkEd4XUqSyZ9MUFfJxY8Jd11zV0iTvCA78iNopa7nlb0EzxsyP+ye9w8tCCTeLPnqvDbu5c7u6LDPVhq4FyVNRf0Hgk78hX5rkdwF2+XlMXheVbGLUOhIX/n69n+IozJ0MGeRn+4H6M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781364707633930.9423609393891; Sat, 13 Jun 2026 08:31:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wYQJb-00083G-FL; Sat, 13 Jun 2026 11:30:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wYQJa-00082x-0y; Sat, 13 Jun 2026 11:30:30 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wYQJY-0005P0-9d; Sat, 13 Jun 2026 11:30:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=EI+AkBjx1TiTmWuRC4iIGqhkKvsK0mc9umkW2C8ve8c=; b=vIFhs Zh+rkBbU3GsSyKcIttQhpnA0OSD5RpHRkiy/kK30I/XukcVixyYO72nyAe7qODL+86QbiLN3l51fm x48F6PFRhnc7iugEvO0+WN+QMpuKWSkrWOazuMB8qpvxUTA9exIy8VPvqGR+Yj10EXQK6TAc6UEGq tGKAhBGznYlarC65a27AYJzo7CJaErnr3il2I0qqBWAN1b4GFRfrIBoOa4CPL0XWNW/DFrSRBFM7o w2f9HKAybNG0gY+LBY9dZWChY8gkbLZkXvPIk4x6aKmcGTPlsHeN5Acw4vXzgzOXgAH1RadopGrw4 +dTS4Ct+WpnBl3AwfA69LXOjh+rgsHYjAgIW5uxyNxNzjLivq4zf6KXt4MUh2vggxRH02q4cwDhkL NrN9E2sJiuB5/EKPuGU1EumBUTXzLdJu9OtKXYMe8ugiNPfQx6A9AMkmI47GejS4ObVQ4rQJO5a7h gckcnowl3RvcIShltDI6ufheUJiAWeo3+gKQdSZDjMUpJwINm3Kolvk17fTijVVQy6o8Sv6TBVTT1 6yBGhZJQptX4rX4RJJyuJwb67eZiTle1jxFgnfhlIhYz93FrP2mhQ2WxjRSWvZc9yvdqEAPk73948 01vh5lvnTMRtMwHUzhTGYijhArUERRJlfVwXBD8SpZBIXZob57mqHTxrSRvrBw=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 13 Jun 2026 16:55:49 +0200 Subject: [PATCH v3 02/12] hw/9pfs: add max_xattr option To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Greg Kurz , Feifan Qian Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.189.157.229; envelope-from=b7631ac0d8dde0629bc7c4f2c4185d9f57b962b4@kylie.crudebyte.com; helo=kylie.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_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1781364709371158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Previous patch introduced a limit of max. 1024 simultaneous xattr FIDs. This patch introduces an option "max_attr" that allows to override this limit, just for the case that some user might run into this limit for some reason, even if unlikely; or for reducing the limit further down (e.g. that default limit of 1024 would cap at max. 64 MiB host memory, at least on Linux hosts where the limit per xattr is 64k). This new "max_xattr" option can be specified with both -fsdev and -virtfs command line options, with the "local" and the "synth" fs drivers. The previous limit of 1024 is preserved as the default value. Signed-off-by: Christian Schoenebeck --- fsdev/file-op-9p.h | 2 ++ fsdev/qemu-fsdev-opts.c | 6 ++++++ fsdev/qemu-fsdev.c | 2 +- hw/9pfs/9p-local.c | 9 +++++++++ hw/9pfs/9p-synth.c | 17 +++++++++++++++++ hw/9pfs/9p.c | 4 ++-- system/vl.c | 7 ++++++- 7 files changed, 43 insertions(+), 4 deletions(-) diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h index 454761d81d..1d931144f4 100644 --- a/fsdev/file-op-9p.h +++ b/fsdev/file-op-9p.h @@ -101,6 +101,8 @@ typedef struct FsDriverEntry { FsThrottle fst; mode_t fmode; mode_t dmode; + /* temporary storage for parse_opts only */ + uint32_t max_xattr; } FsDriverEntry; =20 struct FsContext { diff --git a/fsdev/qemu-fsdev-opts.c b/fsdev/qemu-fsdev-opts.c index 07a18c6e48..c2c1e83611 100644 --- a/fsdev/qemu-fsdev-opts.c +++ b/fsdev/qemu-fsdev-opts.c @@ -46,6 +46,9 @@ static QemuOptsList qemu_fsdev_opts =3D { }, { .name =3D "dmode", .type =3D QEMU_OPT_NUMBER, + }, { + .name =3D "max_xattr", + .type =3D QEMU_OPT_NUMBER, }, =20 THROTTLE_OPTS, @@ -92,6 +95,9 @@ static QemuOptsList qemu_virtfs_opts =3D { }, { .name =3D "dmode", .type =3D QEMU_OPT_NUMBER, + }, { + .name =3D "max_xattr", + .type =3D QEMU_OPT_NUMBER, }, =20 { /*End of list */ } diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index 57877dad0a..f97103cf44 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -45,7 +45,7 @@ typedef struct FsDriverListEntry { static QTAILQ_HEAD(, FsDriverListEntry) fsdriver_entries =3D QTAILQ_HEAD_INITIALIZER(fsdriver_entries); =20 -#define COMMON_FS_DRIVER_OPTIONS "id", "fsdriver", "readonly" +#define COMMON_FS_DRIVER_OPTIONS "id", "fsdriver", "readonly", "max_xattr" =20 static FsDriverTable FsDrivers[] =3D { { diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index aa48306b0e..4708e170a4 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1527,6 +1527,15 @@ static int local_parse_opts(QemuOpts *opts, FsDriver= Entry *fse, Error **errp) const char *path =3D qemu_opt_get(opts, "path"); const char *multidevs =3D qemu_opt_get(opts, "multidevs"); =20 + uint64_t val =3D qemu_opt_get_number(opts, "max_xattr", + V9FS_MAX_XATTR_DEFAULT); + if (val > UINT32_MAX) { + error_setg(errp, "max_xattr value '%s' too large", + qemu_opt_get(opts, "max_xattr")); + return -1; + } + fse->max_xattr =3D val; + if (!sec_model) { error_setg(errp, "security_model property not set"); error_append_security_model_hint(errp); diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index b3743f6169..322dc3bb69 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -25,6 +25,8 @@ #include "qemu/rcu_queue.h" #include "qemu/cutils.h" #include "system/qtest.h" +#include "qapi/error.h" +#include "qemu/option.h" =20 /* Root node for synth file system */ static V9fsSynthNode synth_root =3D { @@ -629,12 +631,27 @@ static int synth_init(FsContext *ctx, Error **errp) return 0; } =20 +static int synth_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **er= rp) +{ + uint64_t val =3D qemu_opt_get_number(opts, "max_xattr", + V9FS_MAX_XATTR_DEFAULT); + if (val > UINT32_MAX) { + error_setg(errp, "max_xattr value '%s' too large", + qemu_opt_get(opts, "max_xattr")); + return -1; + } + fse->max_xattr =3D val; + + return 0; +} + static bool synth_has_valid_file_handle(int fid_type, V9fsFidOpenState *fs) { return false; } =20 FileOperations synth_ops =3D { + .parse_opts =3D synth_parse_opts, .init =3D synth_init, .lstat =3D synth_lstat, .readlink =3D synth_readlink, diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 053f0cc64b..fb8c7439f7 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -4466,8 +4466,8 @@ int v9fs_device_realize_common(V9fsState *s, const V9= fsTransport *t, =20 s->reclaiming =3D false; =20 - /* init xattr FID limit */ - s->ctx.xattr_fid_limit =3D V9FS_MAX_XATTR_DEFAULT; + /* init xattr FID limit from fsdev config */ + s->ctx.xattr_fid_limit =3D fse->max_xattr; s->ctx.xattr_fid_count =3D 0; =20 rc =3D 0; diff --git a/system/vl.c b/system/vl.c index dbdd4f2257..eb86d725bd 100644 --- a/system/vl.c +++ b/system/vl.c @@ -3259,7 +3259,7 @@ void qemu_init(int argc, char **argv) QemuOpts *fsdev; QemuOpts *device; const char *writeout, *sock_fd, *socket, *path, *security_= model, - *multidevs; + *multidevs, *max_xattr_str; =20 olist =3D qemu_find_opts("virtfs"); if (!olist) { @@ -3323,6 +3323,11 @@ void qemu_init(int argc, char **argv) if (multidevs) { qemu_opt_set(fsdev, "multidevs", multidevs, &error_abo= rt); } + max_xattr_str =3D qemu_opt_get(opts, "max_xattr"); + if (max_xattr_str) { + qemu_opt_set(fsdev, "max_xattr", max_xattr_str, + &error_abort); + } device =3D qemu_opts_create(qemu_find_opts("device"), NULL= , 0, &error_abort); qemu_opt_set(device, "driver", "virtio-9p-pci", &error_abo= rt); --=20 2.47.3 From nobody Sun Jul 26 13:25:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1781364761; cv=none; d=zohomail.com; s=zohoarc; b=bR/fN8voOHwgLbcLbwi3H8ZutRvJHVK6gx8Pz2BoD3gIucaYLqQ88Zezlx8vYTQ2ahaP8s8tZZRT4Fza9hxIiGf9rvlOXPeWNZPCq6a39VEr/eFtuWjCH3KAzUFCErSC3eFExdW7rOQuyGSHeZAm7NNNB/P524URMAPZ0Bh+LlM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781364761; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ufiiCn3cvKp4ufTQLLv5qoeOBCcGqz3IzSs540NafIM=; b=XWBxHUtgpsDtPWJ8VdKa03B7m6W9m0G4SOKpYu1fOhjEuEWZaA4wakQCoTF02Yy4RIT+f2SxSQy06/wBGRCwxuMqmQpyvmPNSH+4d0XCLrjMiiPcv+i9bzAqdHyEZm4qeUn33XXZHxYNFjbUHHHvbG1CgnPyktzsnCqWPb05wUY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781364761876859.1937481626046; Sat, 13 Jun 2026 08:32:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wYQJZ-00082Y-Gf; Sat, 13 Jun 2026 11:30:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wYQJW-00080P-O5; Sat, 13 Jun 2026 11:30:26 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wYQJU-0005Lc-PN; Sat, 13 Jun 2026 11:30:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=ufiiCn3cvKp4ufTQLLv5qoeOBCcGqz3IzSs540NafIM=; b=vWhBw hJPFEncfpivVMzEiV3gdUfo76NV+P3/4TJ1mdl78fJ+l8fS2grvjlkeD79ZW+to7ecJHEnObDDtjo MzW1SHcHPT961cL/ir8ZBGl2G6e61hAmZDW9i1+rDtV2+Cn9CGRu7EfpUfSXTyXNnR8xGeoDi5xLV ceNYRMWowPTqZRpVSLX1QY+iSFGNE801Rckea0xiteu61/InYrtff9aeQtWb6Cxtr+1uhfbCXo8CN QuzwRWlT335KC/KaXD1CTW0xpACEdkrokoOXLaJ704o5wjlh6OH4OHcJPRxAscSusny0tzafXvwQG Zovxlb/pz3p7L66g696JzLISJRzF2qT3B1GuNR7nvofXENI8furXmjYQbTbnl9daQHxynAd0sXDRx lYzXAOuGJ79MO8yobrQDI3KWkjz/gCEDVP+pK+XiSbKHJb2auN31J+T2hoX52Yy01+5Fx6DU556+p cCID2wipgfC7Ges/h4EyGyX5rNPlGXO4cZ+tblJiw4bbpFNO/2WiT6BXK9VvQMzyJ24bNKom6DWn/ da0Qr/04KGOZ1gWeFKAHCm0Ytsg6xQUhovynJh0sld2tcuPQQCCUhlnL4GD0IXt3xCXxYVr2mPvun /Sia1NwyBO+z27z9/gEO6NQeBaUnrOmg3A4hbk1t+1smGe04WPm3s2tSzLgUG4=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 13 Jun 2026 16:55:49 +0200 Subject: [PATCH v3 03/12] qemu-options: document 9pfs max_xattr option To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Greg Kurz , Feifan Qian Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.189.157.229; envelope-from=b5a1a6ba299a49183d0032d9e4cd5e009d4aae47@kylie.crudebyte.com; helo=kylie.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_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1781364763302158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add documentation for the new "max_xattr" command line option of 9pfs server, introduced by the previous commit. Signed-off-by: Christian Schoenebeck --- qemu-options.hx | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 96ae41f787..456d44af39 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1914,19 +1914,19 @@ ERST =20 DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev, "-fsdev local,id=3Did,path=3Dpath,security_model=3Dmapped-xattr|mapped= -file|passthrough|none\n" - " [,writeout=3Dimmediate][,readonly=3Don][,fmode=3Dfmode][,dmode=3Ddmo= de]\n" + " [,writeout=3Dimmediate][,readonly=3Don][,fmode=3Dfmode][,dmode=3Ddmo= de][,max_xattr=3Dmax]\n" " [[,throttling.bps-total=3Db]|[[,throttling.bps-read=3Dr][,throttling= .bps-write=3Dw]]]\n" " [[,throttling.iops-total=3Di]|[[,throttling.iops-read=3Dr][,throttli= ng.iops-write=3Dw]]]\n" " [[,throttling.bps-total-max=3Dbm]|[[,throttling.bps-read-max=3Drm][,= throttling.bps-write-max=3Dwm]]]\n" " [[,throttling.iops-total-max=3Dim]|[[,throttling.iops-read-max=3Dirm= ][,throttling.iops-write-max=3Diwm]]]\n" " [[,throttling.iops-size=3Dis]]\n" - "-fsdev synth,id=3Did\n", + "-fsdev synth,id=3Did[,max_xattr=3Dmax]\n", QEMU_ARCH_ALL) =20 SRST -``-fsdev local,id=3Did,path=3Dpath,security_model=3Dsecurity_model [,write= out=3Dwriteout][,readonly=3Don][,fmode=3Dfmode][,dmode=3Ddmode] [,throttlin= g.option=3Dvalue[,throttling.option=3Dvalue[,...]]]`` +``-fsdev local,id=3Did,path=3Dpath,security_model=3Dsecurity_model [,write= out=3Dwriteout][,readonly=3Don][,fmode=3Dfmode][,dmode=3Ddmode][,max_xattr= =3Dmax] [,throttling.option=3Dvalue[,throttling.option=3Dvalue[,...]]]`` \=20 -``-fsdev synth,id=3Did[,readonly=3Don]`` +``-fsdev synth,id=3Did[,readonly=3Don][,max_xattr=3Dmax]`` Define a new file system device. Valid options are: =20 ``local`` @@ -2000,6 +2000,12 @@ SRST Let every is bytes of a request count as a new request for iops throttling purposes. =20 + ``max_xattr=3Dmax`` + Specifies the maximum number of concurrent xattr FIDs allowed for + this export. The default is 1024. Set to 0 for allowing an infinite + number of xattr FIDs. This limit prevents host memory exhaustion + attacks by capping the number of simultaneous xattr FIDs. + -fsdev option is used along with -device driver "virtio-9p-...". =20 ``-device virtio-9p-type,fsdev=3Did,mount_tag=3Dmount_tag`` @@ -2019,14 +2025,14 @@ ERST =20 DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs, "-virtfs local,path=3Dpath,mount_tag=3Dtag,security_model=3Dmapped-xat= tr|mapped-file|passthrough|none\n" - " [,id=3Did][,writeout=3Dimmediate][,readonly=3Don][,fmode=3Dfm= ode][,dmode=3Ddmode][,multidevs=3Dremap|forbid|warn]\n" - "-virtfs synth,mount_tag=3Dtag[,id=3Did][,readonly=3Don]\n", + " [,id=3Did][,writeout=3Dimmediate][,readonly=3Don][,fmode=3Dfm= ode][,dmode=3Ddmode][,multidevs=3Dremap|forbid|warn][,max_xattr=3Dmax]\n" + "-virtfs synth,mount_tag=3Dtag[,id=3Did][,readonly=3Don][,max_xattr=3D= max]\n", QEMU_ARCH_ALL) =20 SRST -``-virtfs local,path=3Dpath,mount_tag=3Dmount_tag ,security_model=3Dsecuri= ty_model[,writeout=3Dwriteout][,readonly=3Don] [,fmode=3Dfmode][,dmode=3Ddm= ode][,multidevs=3Dmultidevs]`` +``-virtfs local,path=3Dpath,mount_tag=3Dmount_tag ,security_model=3Dsecuri= ty_model[,writeout=3Dwriteout][,readonly=3Don] [,fmode=3Dfmode][,dmode=3Ddm= ode][,multidevs=3Dmultidevs][,max_xattr=3Dmax]`` \=20 -``-virtfs synth,mount_tag=3Dmount_tag`` +``-virtfs synth,mount_tag=3Dmount_tag[,max_xattr=3Dmax]`` Define a new virtual filesystem device and expose it to the guest using a virtio-9p-device (a.k.a. 9pfs), which essentially means that a certa= in directory on host is made directly accessible by guest as a pass-throu= gh @@ -2092,6 +2098,12 @@ SRST Specifies the tag name to be used by the guest to mount this export point. =20 + ``max_xattr=3Dmax`` + Specifies the maximum number of concurrent xattr FIDs allowed for + this export. The default is 1024. Set to 0 for allowing an infinite + number of xattr FIDs. This limit prevents host memory exhaustion + attacks by capping the number of simultaneous xattr FIDs. + ``multidevs=3Dremap|forbid|warn`` Specifies how to deal with multiple devices being shared with the same 9p export in order to avoid file ID collisions on guest. --=20 2.47.3 From nobody Sun Jul 26 13:25:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1781364713; cv=none; d=zohomail.com; s=zohoarc; b=Hv2hanZGQSYKYf3nalrJ2N3D0rNkGw3unGiFrLkcIGu2xFLmq9eOZRDw4hpvRWVZLm6Cs1SI5YQpTnFjZipgCSCBifHu5/AiD1bs8kwWMleaETK5Dgt9LTYILC/kzr4qr6Iw3mJh5vVME3PdvkiYqAyKU5lvnS1AWnRsKPlfyZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781364713; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+Pb1E062e+vdMI39HgiCkAtZTwKmpyquagDGi2YMRJw=; b=KNi9DRzOvnrgJ74BOh1iLSM7qpi9bozuh6XQkK/8jtfRVoyAsX03RkpXv+zFSfeZNAFcob8P1v04b9SYJpQacgWS6/zRlfi+DPC3nWl5KBPB0MK49rLBywT0WbBW+aQ3HOl3eyYcS1B+HEU0/RCLRIf/vn+lkcszNtAMvlfnkVo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781364713313712.5572981804758; Sat, 13 Jun 2026 08:31:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wYQJh-000853-Oc; Sat, 13 Jun 2026 11:30:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <049bdd1e66416f5200fb3d59d2da5e8ec149926d@kylie.crudebyte.com>) id 1wYQJg-00084p-Ks; Sat, 13 Jun 2026 11:30:36 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <049bdd1e66416f5200fb3d59d2da5e8ec149926d@kylie.crudebyte.com>) id 1wYQJe-0005Vb-Vs; Sat, 13 Jun 2026 11:30:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=+Pb1E062e+vdMI39HgiCkAtZTwKmpyquagDGi2YMRJw=; b=nAzqt PAPm+FlKSowYKSn3ooxj05YcjGtQzv/GW3aS9JYq15Ims9buyTVyV8DTzuaxnEZ4m7/YckPq7hwQB CBaqZRoeqDFpu8sfd1WJidp57yJx0h128EHcluCCE5Rys5rJ9Pll2iCfys/9H232fF4MGuOv7e1it Ti7ambrJfXg3kI6dNVLPW/y+liptMUGxreFTnCMVzo7lTDhx3g1TugO+kzbYSjgj7vlJqpsl+4g9H HLvlnbxGx+fZfRf6Qh8qi5NYKnOlJeNjZpqtzrBnwfvquJV8ZzGX8hxKYYAmO7NTJe79f9hukJmb9 S2y7xAYNasxa/5QEyVUxUFUfwSpxRL2d3ICeAnSpoyCJ54z62m9qib25JvedB8gp9XA8yShQn6JyC YSWw49I9/xpHJsiLQitXk13MgTa601FMYb41bx+WOXqMwwKe6mxmdnP10UTdaZliK63wB6e80j+eh ip3yw/HGHijYwSgGtYYfhRiiLvKbz83Rwd0fjD517XCJ9KYb7tUM4w5bSHGBr0255FqKAAg302WiG SxEFntutetuEt86cD3h5fCVPAGg2/MXTuLpiKQQFCVcorSj8b59lphNTmr9LkrODYAlg47exrSqfk YYL2uvGB1i5JWBHBbIPCZEn5WtNZKqq+pRS6AtMswDRG6XLWX00/9YIUze1FVY=; Message-ID: <049bdd1e66416f5200fb3d59d2da5e8ec149926d.1781361555.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 13 Jun 2026 16:55:49 +0200 Subject: [PATCH v3 04/12] tests/9p: add Tread / Rread test client functions To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Greg Kurz , Feifan Qian Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.189.157.229; envelope-from=049bdd1e66416f5200fb3d59d2da5e8ec149926d@kylie.crudebyte.com; helo=kylie.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_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1781364715203158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add v9fs_tread() and v9fs_rread() functions to the 9P test client for reading files from 9pfs server in test cases. Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/virtio-9p-client.c | 45 +++++++++++++++++++++++++++ tests/qtest/libqos/virtio-9p-client.h | 33 ++++++++++++++++++++ tests/qtest/virtio-9p-test.c | 1 + 3 files changed, 79 insertions(+) diff --git a/tests/qtest/libqos/virtio-9p-client.c b/tests/qtest/libqos/vir= tio-9p-client.c index af01d4c345..b9785ef8cb 100644 --- a/tests/qtest/libqos/virtio-9p-client.c +++ b/tests/qtest/libqos/virtio-9p-client.c @@ -241,6 +241,7 @@ static const char *rmessage_name(uint8_t id) id =3D=3D P9_RUNLINKAT ? "RUNLINKAT" : id =3D=3D P9_RFLUSH ? "RFLUSH" : id =3D=3D P9_RREADDIR ? "RREADDIR" : + id =3D=3D P9_RREAD ? "RREAD" : ""; } =20 @@ -1103,3 +1104,47 @@ void v9fs_runlinkat(P9Req *req) v9fs_req_recv(req, P9_RUNLINKAT); v9fs_req_free(req); } + +/* size[4] Tread tag[2] fid[4] offset[8] count[4] */ +TReadRes v9fs_tread(TReadOpt opt) +{ + P9Req *req; + uint32_t err; + + g_assert(opt.client); + + uint32_t body_size =3D 4 + 8 + 4; + + req =3D v9fs_req_init(opt.client, body_size, P9_TREAD, opt.tag); + v9fs_uint32_write(req, opt.fid); + v9fs_uint64_write(req, opt.offset); + v9fs_uint32_write(req, opt.count); + v9fs_req_send(req); + + if (!opt.requestOnly) { + v9fs_req_wait_for_reply(req, NULL); + if (opt.expectErr) { + v9fs_rlerror(req, &err); + g_assert_cmpint(err, =3D=3D, opt.expectErr); + } else { + v9fs_rread(req, opt.rread.count, opt.rread.data); + } + req =3D NULL; /* request was freed */ + } + + return (TReadRes) { + .req =3D req, + .count =3D opt.rread.count ? *opt.rread.count : 0 + }; +} + +/* size[4] Rread tag[2] count[4] data[count] */ +void v9fs_rread(P9Req *req, uint32_t *count, void *data) +{ + v9fs_req_recv(req, P9_RREAD); + v9fs_uint32_read(req, count); + if (data && *count > 0) { + v9fs_memread(req, data, *count); + } + v9fs_req_free(req); +} diff --git a/tests/qtest/libqos/virtio-9p-client.h b/tests/qtest/libqos/vir= tio-9p-client.h index e3221a3104..37f2517cff 100644 --- a/tests/qtest/libqos/virtio-9p-client.h +++ b/tests/qtest/libqos/virtio-9p-client.h @@ -473,6 +473,37 @@ typedef struct TunlinkatRes { P9Req *req; } TunlinkatRes; =20 +/* options for 'Tread' 9p request */ +typedef struct TReadOpt { + /* 9P client being used (mandatory) */ + QVirtio9P *client; + /* user supplied tag number being returned with response (optional) */ + uint16_t tag; + /* file ID of file to read from (required) */ + uint32_t fid; + /* start position of read from beginning of file (optional) */ + uint64_t offset; + /* how many bytes to read (required) */ + uint32_t count; + /* data being received from 9p server as 'Rread' response (optional) */ + struct { + uint32_t *count; + void *data; + } rread; + /* only send Tread request but not wait for a reply? (optional) */ + bool requestOnly; + /* do we expect an Rlerror response, if yes which error code? (optiona= l) */ + uint32_t expectErr; +} TReadOpt; + +/* result of 'Tread' 9p request */ +typedef struct TReadRes { + /* if requestOnly was set: request object for further processing */ + P9Req *req; + /* amount of bytes read */ + uint32_t count; +} TReadRes; + void v9fs_set_allocator(QGuestAllocator *t_alloc); void v9fs_memwrite(P9Req *req, const void *addr, size_t len); void v9fs_memskip(P9Req *req, size_t len); @@ -524,5 +555,7 @@ TlinkRes v9fs_tlink(TlinkOpt); void v9fs_rlink(P9Req *req); TunlinkatRes v9fs_tunlinkat(TunlinkatOpt); void v9fs_runlinkat(P9Req *req); +TReadRes v9fs_tread(TReadOpt opt); +void v9fs_rread(P9Req *req, uint32_t *count, void *data); =20 #endif diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 1c69d41e33..8ccec77e70 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -31,6 +31,7 @@ #define tsymlink(...) v9fs_tsymlink((TsymlinkOpt) __VA_ARGS__) #define tlink(...) v9fs_tlink((TlinkOpt) __VA_ARGS__) #define tunlinkat(...) v9fs_tunlinkat((TunlinkatOpt) __VA_ARGS__) +#define tread(...) v9fs_tread((TReadOpt) __VA_ARGS__) =20 static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc) { --=20 2.47.3 From nobody Sun Jul 26 13:25:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1781364721; cv=none; d=zohomail.com; s=zohoarc; b=lW8YucCDBVx5+jQcRPK0TeW/n7ZeownaEaX0IvKbltKnK+FA/2pnQ9aAmxbKSt/2GABu6P7ApUjD2wbuKIol6L4ErXqPKOLx5CbLckHxjoQauhWhhiSS/gM8iXSET4YvSl/eEOC4EoTAAbfcG+z3ICbj1VxcuiUYXenj0TObaL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781364721; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8z6iKW8YNi1KKFTG5t1wGDQ446H2qhx33nkQX+TXy8E=; b=GyUJ2yC0Uf/SG+oRJ5eIjU0eycwmzKe7c/eDSjXUpVq+CrSbi9GGA6rAXR0No7m1sJtL2DxklgSB+U72V+ohyqa5o6QuVbbjssv+63EFdu5NoE8RK3HCE28v8NKAMtgU+UsybJg4wRU6gVwxDlPyTzPMju5NFAQX1AhHD9YJpj0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781364721418499.3325334785943; Sat, 13 Jun 2026 08:32:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wYQJR-0007z7-Jv; Sat, 13 Jun 2026 11:30:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wYQJL-0007u4-D5; Sat, 13 Jun 2026 11:30:15 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wYQJJ-0005EM-Pb; Sat, 13 Jun 2026 11:30:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=8z6iKW8YNi1KKFTG5t1wGDQ446H2qhx33nkQX+TXy8E=; b=jacz8 DEnZq/0+rpG+WlmzOMtn46ds2rcnW56AlXdzB2uLxvVTvHdAO6yCWfdRp2KpCx8xeHthDjnGbF9IO 5/J4LqGQs3BuSyrXg5O9VSAptBsGuv4kVRqTeLdZg6pBOp5kPOS3z64iuIIaOOF/f6PIfhLNOpqXD HiMmaPpjRq87aFQKaT2k5uguwAB96kUOSV7C0z4DpVct8hy7mPDKIPkwH28FtWCJ2z2nUrh2N/p21 o9/oM0Ion7QqUaB0l9Bjg8Yq2TrETEndpv72uMWTlIa9UozjgYoSoQ1n2NVu+Ns/B7Wypoovvq2Jy ZMUXNlfmx+obx8WDjd40jcZElWF4U058VFNcusATb7UvuRQyigw8mBpQsJLjLNncJ3RfLuvBv5YQp hWDwOwEa+/+oNAuVXPvyNcvHWGTkptSuLHJ5QCs+0gmjaV8NT6CAkVxddXxuOi2e5mbNoDyy6VFjJ 2dmcts1FJowzm2n0tYlQRFaKUhEyBG4dQOi4HNLyRrKdJ7EevhQfdfNE7wVLhwSGBKuMCdl4+VlfC wV2gs/PNEMlnh6sq42C0UwlekI/Gl5KVRx1/349gYJsJLat9wV40wagBmyIkm/fhKt/Jz5edlDO4t y9c/JLGU5K3ZaUkFceVGN3qxPW+BDttn398c/6j9QotM8F9M1dbukogWTJRSeQ=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 13 Jun 2026 16:55:49 +0200 Subject: [PATCH v3 05/12] tests/9p: add Tclunk / Rclunk test client functions To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Greg Kurz , Feifan Qian Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.189.157.229; envelope-from=d53f0337eb7f8525a14e394599d809ecf6805e5e@kylie.crudebyte.com; helo=kylie.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_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1781364723050158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add v9fs_tclunk() and v9fs_rclunk() functions to the 9P test client for closing file handles (or "FIDs") in test cases. Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/virtio-9p-client.c | 34 +++++++++++++++++++++++++++ tests/qtest/libqos/virtio-9p-client.h | 22 +++++++++++++++++ tests/qtest/virtio-9p-test.c | 1 + 3 files changed, 57 insertions(+) diff --git a/tests/qtest/libqos/virtio-9p-client.c b/tests/qtest/libqos/vir= tio-9p-client.c index b9785ef8cb..83af6dab5d 100644 --- a/tests/qtest/libqos/virtio-9p-client.c +++ b/tests/qtest/libqos/virtio-9p-client.c @@ -242,6 +242,7 @@ static const char *rmessage_name(uint8_t id) id =3D=3D P9_RFLUSH ? "RFLUSH" : id =3D=3D P9_RREADDIR ? "RREADDIR" : id =3D=3D P9_RREAD ? "RREAD" : + id =3D=3D P9_RCLUNK ? "RCLUNK" : ""; } =20 @@ -1148,3 +1149,36 @@ void v9fs_rread(P9Req *req, uint32_t *count, void *d= ata) } v9fs_req_free(req); } + +/* size[4] Tclunk tag[2] fid[4] */ +TClunkRes v9fs_tclunk(TClunkOpt opt) +{ + P9Req *req; + uint32_t err; + + g_assert(opt.client); + + req =3D v9fs_req_init(opt.client, 4, P9_TCLUNK, opt.tag); + v9fs_uint32_write(req, opt.fid); + v9fs_req_send(req); + + if (!opt.requestOnly) { + v9fs_req_wait_for_reply(req, NULL); + if (opt.expectErr) { + v9fs_rlerror(req, &err); + g_assert_cmpint(err, =3D=3D, opt.expectErr); + } else { + v9fs_rclunk(req); + } + req =3D NULL; /* request was freed */ + } + + return (TClunkRes) { .req =3D req }; +} + +/* size[4] Rclunk tag[2] */ +void v9fs_rclunk(P9Req *req) +{ + v9fs_req_recv(req, P9_RCLUNK); + v9fs_req_free(req); +} diff --git a/tests/qtest/libqos/virtio-9p-client.h b/tests/qtest/libqos/vir= tio-9p-client.h index 37f2517cff..f7ef7f0067 100644 --- a/tests/qtest/libqos/virtio-9p-client.h +++ b/tests/qtest/libqos/virtio-9p-client.h @@ -504,6 +504,26 @@ typedef struct TReadRes { uint32_t count; } TReadRes; =20 +/* options for 'Tclunk' 9p request */ +typedef struct TClunkOpt { + /* 9P client being used (mandatory) */ + QVirtio9P *client; + /* user supplied tag number being returned with response (optional) */ + uint16_t tag; + /* file ID to clunk (required) */ + uint32_t fid; + /* only send Tclunk request but not wait for a reply? (optional) */ + bool requestOnly; + /* do we expect an Rlerror response, if yes which error code? (optiona= l) */ + uint32_t expectErr; +} TClunkOpt; + +/* result of 'Tclunk' 9p request */ +typedef struct TClunkRes { + /* if requestOnly was set: request object for further processing */ + P9Req *req; +} TClunkRes; + void v9fs_set_allocator(QGuestAllocator *t_alloc); void v9fs_memwrite(P9Req *req, const void *addr, size_t len); void v9fs_memskip(P9Req *req, size_t len); @@ -557,5 +577,7 @@ TunlinkatRes v9fs_tunlinkat(TunlinkatOpt); void v9fs_runlinkat(P9Req *req); TReadRes v9fs_tread(TReadOpt opt); void v9fs_rread(P9Req *req, uint32_t *count, void *data); +TClunkRes v9fs_tclunk(TClunkOpt opt); +void v9fs_rclunk(P9Req *req); =20 #endif diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 8ccec77e70..099c5e0ca0 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -32,6 +32,7 @@ #define tlink(...) v9fs_tlink((TlinkOpt) __VA_ARGS__) #define tunlinkat(...) v9fs_tunlinkat((TunlinkatOpt) __VA_ARGS__) #define tread(...) v9fs_tread((TReadOpt) __VA_ARGS__) +#define tclunk(...) v9fs_tclunk((TClunkOpt) __VA_ARGS__) =20 static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc) { --=20 2.47.3 From nobody Sun Jul 26 13:25:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1781364680; cv=none; d=zohomail.com; s=zohoarc; b=SQ2+QAyyih6jibRFzqk/5HPmEhaekF0uTkiCK9UfdFdMpZpVBWtQyzAMJOp4jB94xw0LSVTcr2lJSgZstdUguDvY0qjhLxquRy6nZmb09sW3TGpOrQewvw9jtYrpPuOgVZ4wR7UZBVC4SYMVGjEPyGGL/pV77ygioDOQ0bl4rJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781364680; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BUH244s3Gt7moinlYKDoR8pCKz0Kbx4PwxJ54VEws+w=; b=KjgNaPTxlE9EZh3O2jp//yjwWER+0vu2AZgLZlTj1BBzckSYwZrOfGJIg1T9N8egPXOtCI4Rcj6AspYtRhHaEr4bDZXlddOcmQeIw0MXKl7RU27jOyGrm3DbM3FzaFuybEVc//hawYIwRBFjI508gdzaH1AMXdnPmF8QpxRfjsY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781364680728693.4713567924323; Sat, 13 Jun 2026 08:31:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wYQJl-000865-CT; Sat, 13 Jun 2026 11:30:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <5dbc5061dab1f7829fffc40bf89d7ff443e4bcab@kylie.crudebyte.com>) id 1wYQJj-00085j-PI; Sat, 13 Jun 2026 11:30:39 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <5dbc5061dab1f7829fffc40bf89d7ff443e4bcab@kylie.crudebyte.com>) id 1wYQJi-0005W3-68; Sat, 13 Jun 2026 11:30:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=BUH244s3Gt7moinlYKDoR8pCKz0Kbx4PwxJ54VEws+w=; b=B8hnb hVwdmRsI90cHhTnhEi7UHAEFfHRVX0Luf6yb8zJUswEyKqLdNUPLXxY0nccE7/7RlG0+OAXgfWHDR cG01DTREicmcRQfG3chx2oIM3b7y0HUmZ3fNMXaNySBnyD0OMAG15rB1px0h0nr25w7pV+t8z3qoi 9V1oTtDPfaGfntAo0cZUf4wI3gUHS3XFKErRdE3VKKgZX/81k72gBVUWgbRNNPnHJKIiPow0dj/ER B9xfb4KiGoe4g9WmF7Ql0Q4P7p/xW/G5aYgpw15wrPHO12geIQVTMl6nRUe0fXw006D5YuRiJQTK3 7QLwoguiTvl9tksoKD4a+bx4QtG7UdkuRrIDa5i+uvTbpFVoFcU/2skuvseKLhWvFV9ujYx3ZiXqr bhILIy7lQQI/j5i9ADQrrKuo/uJukFNGB4lVF6IX/jMmMfnZJ5CWmOZFOkfUh+VeI5jkCy7jouKJv 1PuoULZsfbpwRj1oozxjlXRicLI/UCVYDKHO9AEaXGkffn1WSyTMMxC9o12H8fdxwcw62e6Uyg8c0 eyp1m87taEN3BKsY2iPDJ1tI7OuD908XoDTMEb0DWga55Q8jqvhoLmbPqHKb/yUZ8jMZuWAGUpC5+ eQ6BcEt3dBrnqV+8OQzLCj6yG5u44HWw4UjeRnJsk6mokSpxaM9BD4BHbBdYi4=; Message-ID: <5dbc5061dab1f7829fffc40bf89d7ff443e4bcab.1781361555.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 13 Jun 2026 16:55:49 +0200 Subject: [PATCH v3 06/12] tests/9p: add Txattrcreate / Rxattrcreate test client functions To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Greg Kurz , Feifan Qian Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.189.157.229; envelope-from=5dbc5061dab1f7829fffc40bf89d7ff443e4bcab@kylie.crudebyte.com; helo=kylie.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_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1781364683401158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add v9fs_txattrcreate() and v9fs_rxattrcreate() functions to the 9P test client for testing creation of xattrs with 9pfs server. Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/virtio-9p-client.c | 45 +++++++++++++++++++++++++++ tests/qtest/libqos/virtio-9p-client.h | 30 ++++++++++++++++++ tests/qtest/virtio-9p-test.c | 1 + 3 files changed, 76 insertions(+) diff --git a/tests/qtest/libqos/virtio-9p-client.c b/tests/qtest/libqos/vir= tio-9p-client.c index 83af6dab5d..305b0dac63 100644 --- a/tests/qtest/libqos/virtio-9p-client.c +++ b/tests/qtest/libqos/virtio-9p-client.c @@ -243,6 +243,7 @@ static const char *rmessage_name(uint8_t id) id =3D=3D P9_RREADDIR ? "RREADDIR" : id =3D=3D P9_RREAD ? "RREAD" : id =3D=3D P9_RCLUNK ? "RCLUNK" : + id =3D=3D P9_RXATTRCREATE ? "RXATTRCREATE" : ""; } =20 @@ -1182,3 +1183,47 @@ void v9fs_rclunk(P9Req *req) v9fs_req_recv(req, P9_RCLUNK); v9fs_req_free(req); } + +/* size[4] Txattrcreate tag[2] fid[4] name[s] attr_size[8] flags[4] */ +TXattrCreateRes v9fs_txattrcreate(TXattrCreateOpt opt) +{ + P9Req *req; + uint32_t err; + + g_assert(opt.client); + g_assert(opt.name); + + uint32_t body_size =3D 4 + 8 + 4; + uint16_t string_size =3D v9fs_string_size(opt.name); + + g_assert_cmpint(body_size, <=3D, UINT32_MAX - string_size); + body_size +=3D string_size; + + req =3D v9fs_req_init(opt.client, body_size, P9_TXATTRCREATE, opt.tag); + v9fs_uint32_write(req, opt.fid); + v9fs_string_write(req, opt.name); + v9fs_uint64_write(req, opt.size); + v9fs_uint32_write(req, opt.flags); + v9fs_req_send(req); + + err =3D 0; + if (!opt.requestOnly) { + v9fs_req_wait_for_reply(req, NULL); + if (opt.expectErr) { + v9fs_rlerror(req, &err); + g_assert_cmpint(err, =3D=3D, opt.expectErr); + } else { + v9fs_rxattrcreate(req); + } + req =3D NULL; /* request was freed */ + } + + return (TXattrCreateRes) { .req =3D req, .err =3D err }; +} + +/* size[4] Rxattrcreate tag[2] */ +void v9fs_rxattrcreate(P9Req *req) +{ + v9fs_req_recv(req, P9_RXATTRCREATE); + v9fs_req_free(req); +} diff --git a/tests/qtest/libqos/virtio-9p-client.h b/tests/qtest/libqos/vir= tio-9p-client.h index f7ef7f0067..c432b0daee 100644 --- a/tests/qtest/libqos/virtio-9p-client.h +++ b/tests/qtest/libqos/virtio-9p-client.h @@ -524,6 +524,34 @@ typedef struct TClunkRes { P9Req *req; } TClunkRes; =20 +/* options for 'Txattrcreate' 9p request */ +typedef struct TXattrCreateOpt { + /* 9P client being used (mandatory) */ + QVirtio9P *client; + /* user supplied tag number being returned with response (optional) */ + uint16_t tag; + /* file ID to convert to xattr fid (required) */ + uint32_t fid; + /* name of the xattr (required) */ + const char *name; + /* size of the xattr value (required) */ + uint64_t size; + /* flags: P9_XATTR_CREATE or P9_XATTR_REPLACE (optional) */ + uint32_t flags; + /* only send Txattrcreate request but not wait for a reply? (optional)= */ + bool requestOnly; + /* do we expect an Rlerror response, if yes which error code? (optiona= l) */ + uint32_t expectErr; +} TXattrCreateOpt; + +/* result of 'Txattrcreate' 9p request */ +typedef struct TXattrCreateRes { + /* if requestOnly was set: request object for further processing */ + P9Req *req; + /* error code if Rlerror received */ + uint32_t err; +} TXattrCreateRes; + void v9fs_set_allocator(QGuestAllocator *t_alloc); void v9fs_memwrite(P9Req *req, const void *addr, size_t len); void v9fs_memskip(P9Req *req, size_t len); @@ -579,5 +607,7 @@ TReadRes v9fs_tread(TReadOpt opt); void v9fs_rread(P9Req *req, uint32_t *count, void *data); TClunkRes v9fs_tclunk(TClunkOpt opt); void v9fs_rclunk(P9Req *req); +TXattrCreateRes v9fs_txattrcreate(TXattrCreateOpt opt); +void v9fs_rxattrcreate(P9Req *req); =20 #endif diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 099c5e0ca0..99a897b158 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -33,6 +33,7 @@ #define tunlinkat(...) v9fs_tunlinkat((TunlinkatOpt) __VA_ARGS__) #define tread(...) v9fs_tread((TReadOpt) __VA_ARGS__) #define tclunk(...) v9fs_tclunk((TClunkOpt) __VA_ARGS__) +#define txattrcreate(...) v9fs_txattrcreate((TXattrCreateOpt) __VA_ARGS__) =20 static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc) { --=20 2.47.3 From nobody Sun Jul 26 13:25:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1781364772; cv=none; d=zohomail.com; s=zohoarc; b=g/SII0LZ+sBUFCUVbpn7jRjBob68RsoPdOAo2wdb+cr3iAdiLxrTBANJlNFk0DWSkTVU6eOKBgd84LwBRocPViAzTGa/gLi7N/dCiJ8m2gitEEeOf3F5K+MepZREkV9hXqWLQHOViAl5sCjT2k+IciPN2y0aEnlcRjsXgtrwF9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781364772; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sp0WkOTMIe228ItB5HcjR8cQW87AIQqOYxQTM+5MspM=; b=RpNNUEFLqV/yytBqvPAzxGPaaCcTcAqsNUuslWUzifGIpqgy+ffvSxvwdrTzMFte1RycUjNGSXxp3SnckfKiunhq9J0w3OUuY6pIRcCOEPZebMubsJjuvJx90Go7wqnP/UVInTvbHEGF0AyZHyuZRK5Ws1j3hvFllJ0UmgDxT48= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781364772674725.3673786123787; Sat, 13 Jun 2026 08:32:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wYQJY-00081t-Ix; Sat, 13 Jun 2026 11:30:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <9c1c7128135f3bd9c2f62a3f64bb730b6a94ec7a@kylie.crudebyte.com>) id 1wYQJT-0007zi-91; Sat, 13 Jun 2026 11:30:23 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <9c1c7128135f3bd9c2f62a3f64bb730b6a94ec7a@kylie.crudebyte.com>) id 1wYQJR-0005L3-UW; Sat, 13 Jun 2026 11:30:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=sp0WkOTMIe228ItB5HcjR8cQW87AIQqOYxQTM+5MspM=; b=xEjSp UnEU9TeO7VvNua2A2XR/XvNgvZoVHRcR2shueNWtb4e50fGFON/7lMlb5Ww6fdpUa8dkGRHhdkl1p d5OtQGdLE7tF0+loa8u8ALLu6yj/8CiPl53ANRfK2L3BF+3/g5QMjxDNB87cpuO219Lyf1ahCWdid /9oYPg85bEH2tcLSZa/F3ayREhJieSNZ433twLjOac/P5+AmA6K2q6/87FMbxQVAL5neROy075acR CmrnwmlnLKDmqrOUWY+YzXd9NkfrycupKvu3kJ4oqQSVo4KushrhsZ19tHCwIwz3++r/ra3qxIGr/ ynn05+8LUjPIekvLi63hyi3cNxP6yfenYWpWix2S41HoxkA2+QXEbbPJ6iYDg2MQEARekz2/j6X2t pfWqc8bAZemj0OfgBNdlLv31eWS2uHNyTZ+3qQ+HR1chHxcG4DK2EBxqIzUdq7KVmeWocjlNYZk4X 8xDnGGFOqJihZPDdPVRbpONd+SsyQspWOuyqp4/YpcSYJB2XLrw/5XwoyA8JxUvsKFg/7mQXJH0/8 K+KDGNbfOiMgcpR41nNVivzFr1iiGJmuF3REUmhaJ/II1IjckiZatizAjJV8zUyCXR+fQd+DHq88m +Y+F8tWoblqxBBGoZOWLise4RBtetDJoontFgIQWMz61Izdkuwje1Ikt8tlh64=; Message-ID: <9c1c7128135f3bd9c2f62a3f64bb730b6a94ec7a.1781361555.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 13 Jun 2026 16:55:49 +0200 Subject: [PATCH v3 07/12] hw/9pfs: enable xattr (mockup) support for synth fs driver To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Greg Kurz , Feifan Qian Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.189.157.229; envelope-from=9c1c7128135f3bd9c2f62a3f64bb730b6a94ec7a@kylie.crudebyte.com; helo=kylie.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_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1781364773406158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The synth backend is used for testing only. Enable xattr operations by making lsetxattr and lremovexattr callbacks to return success result. They are still actually not doing anything, they just pretend to be working to prevent 9pfs server from erroring out on xattr requests. This allows the subsequent test case patches to verify xattr FID limit enforcement. Signed-off-by: Christian Schoenebeck --- hw/9pfs/9p-synth.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index 322dc3bb69..4b0732e093 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -477,15 +477,15 @@ static int synth_lsetxattr(FsContext *ctx, V9fsPath *= path, const char *name, void *value, size_t size, int flags) { - errno =3D ENOTSUP; - return -1; + /* pretend it worked */ + return 0; } =20 static int synth_lremovexattr(FsContext *ctx, V9fsPath *path, const char *name) { - errno =3D ENOTSUP; - return -1; + /* pretend it worked */ + return 0; } =20 static int synth_name_to_path(FsContext *ctx, V9fsPath *dir_path, --=20 2.47.3 From nobody Sun Jul 26 13:25:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1781364724; cv=none; d=zohomail.com; s=zohoarc; b=Ej8brZXZegZGZn6eNIF2mXS/C+Ge6BVFpXA049BCR6uFCS6AxY5ssynDRx4rRCsb1zQ7mlBonmxCan7OBXJWVVqftQ4SWdp/AvwkbQ9MOckML0FtmqtwWZFlwrFadjPmdCBSvqpAJ31Ulv7xFXDLPyFk4HaMp/8Re1cur5cbYqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781364724; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CJCZqEwpDo0kNpINRxGPflnSQ7lBBvvEzLU2Ny1xHJQ=; b=H37k/y7tOWTMsWC9XTN9mFex/2srH7qkEj1XLD5K3aaBsaoz0oJPKsgvoygknyfCek06H1oJuq523uoxCHQoTJ0xNECX1hkTuy0j/EEAtXUQhxTQeNh/SfYlZMEUgXkFQ3RZSSvnEdZfv3rPHhea4xLeqiJuwlHHOzMWeOb4Yik= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781364724041235.78255433274273; Sat, 13 Jun 2026 08:32:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wYQJe-00084V-Vh; Sat, 13 Jun 2026 11:30:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <357c20fc244c04dcbd36b13aa20a5c9b2034e9f0@kylie.crudebyte.com>) id 1wYQJd-00083m-0g; Sat, 13 Jun 2026 11:30:33 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <357c20fc244c04dcbd36b13aa20a5c9b2034e9f0@kylie.crudebyte.com>) id 1wYQJb-0005Qy-KG; Sat, 13 Jun 2026 11:30:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=CJCZqEwpDo0kNpINRxGPflnSQ7lBBvvEzLU2Ny1xHJQ=; b=bz3uJ 4oIpJm06elFs0Ct33WN+Oh9TU2PoK+/gQgsX4Wx4ePflfak16er0WqACffmpNjXau5j6O+Tt56qgl bFHwCwF4gLXJ0wpDyCv55xWaJpsSaYOhNCzIa1KYBCDvD1km42LCRP3ZoORO0/FK6txEj1Wj7bpn5 ZPhXrK216s4DoDzVTtFOcYTsV4DIjIJ0MFmof/6Qd1As0LAloAxPDpU6exsYQE5Liy33UpWwJGxRS PArcst/HyAIQjXRVrnNSXqDBB/CaZ+9ya0XPrMLAd1Ftl+scaBNYviMnOMygne0zLKq0MhwRGUSbN z6jDFQEc8X2z4a0cs9yVYhCP9ahvaHRmBl0kMJTXJeNvZp1Ro4m7JmFl6oLXELXJOC60bakaQkOW2 MqqHiPhgIv9CZwK3wd3DIbq31FNPCfZQgsZ9DxlArZ7YYdOkE2HExB+rDPJmSdlKc3mInbVQjz8vd Zu1BKZVzzeUqIo4agnYeTkENK+IW5Czng+fptO/5bomoAF3DTjnxm2xinkyPbMY0Xui9QL79kx2RK lCZBk3yFalNI6/+AsRFZTRI+e0fWJXIoug9SdEPpnwqrfnahmtHmdSHnNcNa7uwTMrTNzKpKdlbXK OZvLKRzgIZ3YHpfk8LMhGB/t3poJ8jqdyy0toKN74uKAN8nr1V+ltKQT47GAL0=; Message-ID: <357c20fc244c04dcbd36b13aa20a5c9b2034e9f0.1781361555.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 13 Jun 2026 16:55:49 +0200 Subject: [PATCH v3 08/12] hw/9pfs: add xattr count query interface to fs synth driver To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Greg Kurz , Feifan Qian Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.189.157.229; envelope-from=357c20fc244c04dcbd36b13aa20a5c9b2034e9f0@kylie.crudebyte.com; helo=kylie.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_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1781364725025158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a synthetic "/stat/xattr_count" file path that, if being read by 9p client, returns the 9p server internal xattr FID counter to client. This allows to test and verify that the xattr FID limit is being enforced correctly. Signed-off-by: Christian Schoenebeck --- hw/9pfs/9p-synth.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index 4b0732e093..3b3654b282 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -565,6 +565,19 @@ static ssize_t v9fs_synth_qtest_flush_write(void *buf,= int len, off_t offset, return 1; } =20 +/* transmits internal xattr counter to client */ +static ssize_t v9fs_synth_read_xattr_count(void *buf, int len, off_t offse= t, + void *arg) +{ + FsContext *ctx =3D arg; + size_t local_count =3D ctx->xattr_fid_count; + if (len < (int)sizeof(size_t)) { + return -ENOSPC; + } + memcpy(buf, &local_count, sizeof(size_t)); + return sizeof(size_t); +} + static int synth_init(FsContext *ctx, Error **errp) { QLIST_INIT(&synth_root.child); @@ -626,6 +639,19 @@ static int synth_init(FsContext *ctx, Error **errp) g_free(name); } } + + /* Directory for internal statistic queries */ + { + V9fsSynthNode *stat_dir =3D NULL; + ret =3D qemu_v9fs_synth_mkdir(NULL, 0755, "stat", &stat_dir); + assert(!ret); + + /* File for internal xattr count query */ + ret =3D qemu_v9fs_synth_add_file(stat_dir, 0444, "xattr_count", + v9fs_synth_read_xattr_count, + NULL, ctx); + assert(!ret); + } } =20 return 0; --=20 2.47.3 From nobody Sun Jul 26 13:25:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1781364728; cv=none; d=zohomail.com; s=zohoarc; b=dISN91liQy8qbqQzi1kMvqWai2KHEp6LYOJc1U5PDJgTNHotYeWSJWPMfuNhbLUqW6tDSks8LQ8B1hjkH87Qjz7iFO7wlP2Syev2BievdhcPTdbJZbCd6kBKS3R4gH148jeO8DZUEfqULFXuCb/80m7bYmYXYD+7EJTsz/7zzAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781364728; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QKz/pA4DSBTbw13vXd4yB2hXkK7fGrlgKI9R5osFqTs=; b=RxbkZIjxaeksCwU0lujvrB0Vh1rMeWcTymdXIF0d5Q9zAevOlS7zSgWhO+q46g3X0LGXmZJcuD3ihzjOOWh+8BxZ3lEp/ML7Dwl5vBQSroav/SN5l4kZULcYRZLmodoSM59Pe9ZM8iFRDn9xDQy2OJ8RduJ+lDz0eum9DvPdpoE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781364728618371.65317594999624; Sat, 13 Jun 2026 08:32:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wYQJp-00086u-Sk; Sat, 13 Jun 2026 11:30:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <2dcb1243c80ea97d085af5171785850cf012be36@kylie.crudebyte.com>) id 1wYQJm-00086L-U4; Sat, 13 Jun 2026 11:30:44 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <2dcb1243c80ea97d085af5171785850cf012be36@kylie.crudebyte.com>) id 1wYQJl-0005WT-FJ; Sat, 13 Jun 2026 11:30:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=QKz/pA4DSBTbw13vXd4yB2hXkK7fGrlgKI9R5osFqTs=; b=Ox8eL gdHvkm+ko3HxxbWMVEXaaje2oqc+4M9EtgWqYthwuXd0Kz+u48AJMBcl76EqHNE5C6wRLGfLn3GbU AFmX55SkbZhZDoFFlNUDAWHnDe38Vy9M0NN+0xqWlAjmtvRTs397R0ziJ0ngUSOBDBIDuxwdmliaz R4/bbc55vf+t6D0V3O4XyBx3hU4RPNC/lYNFCYTS0dogaWzF2z2ewFCEdT3Un0AxCevzHRrlsmZuS F9brSedC40s+IA1V4pe00HEaFBFUfMnAuKZgtW0hRAguntuf1mSVSZYmkl+38CvPby/Zuu26iSV7k 9MpcqkKJgINTX7iKUGrs+Qo1IGemiW//NXwBqTKj1vtLkj5+XSeAIjXOa4uKtZanZHznTPJoiWf24 kzfNU9DKwxkDKhC0LS0DK7JadeM4ekxZyB5m3SCxTiEVN2mmH+qa2rxfadIOTf7i61vuUY30l53OL G3OWSjibd12CzQBIskWQe/5bch79dafinVhJsvBoLRmMUrZG2iOWsomDvXzAsUFWPqkH4jYdeYB8r qwqfZJSwUsIcBnV8RRWgBdA/VeXfcmh+kJMtsIKpjLhGhbJmz1PYanpg4qS+EiauUtG7/1dkVdQDY pW1VjiZv7nJPBAPy8kRV51C7HlkrPDsCdPYWAAQK2puQoXAIFu0KO7jxRD7wVY=; Message-ID: <2dcb1243c80ea97d085af5171785850cf012be36.1781361555.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 13 Jun 2026 16:55:49 +0200 Subject: [PATCH v3 09/12] tests/9p: increase P9_MAX_SIZE for test client To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Greg Kurz , Feifan Qian Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.189.157.229; envelope-from=2dcb1243c80ea97d085af5171785850cf012be36@kylie.crudebyte.com; helo=kylie.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_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1781364729318158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Increase the maximum 9P message size ('msize') of 9p test client from 4k to 32k to support larger messages. This is needed for the xattr tests being added with the subsequent patches which are going to transmit xattrs of size 8k. It would have also been possible to send them in multiple chunks, however let's not overcomplicate things. This new msize is still reasonable small compared to common msize values on production systems. Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/virtio-9p-client.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/libqos/virtio-9p-client.h b/tests/qtest/libqos/vir= tio-9p-client.h index c432b0daee..4b04324503 100644 --- a/tests/qtest/libqos/virtio-9p-client.h +++ b/tests/qtest/libqos/virtio-9p-client.h @@ -21,7 +21,8 @@ #include "qgraph.h" #include "tests/qtest/libqtest-single.h" =20 -#define P9_MAX_SIZE 4096 /* Max size of a T-message or R-message */ +/* Max size of a T-message or R-message */ +#define P9_MAX_SIZE (32 * 1024) =20 typedef struct { QTestState *qts; --=20 2.47.3 From nobody Sun Jul 26 13:25:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1781364714; cv=none; d=zohomail.com; s=zohoarc; b=OwzQOCBmyez6xW6mZZZnVhds290H56ypmKCkPQs0SlhC4/4mATN7lOESA1KIOd/lf40NJovvvDpYJm1IUhQsyGYOAJ8yJ9ID2H2VGeYMG1g1qzBOBTsraCbagdi48/2vLaqnEhFNCmm6HnivRA7EafPfrMwXvuPEQmiHPr0z5gw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781364714; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vsAnzYnUkbJPIjTxynzHZ+ERTcjQW3lJwhEltlSR2jw=; b=S7VweVVhD//qvY9Pgu9pnugnIiP36LVmkRE85vD7qnFR0kFOq/nscjfSCWCzRPzVPCdiJxZFPkC7MiIe9JeNsX7HQDDQLzhzDR8pZpcaT2O4FD0/QdjCCYO0HAb3WU8vDt3BrjOZxObXMFZBz9nyVc7/B6++gzSX9RaZ7DT9HdY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781364714749284.0664391309325; Sat, 13 Jun 2026 08:31:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wYQJr-00087e-8O; Sat, 13 Jun 2026 11:30:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <7fe3eca5d17292464676b68d0513052564cd432a@kylie.crudebyte.com>) id 1wYQJp-00086x-UU; Sat, 13 Jun 2026 11:30:46 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <7fe3eca5d17292464676b68d0513052564cd432a@kylie.crudebyte.com>) id 1wYQJo-0005Ww-G9; Sat, 13 Jun 2026 11:30:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=vsAnzYnUkbJPIjTxynzHZ+ERTcjQW3lJwhEltlSR2jw=; b=VbSXe N0kZU3S+kNe68g53rExsqh0v4rHo6CfMXFPv74vTLfIq2jh27/dWJCnPCCnH75StMvDU/l8WCwrMM pI1eWVeNtJ2QCvJPiJo0j0F/ToU07ED+VJ1qLjlzwHY0dfdF/0NhsOW6tbawKS1cJymzlqlIeoW29 LFxXYp3bK9iNfHhMVA0g/NUi0RE8u4C2bTJvK89olJre+Efi6bJ1o34lfhDQl4o50aqQXoSJ8d59e oELTa3HvQnJ9mJcby/nNCOWzEMSZLMm1XX5u8LU6SEPi+DNhNvlXnx9D3nW/sc7qUkzwGm4O3jF2G kHGcnepnBGoPjZFIySLSxeW6nnXKDbN2bV6dJ6msqrVrBVv36yOB/7ydyKUfsIPSUgGowNtSwia8P Ib12NLi27ACW/pe1rXDCN4akGsKxP6v+gIpCTNf3CFGA9tJQB/KYLhSSbt5stBaVJXbbdlfm/HZjM retDU87i7bJNbxRJaH2nlu7Qi3i/pJmOHcK/rP2OE/+0+nxva9AjZglz4SFJCjTOnqVAjQh616b92 CiewWCabYRcpi2asGF4grA4x47W9o74NCs4ysE5rcsi0+93trTDYd7AShE2kMyB5v/0XOD16KOfBq I/Gr3PcpoX8eNpTQ41FEIpXvcehcOwqodj9VoI7ZXREALhAQ2+Itj6lfOA/7gM=; Message-ID: <7fe3eca5d17292464676b68d0513052564cd432a.1781361555.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 13 Jun 2026 16:55:49 +0200 Subject: [PATCH v3 10/12] tests/9p: add virtio_9p_add_synth_driver_args() test client function To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Greg Kurz , Feifan Qian Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.189.157.229; envelope-from=7fe3eca5d17292464676b68d0513052564cd432a@kylie.crudebyte.com; helo=kylie.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_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1781364715159158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add virtio_9p_add_synth_driver_args() to allow appending custom QEMU options for individual 9p synth tests. Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/virtio-9p.c | 6 ++++++ tests/qtest/libqos/virtio-9p.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c index 186fcc1141..823756de8c 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -228,6 +228,12 @@ static void regex_replace(GString *haystack, const cha= r *pattern, g_string_assign(haystack, s); } =20 +void virtio_9p_add_synth_driver_args(GString *cmd_line, const char *args) +{ + /* append passed args to '-fsdev ...' group */ + regex_replace(cmd_line, "(-fsdev \\w[^ ]*)", "\\1,%s", args); +} + void virtio_9p_assign_local_driver(GString *cmd_line, const char *args) { g_assert_nonnull(local_test_path); diff --git a/tests/qtest/libqos/virtio-9p.h b/tests/qtest/libqos/virtio-9p.h index 480727120e..e7efeef7a1 100644 --- a/tests/qtest/libqos/virtio-9p.h +++ b/tests/qtest/libqos/virtio-9p.h @@ -44,6 +44,12 @@ struct QVirtio9PDevice { QVirtio9P v9p; }; =20 +/** + * Add required test specific args to the QEMU command line for the 9pfs + * 'synth' fs driver. + */ +void virtio_9p_add_synth_driver_args(GString *cmd_line, const char *args); + /** * Creates the directory for the 9pfs 'local' filesystem driver to access. */ --=20 2.47.3 From nobody Sun Jul 26 13:25:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1781364763; cv=none; d=zohomail.com; s=zohoarc; b=alwbnhLQkp5vS6eRQeFAZTmVeRi10praILkaMdkEXwSO889vJKwJQo74OiBEC/7dVhkPG4SsO1oop3kXFrO1NgoiOUYbXXcmGq2h35GfFjwo8aujQD6xys3t5xprqyZKdSV7+y4HoWPGNp9goWqRkgVc59LtMVT3QkqurGNOEzY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781364763; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=f5dQ2tNqI9ayHMeWdYoVc8SEf+8Gv+EqgITBot4K7RI=; b=dCnb3t87UQ8X5i7IvptjjfDqK4xris5KN3eW648OJ1NNRcXEK3ULM/FvRy59CiOMehQu4Um7+4JZaBRGrI1TfImPOpGIginOKQgW6VLjgkgUfW1vyvJGK5ZqBkXo2WfQPSgx7Gn9yStQ3nNwMzmevqgmJcFZ+t4qwFU3DD4dYiE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781364763149476.1760125084446; Sat, 13 Jun 2026 08:32:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wYQJY-00081r-Gs; Sat, 13 Jun 2026 11:30:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <540c51faa074d9dd736bbf2170084a12288e23ef@kylie.crudebyte.com>) id 1wYQJP-0007yy-KK; Sat, 13 Jun 2026 11:30:19 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <540c51faa074d9dd736bbf2170084a12288e23ef@kylie.crudebyte.com>) id 1wYQJM-0005KK-U7; Sat, 13 Jun 2026 11:30:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=f5dQ2tNqI9ayHMeWdYoVc8SEf+8Gv+EqgITBot4K7RI=; b=a58pd Y/0g0OlmoS/0s/vfliXcL1XCIqbKK3tGS3gimYrwpyei1md89pNZ0pUsoiem+0V013w2xolBGhCQZ 5XUmq4dp4AZBG5awZZlHRF0Hs9TiPnnqAYQxpTOsHBS0I5O4T/zwFXKTJAdJneXfzrG7Y4nFwe3cW t6vrHE0d5FX/uJb+jwq+dHnVRIs1fSMKdKfSU8YmA4zh6x/ciacNbyB9n1P70Z1vRYKfHhcqY1mPM AnmvxHJ2XezkYRAsmnQdhX739NPfGBjp8uugxBTC+4qf+d3bN766fVIpWl0y7zNq62tv7ViWGjBKp +euONlXPMiKNpfUY/8QovFgNdDYPUW0SMQlGF+2ijC56LGlj7wCdYyTkANFKNPlftZ1D54NSpd1AL dz2wWgOYoZQKe/A2euIK5EtbgvXOKnDcDJI4Ftu3v0F8XKKK+8V7XdA6k01HYkZBgNL60rWtrRYj0 AYT0MtVndQhCTJdIRer5tUw+Q5D/YulLYCIlU2dyQoLz0qgh/zOtYaFCVoFV3/WK4tPgpPOuFqUYa ZuWHokFXfrPA9Zxxy1KcNfIlwcTzCU8rut1fz3SDCDkXf33LJBkGCZ92FSBtTO7XKH2VzXLIHU6sK Cvjiv5CmYPSD1kQdpbs1hi/oW4iugNDXblMLUkIDiINLvF4yA68/UK13WNNxWI=; Message-ID: <540c51faa074d9dd736bbf2170084a12288e23ef.1781361555.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 13 Jun 2026 16:55:49 +0200 Subject: [PATCH v3 11/12] tests/9p: add 3 xattr FID limit test cases (synth fs driver) To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Greg Kurz , Feifan Qian Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.189.157.229; envelope-from=540c51faa074d9dd736bbf2170084a12288e23ef@kylie.crudebyte.com; helo=kylie.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_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1781364765318158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add 3 test cases to verify correct xattr FID limit enforcement of 9pfs server. - 1. test with default max_xattr=3D1024 - 2. test with custom max_xattr=3D100 - 3. test with unlimited max_xattr=3D0 These are tests using the synth driver. Advantage: by using the synth driver the tests cannot only check when the xattr FID limit kicks in (server would return an Rlerror response with ENOSPC), but can also validate the current 9p server internal xattr FID counter at any moment. Signed-off-by: Christian Schoenebeck --- tests/qtest/virtio-9p-test.c | 189 ++++++++++++++++++++++++++++++++++- 1 file changed, 188 insertions(+), 1 deletion(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 99a897b158..2e88429dfa 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -35,6 +35,15 @@ #define tclunk(...) v9fs_tclunk((TClunkOpt) __VA_ARGS__) #define txattrcreate(...) v9fs_txattrcreate((TXattrCreateOpt) __VA_ARGS__) =20 +/* + * xattr size to be used for xattr tests + * + * 64k is the max. xattr size supported by the Linux kernel, However btrfs + * for instance supports only 16219 bytes. So let's be conservative and + * just use 8k for the xattr tests. + */ +#define TEST_XATTR_SIZE (8 * 1024) + static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc) { QVirtio9P *v9p =3D obj; @@ -107,6 +116,42 @@ static bool fs_dirents_contain_name(struct V9fsDirent = *e, const char* name) return false; } =20 +/* + * Returns the current internal xattr FID count (works with synth driver o= nly). + */ +static size_t get_xattr_count(QVirtio9P *v9p) +{ + uint16_t nwqid; + v9fs_qid *wqid; + const char *xattr_count_path[] =3D { "stat", "xattr_count" }; + size_t xattr_count; + uint32_t bytes_read; + + /* walk to /stat/xattr_count file */ + uint32_t fid =3D twalk({ + .client =3D v9p, .fid =3D 0, + .nwname =3D 2, .wnames =3D (char **)xattr_count_path, + .rwalk =3D { .nwqid =3D &nwqid, .wqid =3D &wqid } + }).newfid; + + /* open for read */ + tlopen({ + .client =3D v9p, .fid =3D fid, .flags =3D O_RDONLY, + .rlopen =3D { .qid =3D NULL, .iounit =3D NULL } + }); + + /* read the internal xattr FID count */ + tread({ + .client =3D v9p, .fid =3D fid, .offset =3D 0, .count =3D sizeof(xa= ttr_count), + .rread =3D { .count =3D &bytes_read, .data =3D &xattr_count } + }); + + /* cleanup */ + tclunk({ .client =3D v9p, .fid =3D fid }); + + return xattr_count; +} + /* basic readdir test where reply fits into a single response message */ static void fs_readdir(void *obj, void *data, QGuestAllocator *t_alloc) { @@ -248,6 +293,108 @@ static void do_readdir_split(QVirtio9P *v9p, uint32_t= count) g_free(wnames[0]); } =20 +/* + * Test 9p server's xattr FID count limit enforcement. + * + * Shared test code for both 'synth' and 'local' driver to verify correct + * behaviour of 9p server enforcing preconfigured xattr FID count limit + * correctly. + * + * @v9p: 9pfs client + * + * @max_xattr: max. allowed xattr FIDs, or -1 for infinite + * + * @check_counter: whether to verify 9p server internal xattr FID counter + * (only works with 'synth' fs driver) + */ +static void do_xattr_limit(QVirtio9P *v9p, int max_xattr, bool check_count= er) +{ + size_t count; + int i; + int limit =3D (max_xattr !=3D -1) ? max_xattr : V9FS_MAX_XATTR_DEFAULT= + 100; + g_autofree uint32_t *fids =3D g_new0(uint32_t, limit); + uint32_t err_fid =3D 0; + const char *file_path[] =3D { QTEST_V9FS_SYNTH_WRITE_FILE }; + g_autofree uint8_t *xattr_data =3D g_malloc(TEST_XATTR_SIZE); + + if (!g_test_slow()) { + g_test_skip("This is a slow test, run with -m slow"); + return; + } + + /* prepare xattr data with 'X' characters */ + memset(xattr_data, 'X', TEST_XATTR_SIZE); + + tattach({ .client =3D v9p }); + + /* create max. amount of permitted xattrs */ + for (i =3D 0; i < limit; i++) { + /* walk to create a new fid */ + fids[i] =3D twalk({ + .client =3D v9p, .fid =3D 0, + .nwname =3D 1, .wnames =3D (char **) file_path + }).newfid; + + /* create new xattr fid */ + txattrcreate({ + .client =3D v9p, .fid =3D fids[i], .name =3D "user.test", + .size =3D TEST_XATTR_SIZE, .flags =3D 0 + }); + + /* transfer the xattr data */ + twrite({ + .client =3D v9p, .fid =3D fids[i], .offset =3D 0, + .count =3D TEST_XATTR_SIZE, .data =3D xattr_data + }); + + /* verify server internal xattr counter */ + if (check_counter) { + count =3D get_xattr_count(v9p); + g_assert_cmpuint(count, =3D=3D, (i + 1)); + } + + /* avoid virtio descriptor exhaustion */ + qvirtqueue_reset_pool(v9p->vq); + } + + /* if xattrs are limited, the next xattr should fail */ + if (max_xattr !=3D -1) { + /* walk to create another fid */ + err_fid =3D twalk({ + .client =3D v9p, .fid =3D 0, + .nwname =3D 1, .wnames =3D (char **) file_path + }).newfid; + + /* try to create one more xattr fid - should fail */ + txattrcreate({ + .client =3D v9p, .fid =3D err_fid, .name =3D "user.test_exceed= ", + .size =3D TEST_XATTR_SIZE, .flags =3D 0, + .expectErr =3D ENOSPC + }); + + /* verify internal xattr counter hasn't changed */ + if (check_counter) { + count =3D get_xattr_count(v9p); + g_assert_cmpuint(count, =3D=3D, limit); + } + } + + /* clunk all fids (should decrement xattr counter) */ + for (i =3D 0; i < limit; i++) { + tclunk({ .client =3D v9p, .fid =3D fids[i] }); + qvirtqueue_reset_pool(v9p->vq); + } + if (err_fid) { + tclunk({ .client =3D v9p, .fid =3D err_fid }); + } + + /* verify internal xattr counter is zero */ + if (check_counter) { + count =3D get_xattr_count(v9p); + g_assert_cmpuint(count, =3D=3D, 0); + } +} + static void fs_walk_no_slash(void *obj, void *data, QGuestAllocator *t_all= oc) { QVirtio9P *v9p =3D obj; @@ -508,6 +655,27 @@ static void fs_readdir_split_512(void *obj, void *data, do_readdir_split(obj, 512); } =20 +static void fs_synth_xattr_limit_default(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + v9fs_set_allocator(t_alloc); + do_xattr_limit(obj, V9FS_MAX_XATTR_DEFAULT, true); +} + +static void fs_synth_xattr_limit_custom(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + v9fs_set_allocator(t_alloc); + do_xattr_limit(obj, 100, true); +} + +static void fs_synth_xattr_limit_unlimited(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + v9fs_set_allocator(t_alloc); + do_xattr_limit(obj, -1, true); +} + =20 /* tests using the 9pfs 'local' fs driver */ =20 @@ -822,6 +990,18 @@ static void fs_deep_absolute_path(void *obj, void *dat= a, g_string_free(path, TRUE); } =20 +static void *synth_max_xattr_custom_opt(GString *cmd_line, void *arg) +{ + virtio_9p_add_synth_driver_args(cmd_line, "max_xattr=3D100"); + return arg; +} + +static void *synth_max_xattr_unlimited_opt(GString *cmd_line, void *arg) +{ + virtio_9p_add_synth_driver_args(cmd_line, "max_xattr=3D0"); + return arg; +} + static void cleanup_9p_local_driver(void *data) { /* remove previously created test dir when test is completed */ @@ -872,7 +1052,14 @@ static void register_virtio_9p_test(void) fs_readdir_split_256, &opts); qos_add_test("synth/readdir/split_128", "virtio-9p", fs_readdir_split_128, &opts); - + qos_add_test("synth/xattr_limit/default", "virtio-9p", + fs_synth_xattr_limit_default, &opts); + opts.before =3D synth_max_xattr_custom_opt; + qos_add_test("synth/xattr_limit/custom", "virtio-9p", + fs_synth_xattr_limit_custom, &opts); + opts.before =3D synth_max_xattr_unlimited_opt; + qos_add_test("synth/xattr_limit/unlimited", "virtio-9p", + fs_synth_xattr_limit_unlimited, &opts); =20 /* 9pfs test cases using the 'local' filesystem driver */ opts.before =3D assign_9p_local_driver; --=20 2.47.3 From nobody Sun Jul 26 13:25:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1781364680; cv=none; d=zohomail.com; s=zohoarc; b=QwQp74Vev3tBRjkzVeS1KbyBjcZ3iLziFMWcgUSFL8LsCFRL4DLsTVW+B/6Xgwxi0Fmvzqw7wMcVuwfH55P8gAgykIeX+9lfYeGak0aiTvPePDgW9XTVv0+efcxLXIHn6zmKHXBVzitVqAusoybjCeX6XpM+JihGM2CVQhrhEJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781364680; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MWlpbE08GXlDYt8JMqUz5IxImg8f7uePGr6YufhCcc4=; b=Ow1xXYVepmbJjLjEgLnSTkw3VRTiCDocrY2M5sYG+sWtnZo59/FokNFPww9h5mjVJXfyuKqlh9ghbA5ay1QyzibDJnw1OBUW+4+GBNpM393cEQveDJaSkTtl3AhHhVUFWbJPN7IEAHPZ3yHJmin7aGS1wYruV7//7MZUcrBMTuc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781364680707117.73896906741072; Sat, 13 Jun 2026 08:31:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wYQJu-00088o-UO; Sat, 13 Jun 2026 11:30:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wYQJt-00088A-1d; Sat, 13 Jun 2026 11:30:49 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wYQJr-0005Xg-EN; Sat, 13 Jun 2026 11:30:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=MWlpbE08GXlDYt8JMqUz5IxImg8f7uePGr6YufhCcc4=; b=U4AEc /vQjEtTx0wR+rjvAcjD0Z41FNSMGqF34cNufz4csa3vTOZ6CIWrQcNi7AUY8UnT1tlHe0F4JPCzkA BC+S9lVL/2Flyjzm532SKH77jzLQ304i951SSVKd6fVjmgW4JtdZtwTFSYQf7l4djMrJwXpnX9+uo 9/N7xhx/EdctuzE0lnEl3udLNa8nL2KqVBLy7zrfp5s617p8O8iGckNQH8rI1zBTeun5k1R9vjh9z +YyBp6vyn9I1MAfkpZk33v6Qjs62LHi3vlH5Z+YoxqbeY3DMmjXu0Ys5QFS28nodIbcs4hz5v1Eav ezFnwWQI3zenXvLbh/3zm7PmN4HMv0Lu2b05Y76z6uqMU3ctl2d3S1378RXfXGVtU2w8ubKe9tuGC GqNCtRaq+/9newMII4aPnG7JeNXICJc6swda2aXuUHoeEW69RuoPoXgf2O9KGfTyM75BLgbajV/Ej ZQ5Dm8rJWURsz1lh5hSnD56PdMdwqh4+988/dO15KMQjOjMLGv6vs2x2E8v4QjHSgBoiNxXoKMfiG 5W5R5k2uUvGvSzonq+ZQJFtPr68HBISkq1/MV1AQ+OrpTTVVNx/76GQsGvk37DTgxHxRrRtkviurF L75woSomLTcr+WkMZn1+oTZB+1csl+SY+ALXi7k+vtFCneb3KHSyQRbvQDiMxE=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Sat, 13 Jun 2026 16:55:49 +0200 Subject: [PATCH v3 12/12] tests/9p: add 3 xattr FID limit test cases (local fs driver) To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Greg Kurz , Feifan Qian Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.189.157.229; envelope-from=d23fa874df4f474ee7cbe738a35c1483426057f0@kylie.crudebyte.com; helo=kylie.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_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1781364683379158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Analogue to the previously added 3 synth tests, add (similar) 3 test cases using the "local" fs driver to verify correct xattr FID limit enforcement of 9pfs server with a real filesystem. These 3 new local tests use the shared test code of the previously added 3 synth tests. The only difference is that the local fs driver does not expose the current internal xattr FID counter, so we can't verify this with the local tests. Signed-off-by: Christian Schoenebeck --- tests/qtest/virtio-9p-test.c | 70 ++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 2e88429dfa..cfd3c02da4 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -395,6 +395,19 @@ static void do_xattr_limit(QVirtio9P *v9p, int max_xat= tr, bool check_counter) } } =20 +static void do_local_xattr_limit(QVirtio9P *v9p, int max_xattr) +{ + g_autofree char *test_file =3D virtio_9p_test_path("WRITE"); + + /* + * this file must be created for the test to work with the 'local' fs = driver + */ + g_file_set_contents(test_file, "", 0, NULL); + + /* the actual test code shared with the 'synth' fs driver tests */ + do_xattr_limit(v9p, max_xattr, false); +} + static void fs_walk_no_slash(void *obj, void *data, QGuestAllocator *t_all= oc) { QVirtio9P *v9p =3D obj; @@ -990,6 +1003,27 @@ static void fs_deep_absolute_path(void *obj, void *da= ta, g_string_free(path, TRUE); } =20 +static void fs_local_xattr_limit_default(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + v9fs_set_allocator(t_alloc); + do_local_xattr_limit(obj, V9FS_MAX_XATTR_DEFAULT); +} + +static void fs_local_xattr_limit_custom(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + v9fs_set_allocator(t_alloc); + do_local_xattr_limit(obj, 100); +} + +static void fs_local_xattr_limit_unlimited(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + v9fs_set_allocator(t_alloc); + do_local_xattr_limit(obj, -1); +} + static void *synth_max_xattr_custom_opt(GString *cmd_line, void *arg) { virtio_9p_add_synth_driver_args(cmd_line, "max_xattr=3D100"); @@ -1008,20 +1042,42 @@ static void cleanup_9p_local_driver(void *data) virtio_9p_remove_local_test_dir(); } =20 -static void *assign_9p_local_driver(GString *cmd_line, void *arg) +static void assign_9p_local_driver_with_args(GString *cmd_line, + const char *extra_opts) { /* make sure test dir for the 'local' tests exists */ virtio_9p_create_local_test_dir(); =20 - virtio_9p_assign_local_driver(cmd_line, "security_model=3Dmapped-xattr= "); + g_autofree char *opts =3D + (extra_opts) ? + g_strdup_printf("security_model=3Dmapped-xattr,%s", extra_opts= ) : + g_strdup("security_model=3Dmapped-xattr"); + + virtio_9p_assign_local_driver(cmd_line, opts); =20 g_test_queue_destroy(cleanup_9p_local_driver, NULL); +} + +static void *assign_9p_local_driver(GString *cmd_line, void *arg) +{ + assign_9p_local_driver_with_args(cmd_line, NULL); + return arg; +} + +static void *local_max_xattr_custom_opt(GString *cmd_line, void *arg) +{ + assign_9p_local_driver_with_args(cmd_line, "max_xattr=3D100"); + return arg; +} + +static void *local_max_xattr_unlimited_opt(GString *cmd_line, void *arg) +{ + assign_9p_local_driver_with_args(cmd_line, "max_xattr=3D0"); return arg; } =20 static void register_virtio_9p_test(void) { - QOSGraphTestOptions opts =3D { }; =20 @@ -1078,6 +1134,14 @@ static void register_virtio_9p_test(void) &opts); qos_add_test("local/deep_absolute_path", "virtio-9p", fs_deep_absolute_path, &opts); + qos_add_test("local/xattr_limit/default", "virtio-9p", + fs_local_xattr_limit_default, &opts); + opts.before =3D local_max_xattr_custom_opt; + qos_add_test("local/xattr_limit/custom", "virtio-9p", + fs_local_xattr_limit_custom, &opts); + opts.before =3D local_max_xattr_unlimited_opt; + qos_add_test("local/xattr_limit/unlimited", "virtio-9p", + fs_local_xattr_limit_unlimited, &opts); } =20 libqos_init(register_virtio_9p_test); --=20 2.47.3