From nobody Tue Jun 9 23:07:36 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=1781015187; cv=none; d=zohomail.com; s=zohoarc; b=jXGKnTl3ppYouEPyKYzwR8ZLKD0mS5facush97W6sqDkr/JuRp27NjSAdEm5IcIvSlmWAer0rATkhga+gksa55F1753WZ6R9XfXRlQVD05xDimVn2YNoL3P4os470+Ced7ZX2n85K+62ROVueiiUTBWV3KTZfMBP/E4f+mDBFdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781015187; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MfenymRhk48IxUTxbFS7vY9DrB63qmTI315WRZ5gsUk=; b=JOmvaVnSnou3XV75MqmQBFlcLSFFegTPmC0BkMNn40yucDC2kOQM9E5vPNK0eWmALAwE7m8KfOUH+IuIVmoFhR50MTJcWY1BCsXBO0/+aZVVPUJ6MTkQcgxP6aYaJ4PPMDTG0jHonmzWu23E2FQ4hGnDb8zdX1fm+oKjB91NmzE= 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 1781015187580986.4442403519541; Tue, 9 Jun 2026 07:26:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWxOq-0002Wg-FB; Tue, 09 Jun 2026 10:25:52 -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 1wWxOo-0002VK-DN; Tue, 09 Jun 2026 10:25:50 -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 1wWxOk-0001BB-Qz; Tue, 09 Jun 2026 10:25:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=MfenymRhk48IxUTxbFS7vY9DrB63qmTI315WRZ5gsUk=; b=wNblw 1oc4YOrahxXvsQmoBh20QpV+sGP3lqhqshedyD6lYh2DwTC5jFIflb8KeOFbfF9RNGRePvobcofk+ kB1j3HobsSij0vCXxiawDXwsrh0c2lNooRz87VYKh+qyy0CLOJw7YhK9+NOCdiTYxG1P2B1LX/l9S 5tB6uRat5BWOTpzWVgmQhpeyo7H7NVf4YQuzxYgSmqrKhtaYIBPA+uxIVl2jrkQGzPARq5+TGdQnJ 359x+0opr7bUjeYv80H1y5KuG6nZMivCCW/tmeqh6Qwvmv7zckYsqVKZkP3PjF9nW72RbD4kUbsf2 pXiWe/cvCpfh6w6mxIPbHKZDSXpFNEcrgvmFHmN0/amBZ5lJ6TlJDPmSm0RSiHMV/tjJ2vsqQYbDI 6UnZQ5p0jfytykfDV54fMNzBXU6HWYwwS2gXN1h1xlfo3gwt71lYQncRACkagN8gKA6ppLwZjvza0 xaHRupwM+R44/GlOp2muvk3bmMKUwFaz/qAQr1nqBbddhUhPUuJ3Yl8QCGOEnHQvlW1khBWaLMGyi JtUZA3ZLErXEMB+SitYhuCdBmmmnliXWplkkfwZYkMTDJJjZdkYrUks1GWX48i2uVo49YR7y6uLfU LXrO9mMd4sKVh4loCurnQvW4nlVScfbvnJ7RfxVT+qelMsdrARx4bssoFmbjZs=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 09 Jun 2026 15:47:06 +0200 Subject: [PATCH v2 01/12] hw/9pfs: add xattr FID limit to prevent memory exhaustion To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Greg Kurz , Feifan Qian Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.189.157.229; envelope-from=eb3787869745d47234fb662600187bf773e1ef8a@kylie.crudebyte.com; helo=kylie.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1781015190975154100 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a limit on the number of simultaneously open xattr FIDs to prevent host memory exhaustion attacks. Each xattr FID contains a buffer for the xattr value, and without a limit, a malicious priviliged guest with direct communication access to 9p server could create a huge number of xattr FIDs until host memory is eventually exhausted. Fix this by: - add xattr_fid_limit to struct FsContext for the max. amount - add xattr_fid_count to struct FsContext for the current amount - init xattr_fid_limit with 1024 - init xattr_fid_count with 0 - add function xattr_fid_count_inc() to increment the count - add function xattr_fid_count_decr() to decrement the count - call xattr_fid_count_inc() in Txattrcreate handler - call xattr_fid_count_inc() in Txattrwalk handler - call xattr_fid_count_decr() when a xattr FID is freed Additionally: - reset the xattr FID counter in virtfs_reset() When the limit is reached then xattr_fid_count_inc() returns -ENOSPC and the request handler is aborted on its error path without turning the FID into an xattr type and without allocating memory for the xattr. The default value of 1024 was chosen, as (sane usage of) xattr requests in the 9p protocol are usually very short-lived, and even machines with 128 cores with very high xattr activity should have plenty of head room without ever hitting this limit. Fixes: 10b468bdc5 ("virtio-9p: Implement TXATTRCREATE") Fixes: CVE-2026-8348 Reported-by: Feifan Qian Signed-off-by: Christian Schoenebeck --- fsdev/file-op-9p.h | 9 +++++++ hw/9pfs/9p.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h index e8d0661c4b..454761d81d 100644 --- a/fsdev/file-op-9p.h +++ b/fsdev/file-op-9p.h @@ -81,6 +81,11 @@ typedef struct ExtendedOps { =20 #define V9FS_SEC_MASK 0x0000003C =20 +/* + * Limits the maximum amount of simultaneously open xattr FIDs to prevent + * host memory exhaustion (as each xattr FID contains a xattr value buffer= ). + */ +#define V9FS_MAX_XATTR_DEFAULT 1024 =20 typedef struct FileOperations FileOperations; typedef struct XattrOperations XattrOperations; @@ -109,6 +114,10 @@ struct FsContext { void *private; mode_t fmode; mode_t dmode; + /* max. amount of simultaneously open xattr FIDs */ + uint32_t xattr_fid_limit; + /* current amount of open xattr FIDs */ + uint32_t xattr_fid_count; }; =20 struct V9fsPath { diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index b4314d2549..053f0cc64b 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -265,6 +265,31 @@ static size_t v9fs_string_size(V9fsString *str) return str->size; } =20 +static int xattr_fid_count_inc(V9fsPDU *pdu) +{ + V9fsState *s =3D pdu->s; + + if (s->ctx.xattr_fid_limit > 0 && + s->ctx.xattr_fid_count >=3D s->ctx.xattr_fid_limit) { + error_report_once("9pfs: xattr_fid_count limit exceeded " + "(configurable by option 'max_xattr')."); + return -ENOSPC; + } + s->ctx.xattr_fid_count++; + return 0; +} + +static void xattr_fid_count_decr(V9fsPDU *pdu) +{ + V9fsState *s =3D pdu->s; + + if (s->ctx.xattr_fid_count > 0) { + s->ctx.xattr_fid_count--; + } else { + error_report_once("9pfs: xattr_fid_count underflow detected"); + } +} + /* * returns 0 if fid got re-opened, 1 if not, < 0 on error */ @@ -397,6 +422,7 @@ static int coroutine_fn free_fid(V9fsPDU *pdu, V9fsFidS= tate *fidp) } } else if (fidp->fid_type =3D=3D P9_FID_XATTR) { retval =3D v9fs_xattr_fid_clunk(pdu, fidp); + xattr_fid_count_decr(pdu); } v9fs_path_free(&fidp->path); g_free(fidp); @@ -634,6 +660,14 @@ static void coroutine_fn virtfs_reset(V9fsPDU *pdu) fidp->clunked =3D true; put_fid(pdu, fidp); } + + /* + * Explicitly reset the xattr FID counter. + * + * free_fid() already decrements the counter for each P9_FID_XATTR, so= the + * counter should already be zero, hence this is just a defensive meas= ure. + */ + s->ctx.xattr_fid_count =3D 0; } =20 #define P9_QID_TYPE_DIR 0x80 @@ -4006,6 +4040,14 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque) clunk_fid(s, xattr_fidp->fid); goto out; } + + /* Check xattr FID limit */ + err =3D xattr_fid_count_inc(pdu); + if (err < 0) { + clunk_fid(s, xattr_fidp->fid); + goto out; + } + /* * Read the xattr value */ @@ -4013,6 +4055,7 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque) xattr_fidp->fid_type =3D P9_FID_XATTR; xattr_fidp->fs.xattr.xattrwalk_fid =3D true; xattr_fidp->fs.xattr.value =3D g_malloc0(size); + if (size) { err =3D v9fs_co_llistxattr(pdu, &xattr_fidp->path, xattr_fidp->fs.xattr.value, @@ -4039,6 +4082,14 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque) clunk_fid(s, xattr_fidp->fid); goto out; } + + /* Check xattr FID limit */ + err =3D xattr_fid_count_inc(pdu); + if (err < 0) { + clunk_fid(s, xattr_fidp->fid); + goto out; + } + /* * Read the xattr value */ @@ -4046,6 +4097,7 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque) xattr_fidp->fid_type =3D P9_FID_XATTR; xattr_fidp->fs.xattr.xattrwalk_fid =3D true; xattr_fidp->fs.xattr.value =3D g_malloc0(size); + if (size) { err =3D v9fs_co_lgetxattr(pdu, &xattr_fidp->path, &name, xattr_fidp->fs.xattr.value, @@ -4147,6 +4199,12 @@ static void coroutine_fn v9fs_xattrcreate(void *opaq= ue) goto out_put_fid; } =20 + /* Check xattr FID limit */ + err =3D xattr_fid_count_inc(pdu); + if (err < 0) { + goto out_put_fid; + } + /* Make the file fid point to xattr */ xattr_fidp =3D file_fidp; xattr_fidp->fid_type =3D P9_FID_XATTR; @@ -4408,6 +4466,10 @@ int v9fs_device_realize_common(V9fsState *s, const V= 9fsTransport *t, =20 s->reclaiming =3D false; =20 + /* init xattr FID limit */ + s->ctx.xattr_fid_limit =3D V9FS_MAX_XATTR_DEFAULT; + s->ctx.xattr_fid_count =3D 0; + rc =3D 0; out: if (rc) { --=20 2.47.3 From nobody Tue Jun 9 23:07:36 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=1781015215; cv=none; d=zohomail.com; s=zohoarc; b=C8WVPdUGziqU2WTaUdLQbVRW3rKnWFkeyW7OhiCGGWyZr/xnqSYM4zeHR1ItngxoArhFKtHcyECkEAoo/TrD7U8Rl+xvUyM1D8GTOI9zkb8xWVeJD3DKNZF3wt35cuPO45vg17pYymSF+rVYuR9XMI4curTdJFkWELdkKja2v4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781015215; 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=7eQ4MTenAAvlJ41OoBJnMEbWisXBZTvEROlMRcY7BmY=; b=LqJ9XMO9EeVyUrFvdP8V+qZ9XiAHouKog0rFVAnRjev962ITdoH28uzWU51Elu61dim+N1k5ymydDXC46EajGUR++rEhPYQ2drbYKyZBTweSrdjooNmkzHPLw51OLtw7ogNnsV9z6EDOsIWOUH0UwxN1mjGpR5EE1xeiFym8CvI= 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 1781015215430200.32317721094194; Tue, 9 Jun 2026 07:26:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWxPF-0002jD-EN; Tue, 09 Jun 2026 10:26:18 -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 1wWxPD-0002ip-JC; Tue, 09 Jun 2026 10:26:15 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wWxPA-0001Ov-SA; Tue, 09 Jun 2026 10:26:14 -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=7eQ4MTenAAvlJ41OoBJnMEbWisXBZTvEROlMRcY7BmY=; b=eAsnP VpoxLU4MypaFJ+SnJl/LVMnpyPHhi26NM7WlUEOu835eRkznpa5Sdz02SgurI9rV9HN6wwJRbl+wy +GRY1vyKo9ZWGKPck0BJs4VL+rf/ZWJyIdDEeMYAkYCwnuzJkoh9183jaYQJjjVOAOD5lHsYXDBVx /X9DjXSEGnqg/GGSbkdTcPmBs6CYBajZHEn6NhzTArMzFPPXjPhQZb9qqn6uhLd96xj/09rSWS2BP f9NmEGItCzqB9FOdr7wO6ZjPJoT3DlCjlg2OjEDIpT15MqFiSTsKTHfsa1mRd2+gzP1LP9c8Q1v8u HJ9yOdA4L4LS/DsYnK5jjs4g2MIG5GmqB76a+nFdZzrSxyif284hDLegX4jpyTAkEb6VXOJHnHYGq UfX7gmdS54a6gmvzq9ocYdV6RLw7LKg9z+jujVyLzRG7GAkruyqDpRtG7oA9j/anqBCyiVfNGlx87 dX0OGa1A7trqVWRRpIZrPhld8t4A7kosAJFI5dUlK3F8002uH4LLjZFB0NvRV6ZHi6ehL/SAFL5Yy AVZrojydXeInl6eAImTp/T+wfroNn+DcKvXuxH8ZgOVt6KYYO5552EXillI5l16uuWyxVsCIE8AEZ I9lOoTfIlFPCl6CT9jASk6ARbeMjYIDeXAxzGr/A/EBBdouQtoNLq7ecTMhYS0=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 09 Jun 2026 15:47:06 +0200 Subject: [PATCH v2 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=af41353ef073e7919390ce3115b2642502358041@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: 1781015216832154100 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 454761d81d..1d931144f4 100644 --- a/fsdev/file-op-9p.h +++ b/fsdev/file-op-9p.h @@ -101,6 +101,8 @@ typedef struct FsDriverEntry { FsThrottle fst; mode_t fmode; mode_t dmode; + /* temporary storage for parse_opts only */ + uint32_t max_xattr; } FsDriverEntry; =20 struct FsContext { diff --git a/fsdev/qemu-fsdev-opts.c b/fsdev/qemu-fsdev-opts.c index 07a18c6e48..c2c1e83611 100644 --- a/fsdev/qemu-fsdev-opts.c +++ b/fsdev/qemu-fsdev-opts.c @@ -46,6 +46,9 @@ static QemuOptsList qemu_fsdev_opts =3D { }, { .name =3D "dmode", .type =3D QEMU_OPT_NUMBER, + }, { + .name =3D "max_xattr", + .type =3D QEMU_OPT_NUMBER, }, =20 THROTTLE_OPTS, @@ -92,6 +95,9 @@ static QemuOptsList qemu_virtfs_opts =3D { }, { .name =3D "dmode", .type =3D QEMU_OPT_NUMBER, + }, { + .name =3D "max_xattr", + .type =3D QEMU_OPT_NUMBER, }, =20 { /*End of list */ } diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index 57877dad0a..f97103cf44 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -45,7 +45,7 @@ typedef struct FsDriverListEntry { static QTAILQ_HEAD(, FsDriverListEntry) fsdriver_entries =3D QTAILQ_HEAD_INITIALIZER(fsdriver_entries); =20 -#define COMMON_FS_DRIVER_OPTIONS "id", "fsdriver", "readonly" +#define COMMON_FS_DRIVER_OPTIONS "id", "fsdriver", "readonly", "max_xattr" =20 static FsDriverTable FsDrivers[] =3D { { diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index aa48306b0e..4708e170a4 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1527,6 +1527,15 @@ static int local_parse_opts(QemuOpts *opts, FsDriver= Entry *fse, Error **errp) const char *path =3D qemu_opt_get(opts, "path"); const char *multidevs =3D qemu_opt_get(opts, "multidevs"); =20 + uint64_t val =3D qemu_opt_get_number(opts, "max_xattr", + V9FS_MAX_XATTR_DEFAULT); + if (val > UINT32_MAX) { + error_setg(errp, "max_xattr value '%s' too large", + qemu_opt_get(opts, "max_xattr")); + return -1; + } + fse->max_xattr =3D val; + if (!sec_model) { error_setg(errp, "security_model property not set"); error_append_security_model_hint(errp); diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index b3743f6169..322dc3bb69 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -25,6 +25,8 @@ #include "qemu/rcu_queue.h" #include "qemu/cutils.h" #include "system/qtest.h" +#include "qapi/error.h" +#include "qemu/option.h" =20 /* Root node for synth file system */ static V9fsSynthNode synth_root =3D { @@ -629,12 +631,27 @@ static int synth_init(FsContext *ctx, Error **errp) return 0; } =20 +static int synth_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **er= rp) +{ + uint64_t val =3D qemu_opt_get_number(opts, "max_xattr", + V9FS_MAX_XATTR_DEFAULT); + if (val > UINT32_MAX) { + error_setg(errp, "max_xattr value '%s' too large", + qemu_opt_get(opts, "max_xattr")); + return -1; + } + fse->max_xattr =3D val; + + return 0; +} + static bool synth_has_valid_file_handle(int fid_type, V9fsFidOpenState *fs) { return false; } =20 FileOperations synth_ops =3D { + .parse_opts =3D synth_parse_opts, .init =3D synth_init, .lstat =3D synth_lstat, .readlink =3D synth_readlink, diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 053f0cc64b..fb8c7439f7 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -4466,8 +4466,8 @@ int v9fs_device_realize_common(V9fsState *s, const V9= fsTransport *t, =20 s->reclaiming =3D false; =20 - /* init xattr FID limit */ - s->ctx.xattr_fid_limit =3D V9FS_MAX_XATTR_DEFAULT; + /* init xattr FID limit from fsdev config */ + s->ctx.xattr_fid_limit =3D fse->max_xattr; s->ctx.xattr_fid_count =3D 0; =20 rc =3D 0; diff --git a/system/vl.c b/system/vl.c index dbdd4f2257..eb86d725bd 100644 --- a/system/vl.c +++ b/system/vl.c @@ -3259,7 +3259,7 @@ void qemu_init(int argc, char **argv) QemuOpts *fsdev; QemuOpts *device; const char *writeout, *sock_fd, *socket, *path, *security_= model, - *multidevs; + *multidevs, *max_xattr_str; =20 olist =3D qemu_find_opts("virtfs"); if (!olist) { @@ -3323,6 +3323,11 @@ void qemu_init(int argc, char **argv) if (multidevs) { qemu_opt_set(fsdev, "multidevs", multidevs, &error_abo= rt); } + max_xattr_str =3D qemu_opt_get(opts, "max_xattr"); + if (max_xattr_str) { + qemu_opt_set(fsdev, "max_xattr", max_xattr_str, + &error_abort); + } device =3D qemu_opts_create(qemu_find_opts("device"), NULL= , 0, &error_abort); qemu_opt_set(device, "driver", "virtio-9p-pci", &error_abo= rt); --=20 2.47.3 From nobody Tue Jun 9 23:07:36 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=1781015187; cv=none; d=zohomail.com; s=zohoarc; b=b5T8bOdIFxQ+GyceSimp1LQ8GDAs4N5s4m9f2zfZqUhjH+Th1j1FPgiAUd2WuZ84ir+mqqiYIghlJKuHDRlZs6GydOWZxgO3kn3ZO6byWlmCi2JowJmYRPA9dMjOPpEVHg4uPdOFfUhYxN5fMou+Zfz8X/a/zjxPCtYYkRgXUHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781015187; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ufiiCn3cvKp4ufTQLLv5qoeOBCcGqz3IzSs540NafIM=; b=a88L8G0VMomh+4dnuYTiIRBJFLDJrrdk0FqaquPV5aZXJlaHGdrhAZUOZMVxt6MXkHeCyyENCeGCGdpPod1NaG80ry3VPNSAC7D7TNUw3v04KXCUHOg7+ogi7ULLON9N2IgBFTWCaUcom2MlEWdwsnpgMLttsV7HtSEyTBFhGDw= 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 1781015187879420.2087085800407; Tue, 9 Jun 2026 07:26:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWxP9-0002gM-15; Tue, 09 Jun 2026 10:26: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 <2c100487252994d6d03baa499ef25e5e1bdaf2cb@kylie.crudebyte.com>) id 1wWxP6-0002cK-7w; Tue, 09 Jun 2026 10:26: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 <2c100487252994d6d03baa499ef25e5e1bdaf2cb@kylie.crudebyte.com>) id 1wWxP4-0001NW-7u; Tue, 09 Jun 2026 10:26: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=ufiiCn3cvKp4ufTQLLv5qoeOBCcGqz3IzSs540NafIM=; b=Fi/Yz okwBnuH5CibgeMvJpWAddLv/lN+TjjtTGfCbCYBTEq0i5blPTLDr4r68qvu3Zlli4LP28XQ7LM2eG vSirXOiq/Jlj3Up9UE3NrY+imIHyRdkvAwGW+yEVxqyMCpQxNlM/t2Dj58Iw8SlBVJDG6XkBcc+wM Xe9O6VualWktn0jgvUsOb+/D2zGj8J7t4oKl397bUoFHx+TNJgy10evmmZA8WqRwwOrBfloXH5wwB 1M+scg3GShwO0tU+/XXU5TbYPWf2H1LjVlU0whljcNOOys4yP9+wEaUh531W6YmndAN05BmLmbVRr 4/8LEebx0TukxkqTaO8rc1w17ISrUv5z8KiXHyljjMKCw9qCSyy/S1kAyHbHWwUdrC0qXqfcdr5Aw Jr6bYO1DrszcIiUqMouUV7IR2ys7FcA9Xw5h9r8DbebzKBso2J0uJPxV+qZZ2ZUXIth8ph8IZCcR5 3lUlK34Jm5BJ8FeDHagYpMYVXdgXRySJFcWzoeKeihL28qI+L33BytxiWv3ZcWw1H47oXD5XvxpKW jU66E/7Z9MDtL/1YE3E+oITU66YYJ2xLxoT+4SWY0xmZd9VCsE4lYaFGRXaZn88MD//7KlOBthpWh DfvE6IkQ+rCrEG3eRCyoY1CVdGGIz8Ly9B9NH5ZoEFtH2z/RtgrujdKVqgyESQ=; Message-ID: <2c100487252994d6d03baa499ef25e5e1bdaf2cb.1781012549.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 09 Jun 2026 15:47:06 +0200 Subject: [PATCH v2 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=2c100487252994d6d03baa499ef25e5e1bdaf2cb@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: 1781015191105158500 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add documentation for the new "max_xattr" command line option of 9pfs server, introduced by the previous commit. Signed-off-by: Christian Schoenebeck --- qemu-options.hx | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 96ae41f787..456d44af39 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1914,19 +1914,19 @@ ERST =20 DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev, "-fsdev local,id=3Did,path=3Dpath,security_model=3Dmapped-xattr|mapped= -file|passthrough|none\n" - " [,writeout=3Dimmediate][,readonly=3Don][,fmode=3Dfmode][,dmode=3Ddmo= de]\n" + " [,writeout=3Dimmediate][,readonly=3Don][,fmode=3Dfmode][,dmode=3Ddmo= de][,max_xattr=3Dmax]\n" " [[,throttling.bps-total=3Db]|[[,throttling.bps-read=3Dr][,throttling= .bps-write=3Dw]]]\n" " [[,throttling.iops-total=3Di]|[[,throttling.iops-read=3Dr][,throttli= ng.iops-write=3Dw]]]\n" " [[,throttling.bps-total-max=3Dbm]|[[,throttling.bps-read-max=3Drm][,= throttling.bps-write-max=3Dwm]]]\n" " [[,throttling.iops-total-max=3Dim]|[[,throttling.iops-read-max=3Dirm= ][,throttling.iops-write-max=3Diwm]]]\n" " [[,throttling.iops-size=3Dis]]\n" - "-fsdev synth,id=3Did\n", + "-fsdev synth,id=3Did[,max_xattr=3Dmax]\n", QEMU_ARCH_ALL) =20 SRST -``-fsdev local,id=3Did,path=3Dpath,security_model=3Dsecurity_model [,write= out=3Dwriteout][,readonly=3Don][,fmode=3Dfmode][,dmode=3Ddmode] [,throttlin= g.option=3Dvalue[,throttling.option=3Dvalue[,...]]]`` +``-fsdev local,id=3Did,path=3Dpath,security_model=3Dsecurity_model [,write= out=3Dwriteout][,readonly=3Don][,fmode=3Dfmode][,dmode=3Ddmode][,max_xattr= =3Dmax] [,throttling.option=3Dvalue[,throttling.option=3Dvalue[,...]]]`` \=20 -``-fsdev synth,id=3Did[,readonly=3Don]`` +``-fsdev synth,id=3Did[,readonly=3Don][,max_xattr=3Dmax]`` Define a new file system device. Valid options are: =20 ``local`` @@ -2000,6 +2000,12 @@ SRST Let every is bytes of a request count as a new request for iops throttling purposes. =20 + ``max_xattr=3Dmax`` + Specifies the maximum number of concurrent xattr FIDs allowed for + this export. The default is 1024. Set to 0 for allowing an infinite + number of xattr FIDs. This limit prevents host memory exhaustion + attacks by capping the number of simultaneous xattr FIDs. + -fsdev option is used along with -device driver "virtio-9p-...". =20 ``-device virtio-9p-type,fsdev=3Did,mount_tag=3Dmount_tag`` @@ -2019,14 +2025,14 @@ ERST =20 DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs, "-virtfs local,path=3Dpath,mount_tag=3Dtag,security_model=3Dmapped-xat= tr|mapped-file|passthrough|none\n" - " [,id=3Did][,writeout=3Dimmediate][,readonly=3Don][,fmode=3Dfm= ode][,dmode=3Ddmode][,multidevs=3Dremap|forbid|warn]\n" - "-virtfs synth,mount_tag=3Dtag[,id=3Did][,readonly=3Don]\n", + " [,id=3Did][,writeout=3Dimmediate][,readonly=3Don][,fmode=3Dfm= ode][,dmode=3Ddmode][,multidevs=3Dremap|forbid|warn][,max_xattr=3Dmax]\n" + "-virtfs synth,mount_tag=3Dtag[,id=3Did][,readonly=3Don][,max_xattr=3D= max]\n", QEMU_ARCH_ALL) =20 SRST -``-virtfs local,path=3Dpath,mount_tag=3Dmount_tag ,security_model=3Dsecuri= ty_model[,writeout=3Dwriteout][,readonly=3Don] [,fmode=3Dfmode][,dmode=3Ddm= ode][,multidevs=3Dmultidevs]`` +``-virtfs local,path=3Dpath,mount_tag=3Dmount_tag ,security_model=3Dsecuri= ty_model[,writeout=3Dwriteout][,readonly=3Don] [,fmode=3Dfmode][,dmode=3Ddm= ode][,multidevs=3Dmultidevs][,max_xattr=3Dmax]`` \=20 -``-virtfs synth,mount_tag=3Dmount_tag`` +``-virtfs synth,mount_tag=3Dmount_tag[,max_xattr=3Dmax]`` Define a new virtual filesystem device and expose it to the guest using a virtio-9p-device (a.k.a. 9pfs), which essentially means that a certa= in directory on host is made directly accessible by guest as a pass-throu= gh @@ -2092,6 +2098,12 @@ SRST Specifies the tag name to be used by the guest to mount this export point. =20 + ``max_xattr=3Dmax`` + Specifies the maximum number of concurrent xattr FIDs allowed for + this export. The default is 1024. Set to 0 for allowing an infinite + number of xattr FIDs. This limit prevents host memory exhaustion + attacks by capping the number of simultaneous xattr FIDs. + ``multidevs=3Dremap|forbid|warn`` Specifies how to deal with multiple devices being shared with the same 9p export in order to avoid file ID collisions on guest. --=20 2.47.3 From nobody Tue Jun 9 23:07:36 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=1781015245; cv=none; d=zohomail.com; s=zohoarc; b=ZEaHhzwO+1O1p3gTtUVW3XEpwYzUJHt2fcwIcHN//Txa1h+wYikrfswT/IKuC2NqtE8F3IuhWTC372+k4U7uRTn4OpEfr9plxKdIJF7e3qScfua/ByX8Mcp3BwY6bL7PPgy/s/+qT8Ar2HS1jmekwHYs4iyoOEyicbNcCUDoQKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781015245; 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=a65/ipB44e9T0MvXrq43ov7aQRyC5PjH6WrzL9bPi97KJNsOSpfq9edZrL8ZSOmWSuBsSqRUl3bHjssEbfbQHz4ELPJdz/t9kU/UkTShIUpVR1tNU4UgOlq/eQCBzEkjpfy5/o4vQwZLtuOot/LA9UpQ5PrLtDJ/yG72C7UDQXk= 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 1781015245357455.4596555810176; Tue, 9 Jun 2026 07:27:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWxPY-0002tC-KO; Tue, 09 Jun 2026 10:26:36 -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 <67b8808dd6074564656e19bbbf6dc3580a80bf57@kylie.crudebyte.com>) id 1wWxPU-0002sG-LD; Tue, 09 Jun 2026 10:26:32 -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 <67b8808dd6074564656e19bbbf6dc3580a80bf57@kylie.crudebyte.com>) id 1wWxPT-0001S0-2O; Tue, 09 Jun 2026 10:26:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=+Pb1E062e+vdMI39HgiCkAtZTwKmpyquagDGi2YMRJw=; b=oRSC3 2T0nywxwSe/Ws0w+DdiqpPAGuQ+FE4UgXuPHfP11tNlb/4bJYrKmxP2nDxzieWOOfGT2MAgIpxM8G lW5hE8VVIJ2hCmUPZZQbeqCJ63kt7Q1XAsKQtjGTM94xtM2H2OMcHXW8vP3wNhTkBJZU97Y9mzTPk zkkQZ6W2UAMwZ3LRUdsLq/+YLxV+wY8tCq2vzkF1dsI1MQf1aFf4k6zVQHiRUT2uJCId/tnfSBjoX 0BRSfvwLyhJowrgJfr5HzfqPIJdN/2aQOvgokfC88UnRE3jmvwJEdFbCtOmeSe7FA2oDRz8e+oT9s 1dqVh9JJUzI1CjXfUYaCuXD5jFx0Nqba0pmEzq5dl4tHUZv0wYJndfcZlX6P/G5z3x+7O6tJ7eh8X q9OPwPEZxlJB9BRibAGKAZsIaH8U4/mSlOtJd6KrigiEm692y42SQ3GW3ffPKYvfU98H+8iFJWJAk 26L6ufaHtCUYussYtM4+3r92OqOBZjQCZcCChYepCcEkI5FLhFI33yZbOXJeWBo+lcEGVrsqcJW6U YW9XUmv5PvMUtFz1d+C337Jf0/ru7ZHMhfm1BfMdGXwaLQpQWoyEqz0t0zszZba0XqNIghwGu2ERL o43iP2fCagjKu1tbuzDEU6LXNbq+pe4d2nvdxl2vT+9XYTrv8bRlAvT5RUYLVM=; Message-ID: <67b8808dd6074564656e19bbbf6dc3580a80bf57.1781012549.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 09 Jun 2026 15:47:06 +0200 Subject: [PATCH v2 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=67b8808dd6074564656e19bbbf6dc3580a80bf57@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: 1781015246525158500 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 Tue Jun 9 23:07:36 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=1781015267; cv=none; d=zohomail.com; s=zohoarc; b=hmkWQPxdrfn/bA+pdkW509zEZZUwPAqyZqhHWH3NG7BHeY3G+Jgnp4iZEDd0gXGGg864jEyv1smRSPHE0S7huF6ri21swyIRCyHS2nCFngHafCp7XuHkRks8P0OlIKGVyxlhf2duEWKgttG2xwJZz+tMsF0uC9FBXBFPrzCE4GA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781015267; 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=DKPP2oDhnew4owbUhJUGC18fD/Dv9sl7RQgyI2wbwrO6acucQac7HX+t/DkY30mVr16y9QmCgoNMGhugAKZHneI2fitWXUOGZmB3fn+38Q1vSkZ0u7zXRa/IHPQp7TUlSqGG4YzwQeXRHAOotqIwoIabFQ1XfhWbbC8/pSxhxMU= 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 17810152677044.96979629753173; Tue, 9 Jun 2026 07:27:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWxPg-00030L-Ef; Tue, 09 Jun 2026 10:26: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 1wWxPc-0002wL-DW; Tue, 09 Jun 2026 10:26:42 -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 1wWxPa-0001Tr-PN; Tue, 09 Jun 2026 10:26:40 -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=LP8wt ToBR6mYxo0FoMU02HT62xJcKOXyz1LsL1JeZQOPnXHudxbh7hGOw/yJ+Gh+ouG7M3fCQpWQ7TK5ez pJlUQF/ucl0jtKTq6uvDL5JczPGNxETFbTSITEq2FQmO/4mKsbCTgmzaKF6kDDUaSoznq1JflJDUL HLXFKRHvsXOViKvZV6fOLjcb/rkQzRMaQirh3RQj5D3PkmeVImeivUVDzCcnLM84Rdz4zCuv29ECl DP6U7hQQLqVxK1+JdzomzAKBA0dSY2qybgDz08AkWmZHUWdAJM5aN2BX5P5PogKr2webFTR57XVvo U+dYtIhqSQIYMKuKN/FxqvkeD/69Ke/Ela4ZRVZE0+X+1jGnIom2dedxl6IS8OjLogNPJ1+Vbq50X gsZrnRb1mTF3ZepN4fRpCb8y2gy0T7ektgQmTUVq86xZ5BBQmHdYVQqKpz2O9diZFoLw7eLR55fxf uXqZa2NIrmKg76MLmKklykZw2+ff9i0ab2pLP3rqhplNQOwsNZbmzsyjhLs2+1xNUicnJzB+vZ2MC qcY5hJxvKnmvStJ9E21Gi1RK8DpeCKkaek1oH43pRswBdxk8jTyLOIEl4Dh9jYTux1WD70aDQ2vFt Xgy57AwtSoCpU6fdDV48c/XUtaz3CqymljsjWIr5cDiXDyVdYgk1+2gDp6nHlA=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 09 Jun 2026 15:47:06 +0200 Subject: [PATCH v2 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=f13f16c0fca4db8bf31960139d169b4d280c8776@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: 1781015268517158500 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 Tue Jun 9 23:07:36 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=1781015252; cv=none; d=zohomail.com; s=zohoarc; b=Hmt06iGI3tE4RTbKsLDRIt26t1ob9x6koQBIzp4zAJYwATknL+DkQUMjmf84Ne7wG4dvfEAt+5utctYsZAlRPfqflUWKYeMl2xRkN7vfWG8KCSMcl1xfvPXKauR/lvuktmwCT7IzgI+w65CUaPjaHacBKM/WbsmBNsfr+8Jb0fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781015252; 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=MSttUJ2aERnwx4MkwfNO5O5fQZK3wRgCHZoO+iexTJkoZYZTGm6qxOCwfltBUq8oxciIYJcLNSIBK+qfVfESWelaqb1nTOvWiNlgL8n6R3Q3gZF1V9ththWllO/8e1WGkO2OymZq/pE4aL6JdE5pocfWReS4CS06SEbFPXTOOJk= 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 1781015252024198.2072804780954; Tue, 9 Jun 2026 07:27:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWxP6-0002as-4i; Tue, 09 Jun 2026 10:26:08 -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 <7ccb2b891c1afdfe38eeed8addd1e24713c2c8ae@kylie.crudebyte.com>) id 1wWxOu-0002YH-KW; Tue, 09 Jun 2026 10:25:58 -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 <7ccb2b891c1afdfe38eeed8addd1e24713c2c8ae@kylie.crudebyte.com>) id 1wWxOq-0001Jd-Ov; Tue, 09 Jun 2026 10:25:55 -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=aMHb6 r0qJSzQxrhiFSuuh2TzeFDTolqDHsCAgJwuqH/vpBOXihRSflDAkvHtsLCV323C366bb9Vq0HpyN6 kYpzy4BXQZ5WhSs/FX3q2swE6zjyyxuCdag3jGK7AwoXwUpUl0S6t69EMHvIheRTicTqi6S8o4JLW LwUOkkS5hXf3xx0ljvdwfcmq98Mar/UmssmwXphXQI1N9tP9UiJ2LIwNI2dtUGV4r04aH+AbvMbEf 0wPaXJK5z3U488x37s0E5bJ/V8Sqf5Ld373gpYv1lFNE5M4BvhcDZGtl9p7YZo7GLaB50g41QdtCT PUUFoJ/xKlVjpGPrwzAKUcuBjbIcFw0uZQ8pe1KgeP7W8GnS7sfVQmTUBn+wdP9c9pcUrESqaywkw C4YTRVYVrkuXQfvDXMhmVzUndyu+HD5mokz4PUA+McCPYoaeodenNLZfbo0nZtWUUMscHkIa8C6eN a1PPQV2+0/K6FWZa+kxIauO86/8xdNecZtBsUCwlsmf8lbeMTlWXLhdy32AtDeYzF4Iyzaz1ep4kl lHz+tnIe65XH8kRbwJ+KPptwJzv0M+HeqGOMLOO6kL82mglecRpmBm4OoA0mj9aQclmYJdy+dipTC rt3MskwJcmoTYxBO+Y94QF/9tzfpqMsNcO8JwgqcJ54APULZ83k/XP22TRCexo=; Message-ID: <7ccb2b891c1afdfe38eeed8addd1e24713c2c8ae.1781012549.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 09 Jun 2026 15:47:06 +0200 Subject: [PATCH v2 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=7ccb2b891c1afdfe38eeed8addd1e24713c2c8ae@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: 1781015252562158500 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 Tue Jun 9 23:07:36 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=1781015254; cv=none; d=zohomail.com; s=zohoarc; b=gXC04brK4nS8V1eVgkJ+XRq7YA0j1MyurzDaC9IcyYCjA2zHjLbyRnvf7UvuTmGcuRXJw/Yh41ppR4Fs4KJ48dQl9hmh2V/IcvFkLZ53Rkot+2m4midZkYJl9b6ni0rdTUqiL8r2JmacDKWQHM6skXvluVNHqhCWHgsUQZ3/3oM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781015254; 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=QM923y7yw05sOWtDox+PL7B4BgRNyndtv8uDkBipttuFF9Y/zqX1MOCg+QEoWRl9Dhh4t9duC2xlT9pl1QZJ25VFg6WuVXTmx+yFHjNCf7Dwda8NVHs4+5DpU+rDT0cwJ1/qmQUBBhYgReNtbWKe94SMETdP/lV/nU7rAcvbaCo= 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 1781015254651184.0057420084779; Tue, 9 Jun 2026 07:27:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWxPe-0002xX-Hz; Tue, 09 Jun 2026 10:26: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 <8025c35d04272eebb6d9d04ad607ca5c3c2c046a@kylie.crudebyte.com>) id 1wWxPY-0002td-Ov; Tue, 09 Jun 2026 10:26:38 -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 <8025c35d04272eebb6d9d04ad607ca5c3c2c046a@kylie.crudebyte.com>) id 1wWxPW-0001Sm-KO; Tue, 09 Jun 2026 10:26:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-ID:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=sp0WkOTMIe228ItB5HcjR8cQW87AIQqOYxQTM+5MspM=; b=oO6A7 VpgnhRxK1zorSTb3GEeCUgKdYJ0EX1TmfbDVSD1EROdVisX68vhAlPxV9lXw65C99XgSnrqlOc1Vp gLw/XloS/tndUgPtk1iXnM9UMDXlkRg4wpLIOoxmZqMKKtEdv5lNDCyG7DWARTlsRle4kQ1ZwmTrM dgLFi3PDTBkU3MDZmA7tNX8L+mA7SM+EPfLOxuJT7u8FBl7wEHe/OQWecrhviAqXDQwMzDsboxXKL OlZNAc0bCCW2ZcrbmA7CNxq5TJaMLeHpCZWn2FjzmiL/7vx1Anv05OB1yrkkL9/KxjPeYsywx6XQf +NSzF6RHR1lzn5je/KEhVwtmai2+/NCcar177ud4CVK+n+mocilYFpDYxQHtdSrMU9EwPGVSeQdCL /DKJpZCAJHavzM5rluiKr4sSPSS86k119VY35qKoTCTQV+vrtP/mdEQYwzXJui8SdLtyRaV4T+aIy w3MbLwbGEG294bYRgg/eZSYr3bQoDb0O+B9AIZv81in/p5WoGJkXet/EE25lBxsnL/i43qXr+HxzM UG1yGCNbGeD6L2emQZGpcwjkmognsgdX6mbhg1s9Cygem541W53i+F7boCVYXE7x2lZx+MEskbtbu QD5wnv6Ra7qjE5BUIw2zeJpsRko5207WscOXXEGRBm1HOlNZQB2b7e9Z9aabLY=; Message-ID: <8025c35d04272eebb6d9d04ad607ca5c3c2c046a.1781012549.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 09 Jun 2026 15:47:06 +0200 Subject: [PATCH v2 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=8025c35d04272eebb6d9d04ad607ca5c3c2c046a@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: 1781015256467158501 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 Tue Jun 9 23:07:36 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=1781015289; cv=none; d=zohomail.com; s=zohoarc; b=hQCuXnjZI95bX5j9kQlgw+OSz4fFqctz5OhkZ/JuVHGWrE4ySltFNMtg+NNfGTNh6d4/kJ/sZy/Hobo+JXgcsaColLbeKTPZ0Kk3t3NITKL70Wq/LOrRJ1MJPfgScEaCdCRabcjxsWP3tqdjU60qCqHFVp6IrCtf4MxEHdK5uZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781015289; 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=SapX8AMeEdlOfy0TmbpWYYGHIQa/U1aDGMIVyW5H3uJzWsqnZzGqoUnhy3ZFccTzxEZcuI3M34VtZXrw8Dbb0/V1rNIfusocHCMUU66MnR0J3aaF0p25unwc3FsOvlqWn1X8nkSz+19xjfuzT210fv1IhX2HOqFcLUAn6QSr2FA= 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 178101528936566.61586639920029; Tue, 9 Jun 2026 07:28:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWxPA-0002hU-T5; Tue, 09 Jun 2026 10:26:12 -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 <46e28e8fea419cc93bdfccb6f5c4af6c86cfc25e@kylie.crudebyte.com>) id 1wWxOy-0002Z7-Do; Tue, 09 Jun 2026 10:26: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 <46e28e8fea419cc93bdfccb6f5c4af6c86cfc25e@kylie.crudebyte.com>) id 1wWxOw-0001Lu-N0; Tue, 09 Jun 2026 10:25:59 -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=f07kq yvgGSWqGqELzWStuom9BFoDETEw6II7pJCfxSReBIRXjsvu19XMk5btsNxYf9t3ZOhHVaT/2VyPr8 AYgi8OZ9ITFzCZ6eQ4O1frRaxPRUWKfZC0VlNyFRvk8ruLtRf9K4W0Q7ykozWhFAytRlhntpFP/ZX qJsyZsZCeAQVFA6DE+Tk6LYhdS/DGuinydED+0QQzYmgSWnUqeXhoNw9k5zH+NxK1NSYvQP+ilfjw kaPr1COFVAw5wNSVDtjIT/hrVUKxwCAG5oKa9HWqjPF7E24N5jdLDkznQFJ3Uj6kVpz2FzKzNHKb1 GW9P3zXpgcwCv+P6quyX/1UCn1Lu4Ul48z1zPGolhNujVgplOTOD1aeL1ByWERkgpCDDg5/zcAFVg +TVvb2HI5SFbS9UaeNQvR0eYE1voi200+9nLN46UIQmfGVNNzlAkB5XaRc1RtM15dlbT/KXKm9JAA CmpzI0aljw6/JWWjz+g+Ab31WsQtaMTaZpyVLFXUeEZFMu5P3hufXkmhtmYiXbQlQnsYtq0fkl/kY K4A+0eaHIw9J9L+9H8CyAcs7D45cCLAGa+zaxaeTqKWXrfjE/AsBqR9lPW5ox45oi0x4SA4RfbWK2 SBfKcQJQEzxfKIA+WHLZ9hUTf+pLoyyKc4xeK0sggkcyALg4CtkxSuplQBF57I=; Message-ID: <46e28e8fea419cc93bdfccb6f5c4af6c86cfc25e.1781012549.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 09 Jun 2026 15:47:06 +0200 Subject: [PATCH v2 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=46e28e8fea419cc93bdfccb6f5c4af6c86cfc25e@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: 1781015291843154100 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 Tue Jun 9 23:07:36 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=1781015313; cv=none; d=zohomail.com; s=zohoarc; b=BH1dCLBhLqvEyUUqCygAWjcR8ezVCCTO0Fn4SJP/igHtpnPyEpPiNs89J2BAnirlb25sOq7nlYrpRCDHp3ajYmPgKtIQoObBpxEYeaB8abHYMcki2anGRHOEx92lzurT3EvYdxexfBksanpItGZqX/+ziZf76PZEbSmN2K5HRjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781015313; 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=A+YIaNh499mY9mV7XNDc3ynf6++moeL0zmmANidFNlARRDm/osE9qzeh6BDtUdTcxed23rfw2UStTE3ZIIlhVBg+6t9VyXTv0Q3sI4S2Rr9H1AOioMrLfApVXEi4aV3ukED0eVUBfOJ1Vs78nYR4SsZAFwhyW2Z5ZkA7M2dzXh8= 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 17810153134541016.5577672905804; Tue, 9 Jun 2026 07:28:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWxPi-00032D-CJ; Tue, 09 Jun 2026 10:26: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 <092e1c05ab1dfb7ca8950195a55ffb5e951d0904@kylie.crudebyte.com>) id 1wWxPf-0002z2-6h; Tue, 09 Jun 2026 10:26: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 <092e1c05ab1dfb7ca8950195a55ffb5e951d0904@kylie.crudebyte.com>) id 1wWxPd-0001Ud-SW; Tue, 09 Jun 2026 10:26: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=Nvijw5zxNpcwR19Sl1opG3FKxsazjdsC775GYkiqEho=; b=d3gne KVLPb+o1yyiLz+abIsRsmyyWd9Ktp90QqSCzpCd6f+kEVPjlN/i4lF9TQOOsxClIsVsSa1k9lQvjq MTHYjkKYGFkQ6HUsGXLIXsFelhs0h4LUl379cn0ihQoah/hiEyZaOMWhM1SH2HKKEDLw4lwOAephn oagWJ3sI/768Kspe7zNC7Ivo3MpQ3pZa/dNbUrbIpMRZVlnpuFjJ3Cyhb0BDHyCZ5ZBWFnAdKeGou cd7Eddwom53idFxtndXP+bT95KBV268+Y0TTFlH3d10xRGUNwdar6UcPknDlD3efSjJJ8TW+x7Muu 8U/8+JrRwl1E0q2yNgUSmwftj5CeXn/Vb/J51Og9tQPh1zhDc9KhCK3SiY2K71vsvNi0VWu6dfYwt VZnerXt2E7wHcdd40scnn1uMQ6uAN/13DjKuwPPEZP0HhH3ugdxSxhu0K2d118szuatqEnqIjwZlM NZom1cy4+3FX+/NxHlz35krx0p/l0nQiGeai9Xc3XY4AhNIq8eMhpNnmI7j5DDPfCK64b5hP//+hI idoZZX4COnyNqSgohaQ36QnhHIRmo+kxA296WGs7VrLRxECBp8vVt3b4pyTCxmm5kj43IMzdxj2Bt WfSqE1wZOLtFdQ3hZAA6zX3nPuBbyfeNoi7wUgihnUsQf+58YEOGwtiTE+yfBg=; Message-ID: <092e1c05ab1dfb7ca8950195a55ffb5e951d0904.1781012549.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 09 Jun 2026 15:47:06 +0200 Subject: [PATCH v2 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=092e1c05ab1dfb7ca8950195a55ffb5e951d0904@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: 1781015316261154100 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 Tue Jun 9 23:07:36 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=1781015286; cv=none; d=zohomail.com; s=zohoarc; b=CQxsu01MeJs7/sI7OpOgE4h+y5eClxvGn9k088Im57OIc68p6HCEgVHC/bfYDMyqtmVEI17ufaHIfnXl/nr5iVPQ+zIACZACQPWjgBnhBdEH2JYs2zk3N4jBXYwTHCZFp6f08nb25FJWWiFV2spcWC5gx4s+uoJ1qa+O4QMzzNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781015286; 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=U1TD9P1vLvxnNtieddyhzC8iKx+7U8vQsRLmdv7qX1RYevV3ZbFL5U+gWuIair/kH6whiDkpJor2hdYyNOjoJsTmI4eXyXOtQxPKWi4IBRAD0lL9V9TLFIb9BI74yKJkrvDo6mNCfEVasvmOaLD8XYVJs2pKU25l+xsSAUymp8Q= 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 1781015286912128.30212121496004; Tue, 9 Jun 2026 07:28:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWxPR-0002rA-S2; Tue, 09 Jun 2026 10:26:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wWxPQ-0002pI-GN; Tue, 09 Jun 2026 10:26: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 ) id 1wWxPN-0001Qs-Lc; Tue, 09 Jun 2026 10:26: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=vsAnzYnUkbJPIjTxynzHZ+ERTcjQW3lJwhEltlSR2jw=; b=LC8sH ETMRpplF02XWG2v7SUVSENN1lCjyBx5xOxnHVMA7TFsSVv9X5GHAeKDobqk9D+7jthKFLAGSfOYgH FOQs1SFge5uDKzBGJ6v+LWOpVfCL/ZMdVhp++xhJNsgNUc0ND/QuJSTpeswndxl6jFOzv3cOc4IM6 iqCwoyIvIFRjQ3PfvThTodF3GgccmpJJWo78+SvyUlptZm2/fBvXoCbubd8u49V37P4WKkNFzsc6a hJgRk/J43ymTnzh+rj7KvhZzUxWGiCle0hCt3iMS2A8RRuZTammQCMHP+3Xosx+1aUbMULz9/VqXA uj/voKZJirN+zOhFUmKjO4nfscYuyrcuy5ElsfyV3bgzPNRxuvYGI5Yzo9rGErCPar9hJ/15F4jaE uHLAfDlFo2Pe7mMi4etJ0bUyKxue6jYnNrwuCj9gNqi9P8Smce9qMFqhZzC40+6dg+uknExnooBUj 6bDYFLvaeEXvCw7DkkrdewiAVIb8JPhsDJ8ABAgJRou/yBBfsPSqalkaMf5xqsrpea4lK0swohRUY hzinZpuCnLdMaVoFTy+ymD3hbM6ti7ZXdXA7qNShP7UvSwdbHuIKA2o2BwC3BL7zz00BLvsn7GQ/Q Lf7Cd0Ok3np/6S8lMdnbAYjNDfeHba3P8vHed1hbKA3ExJJzW68HtvUEvf7qrA=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 09 Jun 2026 15:47:06 +0200 Subject: [PATCH v2 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=df93ef4700c808af4c120ea0e636b28539fe4598@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: 1781015289797154100 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 Tue Jun 9 23:07:36 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=1781015290; cv=none; d=zohomail.com; s=zohoarc; b=AhIj3h+g4Ml7D6ZvNBTNccmvR6mht5C4Q3EPJSZnT+PLaYqo4zfV/9aUxDQWYNjIGnSlxOmXi8v4CiezZQ5a3a0lHEFiFfi3rtZOnxyoNd42hTzxxbNcQgoBcOxyFdYBaZN6djjddZHZGBcGW5bhPUL0XroHnztvDdzM0MsG098= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781015290; 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=MPXirfvjJ7Fh7uljcTgPHq1el/KLSC/poiStjCdWqDE=; b=FMNrVL5PfaKCyCGt72f9bfRO7uptcBzozG7jzzh/Jg554DrH6pllXmpnS2+FS+rjGeEAaF0Hu8GKv45UMpNj3nykH2VcvQiPUEGwvBzY+7EhBvVKQoFNJR59p6jWCast3Nu4OZpTZ0zEFOU4roJ/ktfhaU9CkKeBgZeb8vWew1I= 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 1781015290264826.2445756834901; Tue, 9 Jun 2026 07:28:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWxPO-0002kr-Ms; Tue, 09 Jun 2026 10:26: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 <831b5ca3fb4dc81f8354fd6eedc405d12ac54a92@kylie.crudebyte.com>) id 1wWxPL-0002kB-FQ; Tue, 09 Jun 2026 10:26:23 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <831b5ca3fb4dc81f8354fd6eedc405d12ac54a92@kylie.crudebyte.com>) id 1wWxPH-0001Po-Te; Tue, 09 Jun 2026 10:26:22 -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=MPXirfvjJ7Fh7uljcTgPHq1el/KLSC/poiStjCdWqDE=; b=kA8BL IAfb6ijo6R3n5PUXAkcthRMtYiwYBs0gFIs6XlHIwclxiCNF3S7MR6+hUza1Wz7+lEWu79i4f0lLv +YDepzCcorz7YBD4gveTMNkwG1own9txPyqQw0O5XlmBLPW9ugyi8MIg6G9c+elM4Z7gYp8IV1lWA PzExt0Ji3xbaC/7hqPfB//L+pSneY2xIvq+XBZB5GgDPVUz9xoI8vXYXgrlBnQSR2FnuwqNgSTfCH SZN2c0izwkPqoUnABdMqZnlfJpVSwVBSf/IN2dAv+fGXg6tx94RscIDo892ZL7InFiFRN+4UmPdQM YG52fRv1a3Mk3iZQAD0cRcNKyJRPaf1X9fRQ7+vdr6wkQ0rXDUhZi45WoigVOvkemXeRD/8jnqjh5 AU+ylwM+fFd6weLg1+4rz8hD3NFPQewCQ8e2pgDlSkDhiFz3m5qGEJWu+Tzk6xrjCxOOAy8AgoWPu ItPtTnog+HUqVUjiciVZaAv8OWZPqsSvRQQ7I4unSoksKOjYS1OFQtiCpJdnJ813bK2H5oQbgksLb tfIlDO9QJQbzY56qnp2rSm1RPhR6ryvjKrUpBhmYq1dG1dibbhVH/FV9RkU8CFsgrOUfrjNmeuq93 fH/N3BC9nO/zflm58viLgvMC7Gpc2bn2cjnNZ1FFqjaQdJQNXeDInjHEOL957g=; Message-ID: <831b5ca3fb4dc81f8354fd6eedc405d12ac54a92.1781012549.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 09 Jun 2026 15:47:06 +0200 Subject: [PATCH v2 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=831b5ca3fb4dc81f8354fd6eedc405d12ac54a92@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: 1781015290737158500 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. 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 Tue Jun 9 23:07:36 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=1781015213; cv=none; d=zohomail.com; s=zohoarc; b=KdrLuZFZr4Bep/HFenh8ffdiU0RlrfBwVVj6XuZUQamefr82X2e6N3X5LAw02h3UII545rt/3FLQxuO2FlCtULRO4CtqdQ+iDfv4fq+kxs66e6EZksdSgEVCr3ewn8N57QMncRWnb0LzPzrbD/pXPUXJIJ3yq6WG3xCcFznF90Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781015213; 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=IV4PgttiUqlqURT7+C9EUr8y4+9zRUQRPXoakWSXJ4s=; b=ULcbD1vGJ1xhrf0Br9MIRhpMCXIu8wElA97BfHd21P+xRgPAYH+QzlFXX8OWZr0WNsTleVDfbiThyHddqnNXA9SF8xh3yQhHreb3bFtvNzUupXix/jGwJ84VO4C+xYR1OuLzNYs6btJ7pdKZTAJJeG7WUOuhpX8mF3qcBD/b09Q= 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 1781015213213551.2783660477613; Tue, 9 Jun 2026 07:26:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wWxPB-0002i6-EK; Tue, 09 Jun 2026 10:26:13 -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 1wWxP9-0002gX-Bj; Tue, 09 Jun 2026 10:26:11 -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 1wWxP7-0001OA-Na; Tue, 09 Jun 2026 10:26:11 -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=IV4PgttiUqlqURT7+C9EUr8y4+9zRUQRPXoakWSXJ4s=; b=OiaKB Mxv3i/Mq6zmVQfQtVhDj4FlnCVJfOlDzJLwbdE+3ztkw2KV2MzWXmAIhhgXKxBTaTrj/GjJY2TM2Z NKcjKdMC8/zxRNsNTsyAkeCMnz2u3gb4iCYlOGske9mJS6RmYj5QVpftRblKvuj+xLdRZTi5FKBhV xXqM6NvgRSXkHslck7eOtnIVFDV3nDCsxsItCkgqvCkyUH5L7DMjM3Tm1Isgzx6NwNdjSVDfWKkJq 57Pjf4VnosIpAbrgMd7qR5eA64dZSJOooJb81d/DnmNw/b8v4OVPIsuyeYTcuSSJM/EYrUqvvL1TH ic4s4XFV19iqesqtBhOjDwOnfNPlACqkTzoFy9kMu+ypRRQcNArjQ//wRpYDdBQaUA2YzEu+BM26F gqNNCHQAuscCYlif3H7Um9BznOw5+BwLDIZgqH/fUrOIKm85CONXOc3pGiuUQptuw+0PB0W08T6em wlCPajiH3MwXhfNbTtk5ioZF+DhHxWWCERY7e1Va23Mby4QjYbH/KAxn3vIz6aEDgIUqqG8dZP1PK sov2P+ICUvfneKd0wihqTynY1z+LDEa9xy3A9EErvSz5iYOHJn2hxYvD4vELvBa1yJnLHC5Sdla12 rPMcQFhq7WqhUT2oHOgyelQPlHeEM2+yCvtmf0z6ygUqjzqilbfuuKhucH0DWU=; Message-ID: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 09 Jun 2026 15:47:06 +0200 Subject: [PATCH v2 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=cf4466391ba7822cef445f4bdb62498230c73d07@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: 1781015228446154100 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Analogue to the previously added 3 synth tests, add (similar) 3 test cases using the "local" fs driver to verify correct xattr FID limit enforcement of 9pfs server with a real filesystem. These 3 new local tests use the shared test code of the previously added 3 synth tests. The only difference is that the local fs driver does not expose the current internal xattr FID counter, so we can't verify this with the local tests. Signed-off-by: Christian Schoenebeck --- tests/qtest/virtio-9p-test.c | 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