[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 08/14] virtio-blk: extract cleanup_iothread_vq_mapping() funct
From: |
Stefan Hajnoczi |
Subject: |
[PATCH v3 08/14] virtio-blk: extract cleanup_iothread_vq_mapping() function |
Date: |
Tue, 11 Mar 2025 21:07:35 +0800 |
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>
Reviewed-by: Kevin Wolf <kwolf@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 5135b4d8f1..21b1b768ed 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -1495,6 +1495,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(
@@ -1545,6 +1548,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)
{
@@ -1611,12 +1631,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
- [PATCH v3 02/14] dma: use current AioContext for dma_blk_io(), (continued)
- [PATCH v3 02/14] dma: use current AioContext for dma_blk_io(), Stefan Hajnoczi, 2025/03/11
- [PATCH v3 03/14] scsi: track per-SCSIRequest AioContext, Stefan Hajnoczi, 2025/03/11
- [PATCH v3 04/14] scsi: introduce requests_lock, Stefan Hajnoczi, 2025/03/11
- [PATCH v3 05/14] virtio-scsi: introduce event and ctrl virtqueue locks, Stefan Hajnoczi, 2025/03/11
- [PATCH v3 06/14] virtio-scsi: protect events_dropped field, Stefan Hajnoczi, 2025/03/11
- [PATCH v3 07/14] virtio-scsi: perform TMFs in appropriate AioContexts, Stefan Hajnoczi, 2025/03/11
- [PATCH v3 10/14] virtio: extract iothread-vq-mapping.h API, Stefan Hajnoczi, 2025/03/11
- [PATCH v3 09/14] virtio-blk: tidy up iothread_vq_mapping functions, Stefan Hajnoczi, 2025/03/11
- [PATCH v3 12/14] fixup! virtio-scsi: add iothread-vq-mapping parameter, Stefan Hajnoczi, 2025/03/11
- [PATCH v3 11/14] virtio-scsi: add iothread-vq-mapping parameter, Stefan Hajnoczi, 2025/03/11
- [PATCH v3 08/14] virtio-blk: extract cleanup_iothread_vq_mapping() function,
Stefan Hajnoczi <=
- [PATCH v3 13/14] virtio-scsi: handle ctrl virtqueue in main loop, Stefan Hajnoczi, 2025/03/11
- [PATCH v3 14/14] virtio-scsi: only expose cmd vqs via iothread-vq-mapping, Stefan Hajnoczi, 2025/03/11