qapi/misc: Fix missed query-iothreads items
PATCH v3 1/3 qapi/misc: Fix missed query-iothreads items
The example is incomplete: it misses members @poll-max-ns, @poll-grow, @poll-shrink, @aio-max-batch. Messed up in commit 5fc00480ab1 (monitor: add poll-* properties into query-iothreads result) and commit 1793ad0247c (iothread: add aio-max-batch parameter).
--- qapi/misc.json | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
qapi/misc.json +10 -2
@@ -117,11 +117,19 @@ # <- { "return": [ # { # "id":"iothread0", -# "thread-id":3134 +# "thread-id":3134, +# "poll-max-ns":32768, +# "poll-grow":0, +# "poll-shrink":0, +# "aio-max-batch":0 # }, # { # "id":"iothread1", -# "thread-id":3135 +# "thread-id":3135, +# "poll-max-ns":32768, +# "poll-grow":0, +# "poll-shrink":0, +# "aio-max-batch":0 # } # ] # }
Signature · 1 line
2.49.0
PATCH v3 2/3 iothread: Introduce a new flag to show iothreads attached status
QEMU Need a flag to show current iothread attached status when hotplug multi iothreads. For example virtio-blk.
--- include/system/iothread.h | 1 + iothread.c | 5 +++++ 2 files changed, 6 insertions(+)
include/system/iothread.h +1 -0
@@ -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 */
iothread.c +5 -0
@@ -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; }
Signature · 1 line
2.49.0
PATCH v3 3/3 qapi: Add attached flag for iothread
In reply to Zhang ChenThe attached flag depends on struct IOThreadInfo's 'attached': 'bool'. It can show whether the iothread is attached to an actual device. Show in the qmp/hmp CMD with "attached": true/false.
--- iothread.c | 1 + monitor/hmp-cmds.c | 2 ++ qapi/misc.json | 12 ++++++++++++ 3 files changed, 15 insertions(+)
iothread.c +1 -0
@@ -358,6 +358,7 @@ static int query_one_iothread(Object *object, void *opaque) info =g_new0 (IOThreadInfo,1 ); info->id =iothread_get_id (iothread); info->thread_id = iothread->thread_id; + info->attached = iothread->attached; info->poll_max_ns = iothread->poll_max_ns; info->poll_grow = iothread->poll_grow; info->poll_shrink = iothread->poll_shrink;
monitor/hmp-cmds.c +2 -0
@@ -202,6 +202,8 @@ void hmp_info_iothreads(Monitor *mon, const QDict *qdict) value = info->value;monitor_printf (mon,"%s:\n" , value->id);monitor_printf (mon," thread_id=%" PRId64"\n" , value->thread_id); +monitor_printf (mon," attached=%s" "\n" , + value->attached ?"true" :"false" );monitor_printf (mon," poll-max-ns=%" PRId64"\n" , value->poll_max_ns);monitor_printf (mon," poll-grow=%" PRId64"\n" , value->poll_grow);monitor_printf (mon," poll-shrink=%" PRId64"\n" , value->poll_shrink);
qapi/misc.json +12 -0
@@ -76,6 +76,15 @@ # # @thread-id: ID of the underlying host thread # +# @attached: The attached parameter is a flag indicating whether +# the IOThread is currently associated with an active device +# (e.g., virtio-blk).In hotplug scenarios, users can pre-allocate +# multiple iothread objects to serve as a persistent thread pool. +# When a device is hot-unplugged, the corresponding IOThread is +# released but remains available, allowing subsequent hot-plugged +# devices to attach to and reuse the existing thread. +# (since 12.0) +# # @poll-max-ns: maximum polling time in ns, 0 means polling is # disabled (since 2.9) #
@@ -93,6 +102,7 @@ { 'struct': 'IOThreadInfo', 'data': {'id': 'str', 'thread-id': 'int', + 'attached': 'bool', 'poll-max-ns': 'int', 'poll-grow': 'int', 'poll-shrink': 'int',
@@ -118,6 +128,7 @@ # { # "id":"iothread0", # "thread-id":3134, +# "attached":false, # "poll-max-ns":32768, # "poll-grow":0, # "poll-shrink":0,
@@ -126,6 +137,7 @@ # { # "id":"iothread1", # "thread-id":3135, +# "attached":true, # "poll-max-ns":32768, # "poll-grow":0, # "poll-shrink":0,
Signature · 1 line
2.49.0
Quoted 6 lines · Zhang Chen
The example is incomplete: it misses members @poll-max-ns, @poll-grow, @poll-shrink, @aio-max-batch. Messed up in commit
5fc00480ab1(monitor: add poll-* properties into query-iothreads result) and commit1793ad0247c(iothread: add aio-max-batch parameter).
Quoted 6 lines
Signed-off-by Zhang Chen <[email protected]>--- qapi/misc.json | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
Quoted 31 lines
qapi/misc.json +10
-3@@ -117,11 +117,19 @@ # <- { "return": [ # { # "id":"iothread0", -# "thread-id":3134 +# "thread-id":3134, +# "poll-max-ns":32768, +# "poll-grow":0, +# "poll-shrink":0, +# "aio-max-batch":0 # }, # { # "id":"iothread1", -# "thread-id":3135 +# "thread-id":3135, +# "poll-max-ns":32768, +# "poll-grow":0, +# "poll-shrink":0, +# "aio-max-batch":0 # } # ] # } --2.49.0