From nobody Sun Jun 7 22:17:48 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=1780855305; cv=none; d=zohomail.com; s=zohoarc; b=ZQcw104ilVk8RXcGrn0bmJmJlTiRCmVFDjhu+Exqwz5DFRC7eiunBRHoRxDvZzxWBDM7N/mWKaClja3VbzdtvrFB/MqT1IuYqWho2SfYOj4ddyUOYk4sKd1B5zjYn6aqpNBgM7H1CnZONqj7xwYfCMV3sNFInglkwWlgsoZZuis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780855305; 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=iutDKaM1ZP7LrW6J12Ij5PXbPD63QjS7OhuGX2X6xvI=; b=Tbu4XuxKUWzCEm5dDDurS4xUfzQi9cbal4DsDVOSv5UsMPb6GPRJbCVq7j6kmVLHQrQePqT1QRKqX+Yjzc3L2fBY/qWmfG9m4mOeO+tGenv291bP84X7mPsaK4ICOCYerIb6VCsJa5hu0mELTNrysUaNSJM3GHpgZUVOXBeKk3s= 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 1780855305610600.494396647252; Sun, 7 Jun 2026 11:01:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWHm2-0000EJ-MR; Sun, 07 Jun 2026 13:59:02 -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 1wWHm1-0000Dw-1Z; Sun, 07 Jun 2026 13:59:01 -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 1wWHlz-0004IR-6I; Sun, 07 Jun 2026 13:59:00 -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=iutDKaM1ZP7LrW6J12Ij5PXbPD63QjS7OhuGX2X6xvI=; b=VXlTN 67tVRrqDQU5ow8GhIJzfd54r1eu0KJNtkdpPimWFzYMJwRt0E9pq/2qaETCCEkE9PWUWTFNeuOcBd hLW65IhGyDIx0PRgeqlsp+fLKoQqWkgvPxUj+G9fK0Yk/44mP8LOCbM3A98gn3ZbmwFlMGCS932jW 3eazchPx1sz3ULQu9saTy7wKzfC+/naGBBIzarBnsJuJu27v9fyu+etg0M8epKD5lCoKxiSBO7JAu rxoBpWzkNx9FwvqKSRUg0Q8oOQ9SwoMnZBajvNLIZeyLy4H8roiKBZjYNN7gClkm6ydrkhthrA447 aFVrpKv+va90NyK+REBW+n3KhNQ0LPiNcgzXsjLF45D6nxLggLQ9sF+//2ZgvPXWdOVZVqEe+APdF aS41TEyL7Wre2MyTfiQwBUE1tXCwFlZWjfWd4NvasmmtGPqJw7Ke35xbIZKen3yJU9uXwygrrD5vV FrdN3e6Nbtmogyvq3JMfgcANGvmbXnbO0kLlVqxyq0YtN0/n9s2TSb0EFmyLCwDpXTHB8BsMktUGO U/U3pVaADDeN/1AFx9TVIu7GxywvvAzm5qdW83UjiQhWULQNhX93I1HQTjQtwp26rGi/lWcPiPml1 x6pWRCHdcVIovpFeFv919VeN0PtO1AUftAfYqUH5GIodXx79vC1OW1ytIg3usc=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 07 Jun 2026 19:22:19 +0200 Subject: [PATCH 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=e78b7c21000e90ffcb7f74a2eb8adc39dae68b89@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: 1780855306722154100 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 | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h index e8d0661c4b..d67c4687b3 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 simultaniously 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 simultaniously 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..10e2e53c01 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -265,6 +265,29 @@ 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) { + 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 +420,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 +658,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 +4038,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 +4053,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 +4080,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 +4095,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 +4197,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 +4464,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 Jun 7 22:17:48 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=1780855266; cv=none; d=zohomail.com; s=zohoarc; b=Ceuk157KnBkeN0w4lgBZ637OwybGTktTgT+8vSw1ngjCvcfBZaEGVlzsWA+59uGQM6VDf2cFZYm6DVWM6pZfkYl2ErQk+APHr8eZVpbXJIsM4IeoO3B6RLS1/IfhyTaH6SlFMORt7ySNfzBfjTWPKPr+QZbu2YFD1xJlq7H0wv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780855266; 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=Aa5phmjF26iLIol4VbMlxdYrehVT63j6N+RZvPFfJUM=; b=Q1+rHzV+FQnOieztvw/1eK1WB0MOWeIldz+1EX5dMV9Diz7P+bcu+0GFP7KhbszYkTrdp5S7ZLFmmpopY4dMr0BrzWA+10fP6tLGKCbpdXz7g63gCjs/VJtKgmirwyNZ7bJmWo33cpHmvSNYbkN4EGJWAnp+465mPCCCY27Q0Lk= 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 1780855266502600.4907922131107; Sun, 7 Jun 2026 11:01:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWHmg-0000VH-UX; Sun, 07 Jun 2026 13:59:42 -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 1wWHmd-0000Re-Al; Sun, 07 Jun 2026 13:59: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 ) id 1wWHmb-0004O9-MO; Sun, 07 Jun 2026 13:59: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=Aa5phmjF26iLIol4VbMlxdYrehVT63j6N+RZvPFfJUM=; b=vACs1 XZxYcjomsYDeAoa26ZRyRJgVWmOTUGnFoc+nnqWXIu3NdUA5UZGD5p2DjUhRmpVEdQMMqDbr6M41C /RdmE3FHtDvffxbAa3BG7a+KGfYXQyaI34V8B7NAtfyMo1zTNA4G0oM6uSkepAGnnioNA57vSz/4/ lx/qJVuvg+0CpwBm3j8wmzHu19AB0XjYek+3h643QrUenaIHWd6AhMzCeRm6Lh06/Z8Jajl06kJKr VQKS4BWWZ33T+/0XibUPhaXXcu7fPcX8nE7WVP9x8EIYZ6O5Tc1C7WwpE2SHGC6mC/Er3zjdV/YgC WFE0zv4Fys8111qb71/hEUHUxQ8uJrGTOpkRBwoajQTBeVoDyAykoDiPifMTe8gPe8lfNoeBxrm2f LifwUyLDjs9EuXMYup3z0ojUynSgBShUlQFpxzhc908XXE/i927Bix7nBpggo7I/W7u8NOedh2hY5 7rRdJ7galSGSQrw5+MmoU09MVGRUvWXxJXs251kYNOmIWc5UcEBY29g8UC+MbObnvpyz7ZBk6Ymjl HX1ERq9R8qNlNt3UDiRztJouFtHNFKm+P76LrRAgGco2CsF2OmQYM1GNToyamlZUEK+fcE+VKJSRL wuHNbFM2hXwzwt8lsQbIwCX0PeYdx9UQTY9zk4vuUASVNtlrbAfhaNG6+nrnbw=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 07 Jun 2026 19:22:19 +0200 Subject: [PATCH 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=a884579a315b6e9c1bbbddf44ea200dded0af0ca@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: 1780855268155154100 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Previous patch introduced a limit of max. 1024 simultanious 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 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 d67c4687b3..e8a0728c78 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 10e2e53c01..46db172a0b 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -4464,8 +4464,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 Jun 7 22:17:48 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=1780855307; cv=none; d=zohomail.com; s=zohoarc; b=mkdNJW1gASaROfB9JJcTv3hPuas1lWDfzPSTbHKShiDSlUx0/oiTmX94x38Tkt0nQj3QIWxcwpf88On3HaAq7SI8XsH6/jqH2g22wx9e1fgr/6QpId2HTIxouFs6rDjrzB2s63fHCAacCku/guS03N/ZIxiikOKldrU77JGP/ws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780855307; 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=R6AULfhhw5rxqMUI9RRsQGWJDEv+yKByNHZ+XkDIDgU=; b=i22zUqJGofZdNqV+8S3w86l0bUJBbqOmHZFS0z5XRG5BsBAANq5RV3cqAQVFaTf1vlm5WYrmPSU7WE/jsFdNKIsY5hhYsc9J5KVxV+p6qXlSmNy7EiwbDRnAQsY/+2NnskD/GxmWtPSouwOCWblqe+qiYgYUOFn5WaaB0Gw5u78= 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 1780855307486600.2443071367998; Sun, 7 Jun 2026 11:01:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWHmi-0000WL-Js; Sun, 07 Jun 2026 13:59:44 -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 1wWHmh-0000VN-2a; Sun, 07 Jun 2026 13:59:43 -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 1wWHmf-0004PO-Ga; Sun, 07 Jun 2026 13:59: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=R6AULfhhw5rxqMUI9RRsQGWJDEv+yKByNHZ+XkDIDgU=; b=WU7Ha VUKem6LIbx+p6T5kCMsYbvHR+Q7TqsqJDo3wad922UU8BZLhECnt/TVanM5whj59Wfqg/vAiGfAHj cwwCMYLaFWasaeD7IvJqzAoTFpqA0ejuCs/Zy/dEqJWUe+Cb5IYv8OxX9mFcjGFMV4myYOjn3P/hg u5vJrKZFTZ/CVJq5ksDfAByQEQbGI3i8jKx2oBScMK3hAafTXB1pDdrCarUYEDJA3KCquCLaBy51t LPKvxezlNC2WYHGc0C0pr+j8PKiltrKA8Ms5IP8vNnm+gy/n5vo5V4X/1WXkMTLep2AePqcp0E+gT j7zC81PaZH3S4ZM/H6z9NRiCO31d9Y2omBOq8LP8G8jG08RLkWl1hcgNAKAhjrTRkRt4ka6W1H5lJ YQ5Fr20Kek/ys1zQfYzWcsRjXvUEGvNrVLbaOseYy7BTK3Nh+H7iUSjb+RF1fUClxVl6BulmrS/yi Y6Hh0ieRZxUYKuAguClYDbg8FJ0e7DXpHSu9eVn4NcWfB5qAgE43rtZRp1xDwypHhS36qb8u5u9f/ 55VLYw/ooRUMnYhotich90dLayuj3hW3g/xrJNj2iwIfNRDhILUGEt6qRWxZ3C+ONKB/ci5h2UoK4 EaH0RQEZy4WS8a5V84qru8FtT8FB/jyfFSF9tgOsRVHx6dG3Gayd35wIw0ChKk=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 07 Jun 2026 19:22:19 +0200 Subject: [PATCH 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=c237ae8650eba19720d3c2640b202d5d025e49da@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: 1780855309142158500 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..558d084742 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`` + Sets 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 current 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 @@ -2109,6 +2115,12 @@ SRST on host would otherwise cause a file ID collision and hence potential severe misbehaviours on guest. =20 + ``max_xattr`` : sets 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 current + xattr FIDs. + ``warn`` : virtfs 9p expects only one device to be shared with the same export. If however more than one device is shared and accessed via the same 9p export then only a warning message is --=20 2.47.3 From nobody Sun Jun 7 22:17:48 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=1780855194; cv=none; d=zohomail.com; s=zohoarc; b=bbrx6CijlcWc+YR7//wVFRbbNI+T9uxYzU9t67dUJqj0CTH0ki52QxDX9/wxhAQTp+r5oEGId8YLYj3zQv8uNrkD3iHqkZpWhUKQ5ZxjzBj+O1HX31G5XvfVuFZ+EljVsKjKkYu2cYi5Ov3nDopKoLpqT/qg46uY7aI2M1km57M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780855194; 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=Tk7lwF+Zic19KczAOvVu9F9JO3m7/QiToyhOWjCS/+1fR84rFI+RYpoR5muRginyEjP+c4gyfEXJWHw7fqnDF+sb5Rfo7JUWBt+LAxOlkxryXFyQLCG8ygSCiNUF0N6IUFxrytBI+T4UBPtQzUowqXpps22TTaBXfexhC6Ul+BQ= 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 1780855194746472.3880533318114; Sun, 7 Jun 2026 10:59:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWHmU-0000Ne-2q; Sun, 07 Jun 2026 13:59:30 -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 <20720aa8a3d90233314e26966c480fdcc17409ce@kylie.crudebyte.com>) id 1wWHmS-0000NK-8W; Sun, 07 Jun 2026 13:59:28 -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 <20720aa8a3d90233314e26966c480fdcc17409ce@kylie.crudebyte.com>) id 1wWHmQ-0004Mo-IQ; Sun, 07 Jun 2026 13:59:27 -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=mOGpV UGIOQV7y2elbfFMGLPgBi5zRzO9MVKVqoJGwyeEopFzOWICoq/dpy2pVi5RF4frIscRTi0MP+1wsY QlFe91q/0FmIMujIeiD6LvIaM9FYsp6o7d+4vsNS8GX3tYbFgSCZbuOG7YuIQ1F0tFa4wi4SSQ7Db JA69IUPzZGMpWt452yd3wwKbJqzbM4POr1YkHSOKXhcyKNjhCY+AzmZVovGVxIQiWY4r/m4MVFHZj pXJ9hm3/YVu6Eo/bQwUiGgrIYJaW8wlw74H2np5qLQNsfnPzR3DxM41jX+oATVYbzXLtPZcFqp0Gc ufkJYovKFOl7K8KcIlUIhe903lkarEUVYltypeqnYXde8iH4rmF7NXBIC33XGwAjFFL/x3xPNRT6b 1kcaIEmjfMpN/sVs5//32TZXtobcQ/E5CCAm8L5wzwQiUHFVdUXfl5JbTy1jDfAZdoMCaKsiYXi2m nJlk0YDfMyon07UeIaKR1oPReZ33GAmP6jYjs0IyYCNd2ZT6cDUd4ugFZ8R3jjZIvN7f7lMEh4QO1 afs7FILZA9nbVDVeyJ2/ypMAaEbO8/MTB6C5/soOAad7GjGEP3lQEgZeYq40bfhLoAHuZP9nShrrT 8gwJ+3QproqwlLlgDtRhjWtCJQLB6YfKeheemOGfl+LxJhauvFMcAQFBNo4oMI=; Message-ID: <20720aa8a3d90233314e26966c480fdcc17409ce.1780851947.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 07 Jun 2026 19:22:19 +0200 Subject: [PATCH 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=20720aa8a3d90233314e26966c480fdcc17409ce@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: 1780855197568154100 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 Jun 7 22:17:48 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=1780855250; cv=none; d=zohomail.com; s=zohoarc; b=NuEgmt4YmXGQD4UuJePSB0toibal4cHOb+KCVjmW0b2qJ7s1/925ZQ3rxvDAEXAPBCdLqLpBz21b55yN+JHI2ZgDgPFPnv2yY+a4vNo3xTOmG24MG4dR4qYPdOJrHEuK1v2WmMtc1XtaSHTFEW1loUD65z5H6g8EFleTquTIPPE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780855250; 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=RGBEk3feZ/Z3Rt8UI/7NaHVfN+2SayEJWInxdGIhBhTQcvpNyh6+c+o+ILGzC8fDtpcQm33/aGpWgIEe3jlS+fN+7RIn1fdfI7OEU/i63cG0Utg5/4uyylkR/tJIc06aurnj4BDkxXbK9ys89ujsn358dgbA2gK9iyIwBzfzk1w= 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 1780855250073897.2687797752307; Sun, 7 Jun 2026 11:00:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWHm9-0000HL-Q1; Sun, 07 Jun 2026 13:59:09 -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 <8977b3ef87a2c56c1d978cee4e630a0a1b873311@kylie.crudebyte.com>) id 1wWHm8-0000H2-3k; Sun, 07 Jun 2026 13:59:08 -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 <8977b3ef87a2c56c1d978cee4e630a0a1b873311@kylie.crudebyte.com>) id 1wWHm6-0004JG-Ho; Sun, 07 Jun 2026 13:59:07 -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=HNj3Z ptHgNsw9cduMe/DQSMvksFfcNoNBIhsf23nqBDdqb9fISp9oteF++68kQm9sesxG9dNAuJVavf470 N1JYIOO023gDoL8H5nfrV7YO1RfdSAoeiQzWoIbpktst8H0aSbnbhLcHXFSm8G2txp+TsWGLHt0lS q8StdbehDI48LweTsxXm5ruCenbIVW+U8NMqRlJSZgp1fFownoSkHFrJgqHP5mmu1xXM3/iyDAeFl INJEx1dpb3cNlLchnZJNw31/pNLb6c22dn9HZGJ64w3vQHmU6EhcAhd46aLL9tFUGdV0dOxv/AL7b Xnjse5InpmqGsBo4W+rdNdY1qgj2C7Tww+Gj+22Ixb17AEzg2VWKBNRhJVRUr3Y88Nej0rnrzpFss 8i81NjscklwWKsT3GNTOYNK6TfaCZ2d6EiW1qBefzrT5n2G4mAc4SAgRnMLumpbruYwvdoPZKROOO RgBc9cr7A3hbTg3UhrgYfUw30NzbDP9pHaHIpXsJVKW2E0YZO6rUjVvp94k+RgHNc+/Vl2xbXrJcj LYuC4+lTn90piWux4PUr3UeMymqroyIY6OUCsa8d2OEUYWsp+BPUP9yMxt1nlFfAVU9/U1BeJEQZz bO/5iU8uh/oKlD+1RX971ovgRR7szFVubquQLgXU4Xh1kHkdUbvRq+Ceh4gefY=; Message-ID: <8977b3ef87a2c56c1d978cee4e630a0a1b873311.1780851947.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 07 Jun 2026 19:22:19 +0200 Subject: [PATCH 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=8977b3ef87a2c56c1d978cee4e630a0a1b873311@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: 1780855251874154100 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 Jun 7 22:17:48 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=1780855232; cv=none; d=zohomail.com; s=zohoarc; b=X0cAMs4TQjETwvf9wFhj06LubbnPpST2TQZobuLSIiF3qX0doVXYly7nBvUsjdl4VThHDB3X4AQg3Te232tu4xdLJ1Wixvcc9cSFQhJg5SEw33xdZVNt4SNKLfnWgK1IN0Dd1jw06+Nq1bB+1Ri2HE21db92gi3cEYmwWMvR+Jc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780855232; 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=SpanztBDkWCJKk8y8kjnh8T7lRyxD6cBtXUTN/k1b6erbY9R1wEJapzijRWPv/s+vwCpSRtbN+oWox4qdy/cXfBAicvV888cicqfuA1l6ZfPFFzM8cmnX/GRxFmRh8ilAVCoG2UtdDVc052/Vc9kpHn794x5EGd2Jr9KInJofwE= 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 1780855232787911.4663898872011; Sun, 7 Jun 2026 11:00:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWHmQ-0000Mu-2g; Sun, 07 Jun 2026 13:59:26 -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 1wWHmO-0000MU-Ud; Sun, 07 Jun 2026 13:59:24 -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 1wWHmN-0004MT-A4; Sun, 07 Jun 2026 13:59:24 -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=G5z2G uXd39ohCPe4GeM18uAF43d7pWbpSWlll5gKYepMKuYCEd8pPq7hZSSLm11KX0hCrIzg7wU7XQd0EP ROGuIkm+L87rusKqft6OsnceuFL3CtyZSl9C9oqxxSXw9j8dYboetghZcM5N704FDS2Bs9k2Qg+Gp ejjVa81947ABtW93obtLSAGsseQlABDHqUidK7KJMd3xTd+r/jblt3HLki9NS2K6zSxpw79XpW8QQ OCEuK67jTDU4MnRPvTM1lr0bYWNlwAjprMmM9FwiPPGhj9ztSYGLvLUhIVcs1tw0vdbg+mYAIsXur HwgGojnBD7FvXFeY3M+CfXDOFvt7ns+T/BxoJam9awr2iybElOoMwU0Jfc2ExvJC7aeOgBN8u04Wk PwXRdZMxg3iGza1xQx5qraWk/HL7a68mluoMnbSB5YTgKx5VQYyZ6bGOT1f6gSg5SexeppaNrNJ1t a42ULY/P7hu5UWfCA85+TkqsgeQLJ6m/sFChOpSnwM16tf2iR4ovE8yXe1BCFyJADNRF/hT0aokxi EDB9g3Y1mIrippGY947pbUsCv7t/z7kkE/pdOmg4DbDJ2LyQQJ4b6smRyvDNAkusWHCueMlaClXLI BYgviF0tBo4tuO77Npj8JLoCEzBPbpM0Fu83qGK0ZqDCb6q8N0IUeaZlL7Mzqs=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 07 Jun 2026 19:22:19 +0200 Subject: [PATCH 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=a7139564d7fb7fdeb9f391a9a40155d09a3f16cc@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: 1780855234722158500 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 Jun 7 22:17:48 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=1780855288; cv=none; d=zohomail.com; s=zohoarc; b=KHmlamuM1K3B4eB3/Fd5FjIS3OuFho6lKEAxxU3mf6QQjt6IxbAfbXkZB/wT/QjhR02cekC2PDpIYoWjUDpD372P+TR8H/GTYqiOSwYa5Xy/gsj0/pVuBhYPtAgwoscc7Fv9i2wDokWRdqU+wXuqLESAuhKwnBouqtudwDpGiJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780855288; 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=j2BkOVu3gpWx3xdabiOkn9UoGAZW4h9mYFhhrkRn0RwWwrbvN/vqHsjj7uHKJPmZpH7p2KdW41khz/s7BBeHFVyZWYjnbMgS30kHAB4MCTv4ieq/ZCc2r+etuskk4RLKR0Euh6Cefiv32whUoQQxjMztUObDh7v/WkKYoLaf6jk= 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 1780855288090162.5412996818635; Sun, 7 Jun 2026 11:01:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWHm7-0000GQ-4M; Sun, 07 Jun 2026 13:59:07 -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 1wWHm5-0000FZ-1J; Sun, 07 Jun 2026 13:59:05 -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 1wWHm3-0004Ix-NO; Sun, 07 Jun 2026 13:59:04 -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=muydM NCbVMLTz1yEMv9Rjx7Yc4jxK/vtoeaa6DNBpSu/WRxeQTEas1R1DQokxoE5wXOM0OsnBFYQp0ZTJh WvS9xiGhoMvfMx+2X7vemgQuQ5WO7R1ZnS52ck8sCL/vEUjkF9tY8Wmuy7mXHVSHr7DHIgdM9oJ1d FkpwMoVSexbwpUI3J8BftlaqLa5lofisg1bqcuUTOzx+rLAY6RxsdefNXNeMohK/EVYwnPAc6F8js 77xUiT/SqQeUHMU7uDwjXCaGniQXvEzMmJBlpXxUjR6qVR+tJetQsX20gEbeC4dVBmEXTA60864Fp Wsht5UaggSKH1P0VnkYfjfGN9rT6yM+LnNj90BMrlsunyuh/M4AQKnRxALmd+vHmAjcvsRa0YHD+c u9iWnZnL4H1Z0KHI6v4wXn1Bi3sAgXS6TDGTH4NSrz2XFCOYpotIbs6T0wkUjAnLq9lE/4+RRblZY 8oqc8s135SVhwXiL4P+0tilPjqW7YstAKqtpdzvQlGdVhXsIMEJI2ob32xq/d8zTzqOwhSG0nhxzo WQR0xwN27wKN0hFL38FehP7f9aH7Fpp/8HDLHGm0apVdFZQ2Tent9AmWcrie6drMIPCnjeoCnrUvc Bjc8vsypnpv0ei6qpCITbBbRAF/tnOQxonBN+9UE+iBo57XbXyrtvLEBnOfalo=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 07 Jun 2026 19:22:19 +0200 Subject: [PATCH 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=f3e89e13712ecc50b1f68e5fb10b66f48a8a1cee@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: 1780855290931158500 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 Jun 7 22:17:48 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=1780855200; cv=none; d=zohomail.com; s=zohoarc; b=Skd+jXL0hnHbkHLSztgYLuAuaGWPXWCYd8ThefoZTDC3CBTWeTFMpeXyRBLwAOdNQf2rjtH+Iyyuf2Lg6eB1OTQVQyhAns3a6po/+ShbKvuy9kb2Y2TOnWMhj2p2ERzAcjt5wUYZ7/xxgIgev3sU+oGu867aFls3QfwEvypv4o0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780855200; 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=xW/DPGJd1kcaXKX7UWvwp4TuiSMmM2UJikdF3Y9+z5U=; b=nazTQlJCoHK43thjgxt8eiT0rl4wBwJn/MVCh4lcPDsBULgz1BgmlxaUQodDSHETpJMGhushtFD4PdlXWGHqhTrnwVS2ljjtqX+z/7aKX3w2O+L2yPswrQuZuAfmPJV7C09bk6hazVnua7xcRciN3saSuIcxnZo7BwQMn26oejI= 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 1780855200310366.570910945558; Sun, 7 Jun 2026 11:00:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWHmk-0000XF-Od; Sun, 07 Jun 2026 13:59:46 -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 <88245fc6852d430ae4b76157ab9d3b92a4767bdf@kylie.crudebyte.com>) id 1wWHmk-0000Wj-0b; Sun, 07 Jun 2026 13:59: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 <88245fc6852d430ae4b76157ab9d3b92a4767bdf@kylie.crudebyte.com>) id 1wWHmi-0004Pp-IV; Sun, 07 Jun 2026 13:59: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=xW/DPGJd1kcaXKX7UWvwp4TuiSMmM2UJikdF3Y9+z5U=; b=E/E3p J2Ns3jB3Ds3vsUk+q3rF2AlOC19q2QBn7ZH4AILtNvoeu8VAfI9DD+EOBDfXEm1pQPy9/T5wCm0RJ cHSgsNcGXs4U9880mD4MSVEbh8bAICJqtAusKQgnX4/rnu9HoqBPpQnBoJtzYViNglo0WZVMUTLpS sgmJRyexw5yg6MGXWMd7lmOzGDm6QT1ZVu/9eG8N/nv47tFZJHmzY8tU0VBpixotp1VPBel43He1Y K0IZu5Hd2pAUv14BMZoxCiJ3U4J6d0LDQ4hWxHs3xXnxjmUSODfMowRNJF1hpotaYbfVfXk4t0l0b InTmKkQLoC6xWd6MmQNmGle+jUJePpDzsaPBp5ZTNbR/Z0r+p6T4WMloyNJ5QVIttULvPr6YoZojd SLvVjWbqVCZURt84GWx/n5ON10XAdAxupc/073K90/rPx3M42uN1iHbu2KHG0JDAL0I0ooHzn6vtN fl7W7YL+bodxvSdDie4ZtUi5GXhOuFh2Pu/TMTeIA1SkNnqMV++a7VjRdUC0XGDgo7sbGxt0cUnrc 65GnCTs42OO7HhcccOCGsigxTbjyi3Uc0T1L0Ep7oUNA3yTZjlZY5J/imfv/nR5VRZEIkJ++Be9sR og777Qbi+sMFPx/ezZgT03VtRXfdkp2fpLt1/n/B8Ejws9zBDAgUJYXYlkehmw=; Message-ID: <88245fc6852d430ae4b76157ab9d3b92a4767bdf.1780851947.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 07 Jun 2026 19:22:19 +0200 Subject: [PATCH 08/12] hw/9pfs: add xattr count query interface fo 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=88245fc6852d430ae4b76157ab9d3b92a4767bdf@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: 1780855202936154100 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 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 Jun 7 22:17:48 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=1780855191; cv=none; d=zohomail.com; s=zohoarc; b=P7dEBV/4EhFHcgo4CRljCGkjtw5mxw8vCZbAGhpjUZHhoSqR8HuQC+1YCNfGvay2p8RfVDo9I4IdiYsrZDBSTlomjTBl8wmsnQs2sjSfRrScB6BEwCP3tcTOhPRvT90QpcQiCSeZGECWm1rLAgRg9KACTshx0i5WFlpgYFpmBis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780855191; 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=Nvijw5zxNpcwR19Sl1opG3FKxsazjdsC775GYkiqEho=; b=eOIThjhLbRWtArRR3SNoCAbwZQLQ0+dvd+lQZdPHnhw8w7mqvonH7zihVkLcft6GXh6Ie1n9pmVv8vKEjaIrEbSDRPJhL+PWgFJbJbq/hdG2PpQ3yjoplpiu24MORgawU4Stvp8USD/RQdiagBmkc/+YrYDp+PgD9na4xhvIEiw= 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 178085519099656.23977141433329; Sun, 7 Jun 2026 10:59:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWHmB-0000JN-TR; Sun, 07 Jun 2026 13:59:11 -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 1wWHmA-0000IK-Vh; Sun, 07 Jun 2026 13:59:10 -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 1wWHm9-0004Jm-J7; Sun, 07 Jun 2026 13:59:10 -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=Nvijw5zxNpcwR19Sl1opG3FKxsazjdsC775GYkiqEho=; b=JcaXY FVuaGREgC2mgI+cIxiZTua8/3GtwwQkzBLWbCmifsJMbShi3kioiv56hk/pYCXGJemD1s7egn9Jx3 pHbf3ce0ReGvW8roqXloOEJoypFveCfXbGk2ANJgecFDdyLNLn91RPE4ZWBQ9edqbfvIiatDC79/v OclSj80f9Tshb6e4lcPVcH4g+l7eySl+WRk5Q4/HHx8BuhqR0eEZ4g/WhO4YXVcbfRamc/ZAUYDQH UIC4JAnRNAnXnernRU4+Flx5AVXd+mSvbAZXAPlytDv61UaAS/yDPgBxgzC8V8NLC92GOsuFsDJ8M hac7SV96IXDcjgScXrOwmZiohenZCGOkKAfVgSVZYLwQEj7umND50umNUYPvXU8LUTlEPgAeqQNJ6 b4mIhZz3YoNVS/0POxrWHCAfHRu3ZdWzbARsUwP+1wSZVpMBc+PKLq51l7pGHZArpEfJFo4smfoac xLUg3jhPHtlvHXMcU6nGexzkq8CPaallE0vF7GfOI84yrJQahmc6cPtHQxAZvXzRbQE64u2GvZzX1 jDdJIDjoJO+C6l4+gKrwSpzWnEa1S/C8toBXDvHpy2o8Ec3tqevcddYPzfExnbR9N2Z+2Qpr03x4H f6bMcWvBtXlSbJQSKfaG1tiGGnWnWnzPRJz8d9vcwycwkfIlFoa2CNZqta1AWU=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 07 Jun 2026 19:22:19 +0200 Subject: [PATCH 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=eb2d66400d7763e0f4c92e03c527009d5093f5ac@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: 1780855193070158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Increase the maximum 9P message size 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 Jun 7 22:17:48 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=1780855303; cv=none; d=zohomail.com; s=zohoarc; b=D2AFaaplBolpt55okSDzIHawK9rO0s2mzyBDQE0jbZC28WZVs3lyRQYk6iVitD6DoPYW0kPCkmDlOSdtAuWu20A4LNaDHwH/iODP2IsRgwIQOP0N3MWXVUMIqJPArfddjYGssF2m9NSkAaplhDDv0wvY7uAYzmle0C1Rg4hIoNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780855303; 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=kIgp2NOQEt3cUrV9ARgr1LYMHuCWiWvveE8Uv0MfSJZtxSnkCR/Eqc6nA4sgGweGA6cg23S33Jouywh1q1KsI8l0XJaDgCaeeb5R8iPIaBDrfjXvnU6d4caVctUQS2hP7KU8a+BOfHEtvQXCldHt6xsN6ZYXriMGniyUyiHjCFc= 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 1780855303457764.4482257123587; Sun, 7 Jun 2026 11:01:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWHmi-0000Vr-1l; Sun, 07 Jun 2026 13:59:44 -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 <1a5a9695101ddeb4a8091bf1894b5b134a077e9e@kylie.crudebyte.com>) id 1wWHmZ-0000OL-98; Sun, 07 Jun 2026 13:59:35 -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 <1a5a9695101ddeb4a8091bf1894b5b134a077e9e@kylie.crudebyte.com>) id 1wWHmX-0004Nm-Ql; Sun, 07 Jun 2026 13:59:34 -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=CH2UU lTPy9vg/ahu3Nl6A0P1cJtwfxEYSMSO61gGu3acgcQrZBThFBNOEtpMaJ8jYtjR3cL3dE0GN1nZNa dDuX65/WQQ2YeSmMhduSc3mIZHHPFISq53TjtEwD+EtaEfJuOEzrRE/V91F+Tawd6knpbv+zMzE4/ gUxgUc/ShbBKRNhrCWI2Ss5COii73TN5CoDu1X9ZpymwsZHbdbzs40G5kRWHYteDDlwVfsR4RaGu9 vCmaPNuhDG6ch40hNZ14/ocLuk6VsGoIiIZvgyD/c+ZFTpxVzIY3jzj6344G61dUCEdApJB8+HEE+ 7KXW7JEOQbNigDoboLaQ2x2O9cmhYG/jBKXWjIELROJAwQj5ks/KXihPrHENpopQgoU4ybLWCVhtz JHGjfo9JLQ8DUsDUCAyACWLPD15Vqs3po/GXCnY+vl1DFWZ6jLDM+Qj83NNkzLjhwrqABMn/lpq30 N/HR0zEGaPhjjvwUZAhHeinUAfQqcToBdnrqASCzsN/AxATEWf682+Efro9u0l4OG1lXHJ7VzAdj0 +kvKw8HEWYdIG3b74wpWwsICfUs+Z83N7krvWo5/EuxXA7Ya8ZErA4Q0wqUnqT0y+RMoHC5phQLKT 3bdgtLI/7QQzZgNR3xJZ7b9cztXzOb4GQhc2GD35ViKaEGKq+1xGubZ6oRMkUk=; Message-ID: <1a5a9695101ddeb4a8091bf1894b5b134a077e9e.1780851947.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 07 Jun 2026 19:22:19 +0200 Subject: [PATCH 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=1a5a9695101ddeb4a8091bf1894b5b134a077e9e@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: 1780855304495154100 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 Jun 7 22:17:48 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=1780855266; cv=none; d=zohomail.com; s=zohoarc; b=Sn/c5RQNLj7f5Y2GQtXFuwCCy4RwFNNrTjznY3fJe4rZRK8t4gjiN9Y9fCiU18f9frF1Shl4NK0W9v09+c4LIZEttylfiDaN+GOxnW7pz2evczgdCdbU5LI8iqByNdz9iFyCRdZzSEsuKuJmUZSNqkWPNptvH+gAetqcrtcFg04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780855266; 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=3RDkS9FqMQ4WNcgV486Q4foDMpqFcAB7lrLv51/S8jc=; b=mFYSGPa5PDbW2ahl5puFd4+GorI6sd7CvYwnTUD2OWG5tlikOc661o5P8dXp7Dxr9g8pBhjXscaGs5P+41xfxq9Xj3Fd8rKYKBF/PiML5+7E0CxfCOLgjRYCPkNLthvvLWaBrSJTJjhXHMezpn+flUl+6XDxpF/4shtR4TDoh2M= 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 1780855266959241.51802305980766; Sun, 7 Jun 2026 11:01:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWHmM-0000Ld-F9; Sun, 07 Jun 2026 13:59:22 -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 1wWHmL-0000LO-R8; Sun, 07 Jun 2026 13:59:21 -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 1wWHmJ-0004M0-LE; Sun, 07 Jun 2026 13:59:21 -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=3RDkS9FqMQ4WNcgV486Q4foDMpqFcAB7lrLv51/S8jc=; b=CVR3J i7S79s8uyuYcR6EvLzPoz0VqfBlCOu/6CK1XJbcb+t2o/3/n+2ymr3jQJcozTdsWjmxK3v6F4uJtu n5X83CS030wPhKvPA21SdFEYgO2YoZgtYJ7g3A/ToazOxUp5s10JuENFmznh6ZdH7bBOutb4QG9Qw 9YMxf3/m1zZV4xMFhPCIzQ9TcNiydhKCuPDV5duqdy/Ys5OVXnrNjSOnMpIgFt+2gOYh7AmWabdGD yiojlnx/NgrxVci6PllF/Rkdy7H5ydqKpIvQRUUESaUQJQ/MdqJ7dYFajux3io8yOZee18Mw3u8KU CV9vY6Db63aWexAvdx3QOJA+3BR5C0XkFAoLJ6xOuFS1H1SfLELIAC25zCoPWpKj4gOf+hZiHlGkf SyAnI4CDGfBG13Rj/oqnrHp2C/81BPMgvEg+oafEJCJYlad9oz/sm9REeeJkk/GbMSWG/KgGXbvbO vTYy+IN7Zb83ysl7e280UWmY8riiWd4S2XntKQd9hxTZKA/2jzK0DZ3PmmW5MZ564TzwHcx3var2i nVINXUvYdO020ENLLSER+FOD0y9w6zi0s66z6r07VelTjfcUfBDYhOnPtZEesNsQMHfV3EY2/9ZJP 00GbHhjDzP6DxbPm9CzyLtaIIpG8nRF58Go0wRB2WLA5PIFvVv3nqBXw9tBpF4=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 07 Jun 2026 19:22:19 +0200 Subject: [PATCH 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=ea697681cc57f3eae898d55242c2535a1d844eb4@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: 1780855268936158500 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 also validate the current 9p server internal xattr FID counter at any moment. These are "slow" tests, i.e. they are not running by default. Use -m slow for running theses tests. 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 Jun 7 22:17:48 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=1780855191; cv=none; d=zohomail.com; s=zohoarc; b=GcrvsM1BHvtlUtAzSA7kN2KjypecFEYJDTZq5t8rGRkTSR8Ugb/MT6fELiMJOxd3RIYKF7hk3UZoJvPddxoqYEplglCYHRGDKbTqahQ++5nzc+1Rig0I2RamHIE4b/mAuuJdYUwAXxUPhX4K7uhu/sYJxZeTR562GfR5WshEPNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780855191; 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=j+IJKoaTTT2cxXkfp0g/5zvDk/18rKDB/i3pyHZ0ieY=; b=CGteLZ407RVVBjEy2Jul7TEoL7IsUf6U+o/gcse4QPteqibalYUHS/N7oadK/xTiZ3B4f01Jva3j9iQcSgVBioK7ZuUd9Uhmqq5U7qw6bupq7faVS/dcaBbg+Hu76Vin2sJbR7mkvFotCMjTGeqt4tmAIICx900/MsXQAqCYYHA= 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 178085519107687.62889752348406; Sun, 7 Jun 2026 10:59:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWHmF-0000Ko-Pk; Sun, 07 Jun 2026 13:59:15 -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 <7840fbdba06d0f4c45cac96a0a9aa35681ef177f@kylie.crudebyte.com>) id 1wWHmE-0000Ju-27; Sun, 07 Jun 2026 13:59:14 -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 <7840fbdba06d0f4c45cac96a0a9aa35681ef177f@kylie.crudebyte.com>) id 1wWHmC-0004KR-Fm; Sun, 07 Jun 2026 13:59:13 -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=j+IJKoaTTT2cxXkfp0g/5zvDk/18rKDB/i3pyHZ0ieY=; b=ck0v4 Ag917os6/3AG8KJIwcWoVk9MDsUm0Gz+/IBPB6a0OEFH9G+eF27hb1OMPb9CbwOrivu/jB1jvychT qgOi14PaxumE2gX+tG3d/vopr6wb0UXP7ZJN6sMBvza2bUtmfguLAwWMWVCu4qnkt9nVCxefuW5NJ 1hTE1Q20LUX5x8ieA9CEFxiSzecpGcc4ydXLBxVCSUy+DM6UZdxdlI/KOC9mAfiDLczPH/ZC3bGD0 Bp11DelvOe5G6KRu3W/e+EraU3ZzBglGpRodAb6K9PHLPbCvAyKQ6q2kT9wFk+4x0PAPdMmdV6vWy EhRBL1cgNigWXC70PMGlEQbds0tcQn5gYBKkMeTAbSFh4osPm1Y5cero/08SzFKmliknQi6trXaZH pBbgMPIk/BXwuY2OJN70glVK+vMRtl2+CCEV8q3hxNVcpYcngYfACZm1ce5siWfRqBoWA6a81a974 Q5VAeBdYm7S4cWfEIjRbMj9pxjHNuvfXL4qs7DHx75HVcSEo0EKinx5aNA0xz6f+eeX0F3wCm3dAS Mrerm0ODuwnhT05IAvasquTkAPKlZjCxr7E6tdVbicB7hpTSIcF1NytzAOdURgcdrHCgYaM41FmzN HiIYRqI7UldwQ7oB5a7j9hnFN2bIAXMu26Il8REEShSCI++pwvAYdaRSu+ZMJQ=; Message-ID: <7840fbdba06d0f4c45cac96a0a9aa35681ef177f.1780851947.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 07 Jun 2026 19:22:19 +0200 Subject: [PATCH 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=7840fbdba06d0f4c45cac96a0a9aa35681ef177f@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: 1780855193113158500 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. These are "slow" tests, i.e. they are not running by default. Use -m slow for running theses tests. Signed-off-by: Christian Schoenebeck --- tests/qtest/virtio-9p-test.c | 69 ++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 2e88429dfa..d559f0f8a0 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,41 @@ 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 g_strdup("security_model=3Dmapped-xattr"); + if (extra_opts) { + opts =3D g_strdup_printf("%s,%s", opts, extra_opts); + } + 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 +1133,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