From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"John Snow" <jsnow@redhat.com>, "Fam Zheng" <fam@euphon.net>,
"Peter Xu" <peterx@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
qemu-block@nongnu.org, "Stefan Hajnoczi" <stefanha@redhat.com>,
"Kevin Wolf" <kwolf@redhat.com>,
"David Hildenbrand" <david@redhat.com>,
pkrempa@redhat.com, "Hanna Reitz" <hreitz@redhat.com>
Subject: [PATCH 08/12] virtio-blk: extract cleanup_iothread_vq_mapping() function
Date: Thu, 13 Feb 2025 13:00:39 -0500 [thread overview]
Message-ID: <20250213180043.713434-9-stefanha@redhat.com> (raw)
In-Reply-To: <20250213180043.713434-1-stefanha@redhat.com>
This is the cleanup function that must be called after
apply_iothread_vq_mapping() succeeds. virtio-scsi will need this
function too, so extract it.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/block/virtio-blk.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index a1829e3abd..9af8c51af0 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -1485,6 +1485,9 @@ validate_iothread_vq_mapping_list(IOThreadVirtQueueMappingList *list,
* Fill in the AioContext for each virtqueue in the @vq_aio_context array given
* the iothread-vq-mapping parameter in @iothread_vq_mapping_list.
*
+ * cleanup_iothread_vq_mapping() must be called to free IOThread object
+ * references after this function returns success.
+ *
* Returns: %true on success, %false on failure.
**/
static bool apply_iothread_vq_mapping(
@@ -1535,6 +1538,23 @@ static bool apply_iothread_vq_mapping(
return true;
}
+/**
+ * cleanup_iothread_vq_mapping:
+ * @list: The mapping of virtqueues to IOThreads.
+ *
+ * Release IOThread object references that were acquired by
+ * apply_iothread_vq_mapping().
+ */
+static void cleanup_iothread_vq_mapping(IOThreadVirtQueueMappingList *list)
+{
+ IOThreadVirtQueueMappingList *node;
+
+ for (node = list; node; node = node->next) {
+ IOThread *iothread = iothread_by_id(node->value->iothread);
+ object_unref(OBJECT(iothread));
+ }
+}
+
/* Context: BQL held */
static bool virtio_blk_vq_aio_context_init(VirtIOBlock *s, Error **errp)
{
@@ -1601,12 +1621,7 @@ static void virtio_blk_vq_aio_context_cleanup(VirtIOBlock *s)
assert(!s->ioeventfd_started);
if (conf->iothread_vq_mapping_list) {
- IOThreadVirtQueueMappingList *node;
-
- for (node = conf->iothread_vq_mapping_list; node; node = node->next) {
- IOThread *iothread = iothread_by_id(node->value->iothread);
- object_unref(OBJECT(iothread));
- }
+ cleanup_iothread_vq_mapping(conf->iothread_vq_mapping_list);
}
if (conf->iothread) {
--
2.48.1
next prev parent reply other threads:[~2025-02-13 18:07 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-13 18:00 [PATCH 00/12] virtio-scsi: add iothread-vq-mapping parameter Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 01/12] scsi-disk: drop unused SCSIDiskState->bh field Stefan Hajnoczi
2025-03-11 9:29 ` Philippe Mathieu-Daudé
2025-02-13 18:00 ` [PATCH 02/12] dma: use current AioContext for dma_blk_io() Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 03/12] scsi: track per-SCSIRequest AioContext Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 04/12] scsi: introduce requests_lock Stefan Hajnoczi
2025-03-10 13:37 ` Kevin Wolf
2025-03-11 9:11 ` Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 05/12] virtio-scsi: introduce event and ctrl virtqueue locks Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 06/12] virtio-scsi: protect events_dropped field Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 07/12] virtio-scsi: perform TMFs in appropriate AioContexts Stefan Hajnoczi
2025-02-13 18:00 ` Stefan Hajnoczi [this message]
2025-02-13 18:00 ` [PATCH 09/12] virtio-blk: tidy up iothread_vq_mapping functions Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 10/12] virtio: extract iothread-vq-mapping.h API Stefan Hajnoczi
2025-02-13 18:00 ` [PATCH 11/12] virtio-scsi: add iothread-vq-mapping parameter Stefan Hajnoczi
2025-03-10 14:33 ` Kevin Wolf
2025-03-10 14:37 ` Peter Krempa
2025-03-10 15:17 ` Kevin Wolf
2025-02-13 18:00 ` [PATCH 12/12] virtio-scsi: handle ctrl virtqueue in main loop Stefan Hajnoczi
2025-03-10 14:43 ` Kevin Wolf
2025-02-20 17:04 ` [PATCH 00/12] virtio-scsi: add iothread-vq-mapping parameter Peter Krempa
2025-03-10 14:43 ` Kevin Wolf
2025-03-11 9:22 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250213180043.713434-9-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=david@redhat.com \
--cc=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=pkrempa@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).