Replace raw object_ref/unref calls with iothread_ref_and_get/unref_and_put_aio_context.
Signed-off-by: Zhang Chen <[email protected]> --- hw/block/dataplane/xen-block.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c index 48c2e315f3..9dfe06e1be 100644 --- a/hw/block/dataplane/xen-block.c +++ b/hw/block/dataplane/xen-block.c @@ -621,9 +621,15 @@ XenBlockDataPlane *xen_block_dataplane_create(XenDevice *xendev, QLIST_INIT(&dataplane->freelist); if (iothread) { + g_autofree char *path = object_get_canonical_path(OBJECT(xendev)); + const IOThreadHolder io_holder = { + .type = IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path = path, + }; + dataplane->iothread = iothread; - object_ref(OBJECT(dataplane->iothread)); - dataplane->ctx = iothread_get_aio_context(dataplane->iothread); + dataplane->ctx = iothread_ref_and_get_aio_context(dataplane->iothread, + &io_holder); } else { dataplane->ctx = qemu_get_aio_context(); } @@ -652,7 +658,14 @@ void xen_block_dataplane_destroy(XenBlockDataPlane *dataplane) qemu_bh_delete(dataplane->bh); if (dataplane->iothread) { - object_unref(OBJECT(dataplane->iothread)); + g_autofree char *path = object_get_canonical_path( + OBJECT(dataplane->xendev)); + const IOThreadHolder io_holder = { + .type = IO_THREAD_HOLDER_KIND_QOM_OBJECT, + .u.qom_object.qom_path = path, + }; + + iothread_unref_and_put_aio_context(dataplane->iothread, &io_holder); } g_free(dataplane); -- 2.54.0
