From patchwork Thu Feb 6 16:41:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13963338 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0EFEC02194 for ; Thu, 6 Feb 2025 16:51:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg53n-0008LI-LR; Thu, 06 Feb 2025 11:49:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <0ad7cb925edff3f14bd47fdb7ef3c0b6186960d4@kylie.crudebyte.com>) id 1tg53b-0008Ji-NM for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:48:52 -0500 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 <0ad7cb925edff3f14bd47fdb7ef3c0b6186960d4@kylie.crudebyte.com>) id 1tg53Z-0006DY-Vo for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:48:51 -0500 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=D9wDRyQBxJlr5I2gWNfNbciP1wRvnJLh7g260qArd8s=; b=S5RQ0 K3KqMFuQ8mrfIzynOPNmUYiJ++3QHACX3N6NICWwAao2dfS0TcOh6xOhvthx73Nw8UanCsQUtrgMO p0WQZu8ymCXPNUWjZKTtrKY3fSGnvDDl3h3ooGpM7oAjtM5aIASGbHNudvz8iLqWPNqBhy9xINhZ5 kS7Fgwi2yAgfSIYffx2rFmalyJaZ/vjmNFuLkbM8cA0ibuCOFendBfsp4B0NhKgAVcBWsMEr1JRvf uwNLTnqeHLf0dw2ni/0SHjCKkv1UiGgDw2BpvVkjnu3VwKy8kzAmww+XlUCu9Jac/66y/T2mIM+8R vjiexZOglbDO1vl+7Anv0te683ktK298uGqgRFm8xBeqHjh4XdxqRoTbRS5880S03i0JQqvcxmyq0 8vVITW9K6IGIV0MFvscrRYHqJejIgFwshTQMaUi9fWuwm1lg8Xsh+/E+FqdK4eYHtd+YmjsA0AjUM AkwXJlExM7XHzIEA2ZqDBRPXI8DiUywFHlkgEvsKRLk1Kj7Qx7wnqaJHlsQ7YNMxYCBfnyk7kHoDc Raa5m6/KrXk5f5zUeuIr1TUrO8xJd/DaamwReW1I6+mKRDIkW6BOuafhLIrAerx6RXP781fIN41uj LqG+21/iZUUKCT4wEMwgNI7rS9YQULbKJUDGrtBsWO+etgxrm0BaQTozTIwDzM=; Message-Id: <0ad7cb925edff3f14bd47fdb7ef3c0b6186960d4.1738860115.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 06 Feb 2025 17:41:56 +0100 Subject: [PULL 1/7] 9pfs: improve v9fs_walk() tracing To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Stefan Hajnoczi Received-SPF: pass client-ip=5.189.157.229; envelope-from=0ad7cb925edff3f14bd47fdb7ef3c0b6186960d4@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 'Twalk' is the most important request type in the 9p protocol to look out for when debugging 9p communication. That's because it is the only part of the 9p protocol which actually deals with human-readable path names, whereas all other 9p request types work on numeric file IDs (FIDs) only. Improve tracing of 'Twalk' requests, e.g. let's say client wanted to walk to "/home/bob/src", then improve trace output from: v9fs_walk tag 0 id 110 fid 0 newfid 1 nwnames 3 to: v9fs_walk tag=0 id=110 fid=0 newfid=1 nwnames=3 wnames={home, bob, src} To achieve this, add a new helper function trace_v9fs_walk_wnames() which converts the received V9fsString array of individual path elements into a comma-separated string presentation for being passed to the tracing system. As this conversion is somewhat expensive, this conversion function is only called if tracing of event 'v9fs_walk' is currently enabled. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Reviewed-by: Stefan Hajnoczi Message-Id: --- hw/9pfs/9p.c | 36 +++++++++++++++++++++++++++++++----- hw/9pfs/trace-events | 2 +- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 578517739a..6f24c1abb3 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1774,6 +1774,21 @@ static bool same_stat_id(const struct stat *a, const struct stat *b) return a->st_dev == b->st_dev && a->st_ino == b->st_ino; } +/* + * Returns a (newly allocated) comma-separated string presentation of the + * passed array for logging (tracing) purpose for trace event "v9fs_walk". + * + * It is caller's responsibility to free the returned string. + */ +static char *trace_v9fs_walk_wnames(V9fsString *wnames, size_t nwnames) +{ + g_autofree char **arr = g_malloc0_n(nwnames + 1, sizeof(char *)); + for (size_t i = 0; i < nwnames; ++i) { + arr[i] = wnames[i].data; + } + return g_strjoinv(", ", arr); +} + static void coroutine_fn v9fs_walk(void *opaque) { int name_idx, nwalked; @@ -1787,6 +1802,7 @@ static void coroutine_fn v9fs_walk(void *opaque) size_t offset = 7; int32_t fid, newfid; P9ARRAY_REF(V9fsString) wnames = NULL; + g_autofree char *trace_wnames = NULL; V9fsFidState *fidp; V9fsFidState *newfidp = NULL; V9fsPDU *pdu = opaque; @@ -1800,11 +1816,9 @@ static void coroutine_fn v9fs_walk(void *opaque) } offset += err; - trace_v9fs_walk(pdu->tag, pdu->id, fid, newfid, nwnames); - if (nwnames > P9_MAXWELEM) { err = -EINVAL; - goto out_nofid; + goto out_nofid_nownames; } if (nwnames) { P9ARRAY_NEW(V9fsString, wnames, nwnames); @@ -1814,15 +1828,23 @@ static void coroutine_fn v9fs_walk(void *opaque) for (i = 0; i < nwnames; i++) { err = pdu_unmarshal(pdu, offset, "s", &wnames[i]); if (err < 0) { - goto out_nofid; + goto out_nofid_nownames; } if (name_is_illegal(wnames[i].data)) { err = -ENOENT; - goto out_nofid; + goto out_nofid_nownames; } offset += err; } + if (trace_event_get_state_backends(TRACE_V9FS_WALK)) { + trace_wnames = trace_v9fs_walk_wnames(wnames, nwnames); + trace_v9fs_walk(pdu->tag, pdu->id, fid, newfid, nwnames, + trace_wnames); + } + } else { + trace_v9fs_walk(pdu->tag, pdu->id, fid, newfid, nwnames, ""); } + fidp = get_fid(pdu, fid); if (fidp == NULL) { err = -ENOENT; @@ -1957,7 +1979,11 @@ out: } v9fs_path_free(&dpath); v9fs_path_free(&path); + goto out_pdu_complete; +out_nofid_nownames: + trace_v9fs_walk(pdu->tag, pdu->id, fid, newfid, nwnames, ""); out_nofid: +out_pdu_complete: pdu_complete(pdu, err); } diff --git a/hw/9pfs/trace-events b/hw/9pfs/trace-events index a12e55c165..ed9f4e7209 100644 --- a/hw/9pfs/trace-events +++ b/hw/9pfs/trace-events @@ -11,7 +11,7 @@ v9fs_stat(uint16_t tag, uint8_t id, int32_t fid) "tag %d id %d fid %d" v9fs_stat_return(uint16_t tag, uint8_t id, int32_t mode, int32_t atime, int32_t mtime, int64_t length) "tag %d id %d stat={mode %d atime %d mtime %d length %"PRId64"}" v9fs_getattr(uint16_t tag, uint8_t id, int32_t fid, uint64_t request_mask) "tag %d id %d fid %d request_mask %"PRIu64 v9fs_getattr_return(uint16_t tag, uint8_t id, uint64_t result_mask, uint32_t mode, uint32_t uid, uint32_t gid) "tag %d id %d getattr={result_mask %"PRId64" mode %u uid %u gid %u}" -v9fs_walk(uint16_t tag, uint8_t id, int32_t fid, int32_t newfid, uint16_t nwnames) "tag %d id %d fid %d newfid %d nwnames %d" +v9fs_walk(uint16_t tag, uint8_t id, int32_t fid, int32_t newfid, uint16_t nwnames, const char* wnames) "tag=%d id=%d fid=%d newfid=%d nwnames=%d wnames={%s}" v9fs_walk_return(uint16_t tag, uint8_t id, uint16_t nwnames, void* qids) "tag %d id %d nwnames %d qids %p" v9fs_open(uint16_t tag, uint8_t id, int32_t fid, int32_t mode) "tag %d id %d fid %d mode %d" v9fs_open_return(uint16_t tag, uint8_t id, uint8_t type, uint32_t version, uint64_t path, int iounit) "tag %u id %u qid={type %u version %u path %"PRIu64"} iounit %d" From patchwork Thu Feb 6 16:41:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13963334 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED982C02198 for ; Thu, 6 Feb 2025 16:49:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg53o-0008Lp-Ai; Thu, 06 Feb 2025 11:49:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg53i-0008Kd-PZ for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:49:00 -0500 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 1tg53g-0006EH-1x for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:48:57 -0500 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=wWlmiOVMENnEwZf9iPw+EDJPnbEjYuKXLevRQyibxQ0=; b=rm3I3 bSkLFm07bvsTn5bzQKHxM9HosyNqpMYfJYybwxfYlFoo9P/A15ugQzl9Bski3UdDopG65IORNtEGZ n5kArh0tOAC5gAWpgiDzjwyH4+4oMH+YFmQntxEALa5dhW/a1ZOa+XUxzuA4murFdvX+UYf5WXHAD hJ+rVmSUY3mfQgvGjNCFs1KTr4o6/zepi8oTXCRqNpV9crSnPV5B8cCKCPb58LtU32eK5lwEAdoAd eMelZeJyhndMhkSKkkc3l4RA60sjSsKse704jHkk1NhCekvAGg5m3+0KK7G6FmlGS5fJ8ZpoCjMpC CGvY8Nlkd4MxmfpW4TqC7Rfi6IqPq3Mo64L/lILAdlZwqS724vQna9BnVHZ9PeQ6zv7+UXiQXX/K2 m4T1BeohJYij5a0qae6p/wCaQc5vsOdW79NhYpWgeqK4NTk2cmvYKkh70EMikhrXKoQ28+23ClsTL s48a7iePWc3ltsf5ru63eUPT2ybeIj/wMe/p/6XvNsmwGkEXYAdIVWZ9/t7s5xtw+1f+mbUHkeqZv JHG61ambBY+y/uR02A66K1dbBU1ap9zIkyJgY4NbUERHZ+kTirt7fMCSk5Vhp7YxOezR2GU+vqq+6 BcVrnXfmwWmo1oC+PdfEm5f7mD5as1jA4SxMcAhYWD++UUUxEiLm1F9gJ27ktQ=; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 06 Feb 2025 17:41:56 +0100 Subject: [PULL 2/7] 9pfs: make multidevs=remap default To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Stefan Hajnoczi Received-SPF: pass client-ip=5.189.157.229; envelope-from=a2f17bd40b3d302f6c1ddf0da75d2343966e0a3f@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 1a6ed33cc5 introduced option multidevs=remap|forbid|warn and made "warn" the default option. As it turned out though, e.g. by several reports in conjunction with following 9p client issue: https://github.com/torvalds/linux/commit/850925a8133c73c4a2453c360b2c3beb3bab67c9 Many people are just ignoring this warning, or even do not notice the warning at all. Therefore make multidevs=remap the new default option to prevent people to run into such kind of severe misbehaviours in the first place. From performance PoV the runtime overhead of multidevs=remap is neglectable with few or even just only one device being shared with the same 9p export, expected to be constant Theta(1). The inode numbers emitted to guest also just loose one bit (since 6b6aa8285d) for the 1st device being shared. Signed-off-by: Christian Schoenebeck Message-Id: <09cc84e5561f66b6a8cf49b3532c6c78a6acc806.1734876877.git.qemu_oss@crudebyte.com> --- hw/9pfs/9p-local.c | 3 +++ qemu-options.hx | 49 +++++++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 1b1f3b9ec8..928523afcc 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1538,6 +1538,9 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp) "[remap|forbid|warn]\n"); return -1; } + } else { + fse->export_flags &= ~V9FS_FORBID_MULTIDEVS; + fse->export_flags |= V9FS_REMAP_INODES; } if (!path) { diff --git a/qemu-options.hx b/qemu-options.hx index ec0090dfe2..1b26ad53bd 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1951,32 +1951,37 @@ SRST Specifies the tag name to be used by the guest to mount this export point. - ``multidevs=multidevs`` - Specifies how to deal with multiple devices being shared with a - 9p export. Supported behaviours are either "remap", "forbid" or - "warn". The latter is the default behaviour on which virtfs 9p - expects only one device to be shared with the same export, and - if more than one device is shared and accessed via the same 9p - export then only a warning message is logged (once) by qemu on - host side. In order to avoid file ID collisions on guest you - should either create a separate virtfs export for each device to - be shared with guests (recommended way) or you might use "remap" - instead which allows you to share multiple devices with only one - export instead, which is achieved by remapping the original - inode numbers from host to guest in a way that would prevent - such collisions. Remapping inodes in such use cases is required + ``multidevs=remap|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. + Supported behaviours are either "remap" (default), "forbid" or + "warn". + + ``remap`` : assumes the possibility that more than one device is + shared with the same 9p export. Therefore inode numbers from host + are remapped for guest in a way that would prevent file ID + collisions on guest. Remapping inodes in such cases is required because the original device IDs from host are never passed and exposed on guest. Instead all files of an export shared with - virtfs always share the same device id on guest. So two files + virtfs always share the same device ID on guest. So two files with identical inode numbers but from actually different devices on host would otherwise cause a file ID collision and hence - potential misbehaviours on guest. "forbid" on the other hand - assumes like "warn" that only one device is shared by the same - export, however it will not only log a warning message but also - deny access to additional devices on guest. Note though that - "forbid" does currently not block all possible file access - operations (e.g. readdir() would still return entries from other - devices). + potential severe misbehaviours on guest. + + ``warn`` : virtfs 9p expects only one device to be shared with + the same export. If however more than one device is shared and + accessed via the same 9p export then only a warning message is + logged (once) by qemu on host side. No further action is performed + in this case that would prevent file ID collisions on guest. This + could thus lead to severe misbehaviours in this case like wrong + files being accessed and data corruption on the exported tree. + + ``forbid`` : assumes like "warn" that only one device is shared + by the same 9p export, however it will not only log a warning + message but also deny access to additional devices on guest. Note + though that "forbid" does currently not block all possible file + access operations (e.g. readdir() would still return entries from + other devices). ERST DEF("iscsi", HAS_ARG, QEMU_OPTION_iscsi, From patchwork Thu Feb 6 16:41:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13963332 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A588EC02199 for ; Thu, 6 Feb 2025 16:49:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg53o-0008Ls-Rt; Thu, 06 Feb 2025 11:49:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <9a0dd4b3e4e0b06ec35c5ac370f54a36ea1846ed@kylie.crudebyte.com>) id 1tg53n-0008LL-OT for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:49:03 -0500 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 <9a0dd4b3e4e0b06ec35c5ac370f54a36ea1846ed@kylie.crudebyte.com>) id 1tg53m-0006Eu-1e for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:49:03 -0500 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=647mmsLP3uA3INY74GivlMfueppYt8qBzVKkJaljaRo=; b=YBVBY Qn5evLclw23qHNqiPOzbJAIWkNsu24/fvsbFtxkyKsMJW91cdiPz23fQWKhmZre8x7u/XSA4wEkNe Mo7W8TwspLA9tOFGYAwx4DljX+7Rfhmx0GAbTf00q59N8UzvwghGgTo8SDHoxI0qwn3GDh2npQ5re JYJINGwkEEJr/6PXN3wgBZJ+ZMDwS5BnssSGimHN2nvuCGoVwch71bU+zlohWjL8YRqe05sJyxBWM 6gdh5aVYP07XmO5Di2DPenIs1KHj+ETioyCqAhhrTHA8qOzwNf08uXiS634cFIqPFitkVMx4bPnpA atwcCTMK+Wuy0fcaGawtT+SnNpswkBsL17VA78GmEwosB0+cZ6HGEO5SqTPsufjRCTogMnGc9uHSj k4ySw7qehE6VTracbVg+SJfm6iCR8dAkbmDAe4+1jU6EN1iajs/+uQbqmbkH+MO6MrJxICtD1feCo RmsAN0Ct8b0o1DWjlL/hHUwRb5jOGVN6G+u8gTkk97uOL9/wDacEDSCfj+5Hrs6AbBAsJPG2NWxUV vsG/qMAyozGpOi2XyWu77cGkfMr3Pi8i3uch3EJW8XHTy8wl2VKB14pkARING2TyN+urKgBhlYJ70 Q4HkRhYzRGZDXNNu2eVdI5XGBeEKcdy/p0Y62LQai51+EeBTz23OG+cQLHT9RM=; Message-Id: <9a0dd4b3e4e0b06ec35c5ac370f54a36ea1846ed.1738860115.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 06 Feb 2025 17:41:56 +0100 Subject: [PULL 3/7] 9pfs: improve v9fs_open() tracing To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Stefan Hajnoczi Received-SPF: pass client-ip=5.189.157.229; envelope-from=9a0dd4b3e4e0b06ec35c5ac370f54a36ea1846ed@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Improve tracing of 9p 'Topen' request type by showing open() flags as human-readable text. E.g. trace output: v9fs_open tag 0 id 12 fid 2 mode 100352 would become: v9fs_open tag=0 id=12 fid=2 mode=100352(RDONLY|NONBLOCK|DIRECTORY| TMPFILE|NDELAY) Therefor add a new utility function qemu_open_flags_tostr() that converts numeric open() flags from host's native O_* flag constants to a string presentation. 9p2000.L and 9p2000.u protocol variants use different numeric 'mode' constants for 'Topen' requests. Instead of writing string conversion code for both protocol variants, use the already existing conversion functions that convert the mode flags from respective protocol constants to host's native open() numeric flag constants and pass that result to the new string conversion function qemu_open_flags_tostr(). Signed-off-by: Christian Schoenebeck Message-Id: --- hw/9pfs/9p-util-generic.c | 50 +++++++++++++++++++++++++++++++++++++++ hw/9pfs/9p-util.h | 6 +++++ hw/9pfs/9p.c | 9 ++++++- hw/9pfs/meson.build | 1 + hw/9pfs/trace-events | 2 +- 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 hw/9pfs/9p-util-generic.c diff --git a/hw/9pfs/9p-util-generic.c b/hw/9pfs/9p-util-generic.c new file mode 100644 index 0000000000..4c1e9c887d --- /dev/null +++ b/hw/9pfs/9p-util-generic.c @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "9p-util.h" +#include + +char *qemu_open_flags_tostr(int flags) +{ + int acc = flags & O_ACCMODE; + return g_strconcat( + (acc == O_WRONLY) ? "WRONLY" : (acc == O_RDONLY) ? "RDONLY" : "RDWR", + (flags & O_CREAT) ? "|CREAT" : "", + (flags & O_EXCL) ? "|EXCL" : "", + (flags & O_NOCTTY) ? "|NOCTTY" : "", + (flags & O_TRUNC) ? "|TRUNC" : "", + (flags & O_APPEND) ? "|APPEND" : "", + (flags & O_NONBLOCK) ? "|NONBLOCK" : "", + (flags & O_DSYNC) ? "|DSYNC" : "", + #ifdef O_DIRECT + (flags & O_DIRECT) ? "|DIRECT" : "", + #endif + (flags & O_LARGEFILE) ? "|LARGEFILE" : "", + (flags & O_DIRECTORY) ? "|DIRECTORY" : "", + (flags & O_NOFOLLOW) ? "|NOFOLLOW" : "", + #ifdef O_NOATIME + (flags & O_NOATIME) ? "|NOATIME" : "", + #endif + #ifdef O_CLOEXEC + (flags & O_CLOEXEC) ? "|CLOEXEC" : "", + #endif + #ifdef __O_SYNC + (flags & __O_SYNC) ? "|SYNC" : "", + #else + ((flags & O_SYNC) == O_SYNC) ? "|SYNC" : "", + #endif + #ifdef O_PATH + (flags & O_PATH) ? "|PATH" : "", + #endif + #ifdef __O_TMPFILE + (flags & __O_TMPFILE) ? "|TMPFILE" : "", + #elif defined(O_TMPFILE) + ((flags & O_TMPFILE) == O_TMPFILE) ? "|TMPFILE" : "", + #endif + /* O_NDELAY is usually just an alias of O_NONBLOCK */ + #if defined(O_NDELAY) && O_NDELAY != O_NONBLOCK + (flags & O_NDELAY) ? "|NDELAY" : "", + #endif + NULL /* always last (required NULL termination) */ + ); +} diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 95ee4da9bd..7bc4ec8e85 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -267,4 +267,10 @@ int pthread_fchdir_np(int fd) __attribute__((weak_import)); #endif int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev); +/* + * Returns a newly allocated string presentation of open() flags, intended + * for debugging (tracing) purposes only. + */ +char *qemu_open_flags_tostr(int flags); + #endif diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 6f24c1abb3..7cad2bce62 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -2008,6 +2008,7 @@ static void coroutine_fn v9fs_open(void *opaque) V9fsFidState *fidp; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; + g_autofree char *trace_oflags = NULL; if (s->proto_version == V9FS_PROTO_2000L) { err = pdu_unmarshal(pdu, offset, "dd", &fid, &mode); @@ -2019,7 +2020,13 @@ static void coroutine_fn v9fs_open(void *opaque) if (err < 0) { goto out_nofid; } - trace_v9fs_open(pdu->tag, pdu->id, fid, mode); + if (trace_event_get_state_backends(TRACE_V9FS_OPEN)) { + trace_oflags = qemu_open_flags_tostr( + (s->proto_version == V9FS_PROTO_2000L) ? + dotl_to_open_flags(mode) : omode_to_uflags(mode) + ); + trace_v9fs_open(pdu->tag, pdu->id, fid, mode, trace_oflags); + } fidp = get_fid(pdu, fid); if (fidp == NULL) { diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build index eceffdb81e..d35d4f44ff 100644 --- a/hw/9pfs/meson.build +++ b/hw/9pfs/meson.build @@ -3,6 +3,7 @@ fs_ss.add(files( '9p-local.c', '9p-posix-acl.c', '9p-synth.c', + '9p-util-generic.c', '9p-xattr-user.c', '9p-xattr.c', '9p.c', diff --git a/hw/9pfs/trace-events b/hw/9pfs/trace-events index ed9f4e7209..0e0fc37261 100644 --- a/hw/9pfs/trace-events +++ b/hw/9pfs/trace-events @@ -13,7 +13,7 @@ v9fs_getattr(uint16_t tag, uint8_t id, int32_t fid, uint64_t request_mask) "tag v9fs_getattr_return(uint16_t tag, uint8_t id, uint64_t result_mask, uint32_t mode, uint32_t uid, uint32_t gid) "tag %d id %d getattr={result_mask %"PRId64" mode %u uid %u gid %u}" v9fs_walk(uint16_t tag, uint8_t id, int32_t fid, int32_t newfid, uint16_t nwnames, const char* wnames) "tag=%d id=%d fid=%d newfid=%d nwnames=%d wnames={%s}" v9fs_walk_return(uint16_t tag, uint8_t id, uint16_t nwnames, void* qids) "tag %d id %d nwnames %d qids %p" -v9fs_open(uint16_t tag, uint8_t id, int32_t fid, int32_t mode) "tag %d id %d fid %d mode %d" +v9fs_open(uint16_t tag, uint8_t id, int32_t fid, int32_t mode, const char* oflags) "tag=%d id=%d fid=%d mode=%d(%s)" v9fs_open_return(uint16_t tag, uint8_t id, uint8_t type, uint32_t version, uint64_t path, int iounit) "tag %u id %u qid={type %u version %u path %"PRIu64"} iounit %d" v9fs_lcreate(uint16_t tag, uint8_t id, int32_t dfid, int32_t flags, int32_t mode, uint32_t gid) "tag %d id %d dfid %d flags %d mode %d gid %u" v9fs_lcreate_return(uint16_t tag, uint8_t id, uint8_t type, uint32_t version, uint64_t path, int32_t iounit) "tag %u id %u qid={type %u version %u path %"PRIu64"} iounit %d" From patchwork Thu Feb 6 16:41:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13963335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5FC35C02194 for ; Thu, 6 Feb 2025 16:50:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg54M-0008Rk-UN; Thu, 06 Feb 2025 11:49:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3d68de855175ae590479f15b37e8db300d43e860@kylie.crudebyte.com>) id 1tg53t-0008MU-Cg for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:49:09 -0500 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 <3d68de855175ae590479f15b37e8db300d43e860@kylie.crudebyte.com>) id 1tg53r-0006F9-Vx for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:49:09 -0500 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=Ca3s76Xbf8+ekttt2UWEE6onhWTBpocpOOjWu6ipy1A=; b=VfDis 0lb4ATJYRDgueDhE0f6CYwW2MKN+o538mpeawsV/D7Qefqt6SXs+bu3mP/l5EVAndmlRBWoWa4Ssg 7hncKAomBh71q5vFxI9KJ/jLkK6qTqtDupnFv3EwMHtdZLzXZID2eicOlCT+3zo6izdwG7IiSSY6K bmCcoX/dNv7F7Dh3cZtNepJRxrtgY79kKmhFh7a0003Z9mNh2x9xr6uenTxDQix6qLsd7EVUFS5GP pWyVdStIpSlMRbETvFBX5uIXLEhTGc3JztTtJyX5NvDwabZNOifdiA9qF5fmXQYiePJtbZdbrAxzY t2uzHe0aOJ50r+3zMhNqN+L4R7wEvGeTF3+hVTH8ZyKnmA3VKL0sh1FTLSBq/44xyVQrsuMdF/2O7 w1EaLhmHXUTVgAJtAjYvttVDXRM2+07bipvScixqzT3fIdkvjFWe3mGTL2PFWAAuXdlCikIiNB94H Qqk8GfIqYubwOb0PNetS3b4IKt4Fgp/UMaID8XmlEQpjx/jkCkuwfBZW5DW5J+ZzZlc96x7obEh0F YqXC2a/fc+pgX8MXDHEtf0/M6T3iIC/3hISsNpHy00lZY/MgRV3J03QJ0S4sEaagejKHF8ACquPx3 fKk1AA8HaZL1ZL+LdIBn40Teo69Br4+Pa4qzE90I0eIIBRH9iFCzJjNTGp2cAE=; Message-Id: <3d68de855175ae590479f15b37e8db300d43e860.1738860115.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 06 Feb 2025 17:41:56 +0100 Subject: [PULL 4/7] tests/9p: rename test use_after_unlink -> use_file_after_unlink To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Stefan Hajnoczi Received-SPF: pass client-ip=5.189.157.229; envelope-from=3d68de855175ae590479f15b37e8db300d43e860@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org To pave the way for adding new test use_dir_after_unlink with subsequent patch, i.e. making it clear that the existing test is just about unlinked files, not unlinked directories. Signed-off-by: Christian Schoenebeck Message-Id: <9d2ca46a58b812ad17ca7bb8a84f12252d3e3832.1736427878.git.qemu_oss@crudebyte.com> --- tests/qtest/virtio-9p-test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index ab3a12c816..07459c5289 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -693,8 +693,8 @@ static void fs_unlinkat_hardlink(void *obj, void *data, g_assert(stat(real_file, &st_real) == 0); } -static void fs_use_after_unlink(void *obj, void *data, - QGuestAllocator *t_alloc) +static void fs_use_file_after_unlink(void *obj, void *data, + QGuestAllocator *t_alloc) { QVirtio9P *v9p = obj; v9fs_set_allocator(t_alloc); @@ -802,8 +802,8 @@ static void register_virtio_9p_test(void) qos_add_test("local/hardlink_file", "virtio-9p", fs_hardlink_file, &opts); qos_add_test("local/unlinkat_hardlink", "virtio-9p", fs_unlinkat_hardlink, &opts); - qos_add_test("local/use_after_unlink", "virtio-9p", fs_use_after_unlink, - &opts); + qos_add_test("local/use_file_after_unlink", "virtio-9p", + fs_use_file_after_unlink, &opts); } libqos_init(register_virtio_9p_test); From patchwork Thu Feb 6 16:41:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13963333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E190EC02194 for ; Thu, 6 Feb 2025 16:49:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg54S-0000Bz-0t; Thu, 06 Feb 2025 11:49:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <37c21fb972da373be101d20574309be0584dc2a3@kylie.crudebyte.com>) id 1tg54B-0008Rg-5V for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:49:33 -0500 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 <37c21fb972da373be101d20574309be0584dc2a3@kylie.crudebyte.com>) id 1tg53z-0006Fs-68 for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:49:17 -0500 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=zDzfIhpX7RUp42esNkfxQxrLx+/ehHksTquEVG3MY18=; b=NFCIK ZDNgugjfj3KeSkHdUMSo/4Cs23wAYtc6d2iDMOGWeQSL1HuLT4R8eEGLjO27soVC36fvY07ijBuzT rVkXffAMp3FBwovh7xmNQ0g8K9IWIteMghwUPjpUex0HpNFf9wQM5qzF1sSBfoCd3eyRUT1Iyk7wI eKzbrvrfW/BxKI0n7WRCpY3fcz+SMroIRHN66EeIhQqBvndv+lesgsqAUHvhdahuKe6l64eGnXjSz yvb6F5OEshcoJ9BlO5shm6k/YmDGF5u5Da7/2tV+wNYdilqq4g8n9qm7Q5ooLGR9pZ0PWPXi7GOGq mb7MLgMPMzDSPXoi+tvuuy9LDwL+snbPJz9nbtH2pCYVl/Uor+P8+sJY0L+irR2LiKn9SV+SZ3UcT 287lEEalpp5apD0qUiiIOBCvkhCyfAXTXMhEsr1c8kiT6G2k1nG5Q1wMpGdmYLNqJRLS2qTnTiMZK 11vCihRBkQucmcSxqckoRS0QG2jEgtZUqqE5xY3e1Ov76dyK0CNjimPYv1YeEo+3n2u/DT/CTCtVs o3Lfrk6dcKb5MVr10TRQVDEbBZUVNg0ltTm/jIBYJeuhlYTrp5V6nCFEsTyB9U0h+qjGZf+/enmA6 E46AMMuBiDF1Pp7Xq342d/9s/4YHCPqnzux++xD8aIWybFWtpWjgmk26CgaIWs=; Message-Id: <37c21fb972da373be101d20574309be0584dc2a3.1738860115.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 06 Feb 2025 17:41:56 +0100 Subject: [PULL 5/7] tests/9p: add use_dir_after_unlink test To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Stefan Hajnoczi Received-SPF: pass client-ip=5.189.157.229; envelope-from=37c21fb972da373be101d20574309be0584dc2a3@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org After removing a directory from the filesystem, it should still be possible to operate on the directory if the directory has been opened before. As a first step this new test will verify whether Tgetattr request works on the unlinked directory. Signed-off-by: Christian Schoenebeck Message-Id: <0a9b3419356731e34b1be4a8577d6b416379d085.1736427878.git.qemu_oss@crudebyte.com> --- tests/qtest/virtio-9p-test.c | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 07459c5289..35c42cd0d7 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -737,6 +737,43 @@ static void fs_use_file_after_unlink(void *obj, void *data, g_assert_cmpint(count, ==, write_count); } +static void fs_use_dir_after_unlink(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p = obj; + v9fs_set_allocator(t_alloc); + g_autofree char *real_dir = virtio_9p_test_path("10/doa_dir"); + struct stat st_dir; + struct v9fs_attr attr; + uint32_t fid_dir; + + tattach({ .client = v9p }); + + /* create a dir "10/doa_dir" and make sure it exists */ + tmkdir({ .client = v9p, .atPath = "/", .name = "10" }); + tmkdir({ .client = v9p, .atPath = "10", .name = "doa_dir" }); + g_assert(stat(real_dir, &st_dir) == 0); + g_assert((st_dir.st_mode & S_IFMT) == S_IFDIR); + + /* request a FID for that directory that we can work with next */ + fid_dir = twalk({ + .client = v9p, .fid = 0, .path = "10/doa_dir" + }).newfid; + g_assert(fid_dir != 0); + + /* now first open the dir before ... */ + tlopen({ .client = v9p, .fid = fid_dir, .flags = O_RDONLY }); + /* ... removing the dir from file system */ + tunlinkat({ .client = v9p, .atPath = "10", .name = "doa_dir", + .flags = AT_REMOVEDIR }); + + /* dir is removed, but we still have it open, so this should succeed */ + tgetattr({ + .client = v9p, .fid = fid_dir, .request_mask = P9_GETATTR_BASIC, + .rgetattr.attr = &attr + }); +} + static void cleanup_9p_local_driver(void *data) { /* remove previously created test dir when test is completed */ @@ -804,6 +841,8 @@ static void register_virtio_9p_test(void) &opts); qos_add_test("local/use_file_after_unlink", "virtio-9p", fs_use_file_after_unlink, &opts); + qos_add_test("local/use_dir_after_unlink", "virtio-9p", + fs_use_dir_after_unlink, &opts); } libqos_init(register_virtio_9p_test); From patchwork Thu Feb 6 16:41:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13963337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A28C5C02194 for ; Thu, 6 Feb 2025 16:50:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg54U-0000Kw-Oo; Thu, 06 Feb 2025 11:49:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <6eadd8767ab9422942c3c5e8d70c923e5ee3aa3f@kylie.crudebyte.com>) id 1tg54K-0008U4-KQ for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:49:38 -0500 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 <6eadd8767ab9422942c3c5e8d70c923e5ee3aa3f@kylie.crudebyte.com>) id 1tg54G-0006GI-Lg for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:49:33 -0500 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=PqKdHe7ois7thoZS8jd2yyOq9qy3lzC6R+YWRsAjpF4=; b=JV8Sg 4MYSZpWS9j+wb7T8HQRcEuRWU8/DZhngvisgykswBgj/0xy4fM1FHV0HiSCifPEt5qcbgf7aChEph CrkFdBUR+6vovHEOZa+ZbyHddDtV/JKk0oW9DVz+CmkMREBWwfBvqrs5UFKEaYoemkgS9P1NYFFTk u8y1H0gf6thsQ4eSmw3GscWeh9LILnHBfjUjynuPnIgqGK262qptOE9js1ddbHlg3jfHDCRzyHWga qcYjfcEqmQFt+di61KLtJ5kfRM6vBLcmy1aUGi6eZ5OtE1qXDTO3J8B6FY4acne1t7y1zYuUyygaC nbbKs0E2B/mNFZl1OV9GvzMqeCqjHyvEoK5gDKYmPcZpp/V16d+5VwFo/bx31+sbAISSOvXXydTpM JE2gxeFYEcJkSYO6R5vVuDou9CSc80Lb80WC3glTPE7puVf2mBfX1TIyJlCWYe1rME2Pnk1Ol8iBo y6c27ZFTxv+37JNKxJwZVf3Rq5upRA5YFQVeE5d+1tzAUSp0iQpDEFLcEBvKXOt5H/UGKlZG9cEx1 nzCIr2s0puPGGNGpTZDCQLhWyYQ7L224m4eiJk77NEqtrdYccYj2unfONf5Oomwod3YdjgFA/uHQy v9ZMQxDrENGwAmxxLYkJ7WoEA8NUznVgqJW373LWIYq+Oz6KsdhcX9UapCY06c=; Message-Id: <6eadd8767ab9422942c3c5e8d70c923e5ee3aa3f.1738860115.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 06 Feb 2025 17:41:56 +0100 Subject: [PULL 6/7] tests/9p: extend use_dir_after_unlink test with Treaddir To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Stefan Hajnoczi Received-SPF: pass client-ip=5.189.157.229; envelope-from=6eadd8767ab9422942c3c5e8d70c923e5ee3aa3f@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sending a Treaddir request on an unlinked directory should also succeed if the directory was alread opened before unlink. We just check that no error occurs and that we get some kind of Treaddir result, but completely ignore the actual Treaddir result content. In fact, there should be no system as of to date that would allow a removed directory to have any content (files, links, devices, subdirectories) and POSIX specifies that a directory must be empty when trying to remove it from the file system. Signed-off-by: Christian Schoenebeck Message-Id: --- tests/qtest/virtio-9p-test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 35c42cd0d7..10243247ab 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -772,6 +772,9 @@ static void fs_use_dir_after_unlink(void *obj, void *data, .client = v9p, .fid = fid_dir, .request_mask = P9_GETATTR_BASIC, .rgetattr.attr = &attr }); + treaddir({ + .client = v9p, .fid = fid_dir, .offset = 0, .count = P9_MAX_SIZE - 11 + }); } static void cleanup_9p_local_driver(void *data) From patchwork Thu Feb 6 16:41:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13963336 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6BA7FC02194 for ; Thu, 6 Feb 2025 16:50:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg54W-0000QO-3k; Thu, 06 Feb 2025 11:49:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg54G-0008Sk-TJ for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:49:38 -0500 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 1tg54E-0006H1-H0 for qemu-devel@nongnu.org; Thu, 06 Feb 2025 11:49:31 -0500 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=JkRdxjgnBKt71547XwUn1O1/I1Rb6x+CIeZvvDqy18c=; b=SkEi/ cQ2KjJs+Lbpu/slDZ74yqOOy8NOiuYpIfKBTnv8hkSzPTCWI9rZsTim1G/N7HEvh8Z8wyJQi4utgB zUo/C1juCQvjw3ZhWzz1smT+JWx7eHEX0F5yDh/8pnKZIRZV1kafoCINVxfEvj/S8ZH4n9OhiMf3j gnP42Ubu9oT7aLAKMIRS07sCWQ4QUYi3LdBHdMuIxXIEFpWjTv+Z4nvF8HzBo7/oipRapmq0D5lxn qiI1s4Q/bguDk+Vo08lbhD44axuwrZyg63mu5RO5489/uJS+fAyFhgHyVUntZoh1iqfYai2W0Y0nf Am8qC1mZYU8MoAKZMpZ44NWviDMfEySNM8RbGFkyW8yZ9bbhl1Dajz02LcbQwLe/WKc3jcsFD6mi3 0Ww5hsiaM6DHlrUElvVhRWTYYSGfXZvFxrj68hEpoyiYUrJK5Jp4INa4+g4OgK01QX3GrX8cK0ysb JYRk6qZCo7qq93VqxH/pAC5Lsps/wAONhQ4ajCm7F1n1Lhb4MJZDNVyYslAhuudjssZYXVSuxm89c ESFvaBGdFshBfp85i8afdEmp2U3x1KAtY7xflq4uvxF823Ze+hS11Rv3GVZTEnWtCkKVZevRKySXz 4rPxJPwZe9aSfNlMTwjFbDMjNXrCqrAMxGxtvQ6rDLerSE02V5m7h5l35Z2py8=; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 06 Feb 2025 17:41:56 +0100 Subject: [PULL 7/7] MAINTAINERS: Mark me as reviewer only for 9pfs To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz , Stefan Hajnoczi Received-SPF: pass client-ip=5.189.157.229; envelope-from=bfa7bf02782dbd996201c90f850ca11730041af1@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Greg Kurz I still review 9pfs changes from time to time but I'm definitely not able to do actual maintainer work. Drop my tree on the way as I'll obviously not use it anymore, and it has been left untouched since May 2020. Signed-off-by: Greg Kurz Reviewed-by: Christian Schoenebeck Message-Id: <20250115100849.259612-1-groug@kaod.org> Signed-off-by: Christian Schoenebeck --- MAINTAINERS | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 0cf37fce7b..c6859cbb0e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2254,8 +2254,8 @@ F: include/system/balloon.h F: tests/qtest/virtio-balloon-test.c virtio-9p -M: Greg Kurz M: Christian Schoenebeck +R: Greg Kurz S: Maintained W: https://wiki.qemu.org/Documentation/9p F: hw/9pfs/ @@ -2263,7 +2263,6 @@ X: hw/9pfs/xen-9p* F: fsdev/ F: tests/qtest/virtio-9p-test.c F: tests/qtest/libqos/virtio-9p* -T: git https://gitlab.com/gkurz/qemu.git 9p-next T: git https://github.com/cschoenebeck/qemu.git 9p.next virtio-blk