On Thu, Mar 05, 2026 at 10:24:52PM +0800, Zhang Chen wrote:
> Refactor virtio-blk and virtio-scsi to use the new iothread_get/put
> APIs for AioContext management. This ensures IOThread references
> are tracked via the device's canonical QOM path.
> 
> Summary of changes:
> - Lift 'path' scope to cover both vq_mapping and single iothread cases.
> - Replace raw object_ref/unref with iothread_get/put_aio_context.
> - Ensure consistent memory cleanup of the QOM path string.
> 
> Signed-off-by: Zhang Chen <[email protected]>
> ---
>  hw/block/virtio-blk.c           | 17 ++++++-----------
>  hw/scsi/virtio-scsi-dataplane.c | 18 +++++++-----------
>  2 files changed, 13 insertions(+), 22 deletions(-)
> 
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index b6f74df68f..94a70c6212 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -1429,6 +1429,7 @@ static bool virtio_blk_vq_aio_context_init(VirtIOBlock 
> *s, Error **errp)
>      VirtIOBlkConf *conf = &s->conf;
>      BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
>      VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
> +    char *path = object_get_canonical_path(OBJECT(vdev));
>  
>      if (conf->iothread && conf->iothread_vq_mapping_list) {
>          error_setg(errp,

There is a memory leak when this returns false. Please use g_autofree
when declaring temporary string variables instead of calling g_free()
manually.

Attachment: signature.asc
Description: PGP signature

Reply via email to