QEMU Need a flag to show current iothread attached status when hotplug multi iothreads. For example virtio-blk.
Signed-off-by: Zhang Chen <[email protected]> --- include/system/iothread.h | 1 + iothread.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/system/iothread.h b/include/system/iothread.h index e26d13c6c7..3d00474523 100644 --- a/include/system/iothread.h +++ b/include/system/iothread.h @@ -32,6 +32,7 @@ struct IOThread { QemuSemaphore init_done_sem; /* is thread init done? */ bool stopping; /* has iothread_stop() been called? */ bool running; /* should iothread_run() continue? */ + bool attached; /* Whether or not attached to device */ int thread_id; /* AioContext poll parameters */ diff --git a/iothread.c b/iothread.c index caf68e0764..38e38fb44d 100644 --- a/iothread.c +++ b/iothread.c @@ -94,6 +94,7 @@ void iothread_stop(IOThread *iothread) return; } iothread->stopping = true; + iothread->attached = false; aio_bh_schedule_oneshot(iothread->ctx, iothread_stop_bh, iothread); qemu_thread_join(&iothread->thread); } @@ -199,6 +200,9 @@ static void iothread_init(EventLoopBase *base, Error **errp) */ iothread_init_gcontext(iothread, thread_name); + /* Clear iothread attached flag for init gcontext */ + iothread->attached = false; + iothread_set_aio_context_params(base, &local_error); if (local_error) { error_propagate(errp, local_error); @@ -336,6 +340,7 @@ char *iothread_get_id(IOThread *iothread) AioContext *iothread_get_aio_context(IOThread *iothread) { + iothread->attached = true; return iothread->ctx; } -- 2.49.0
