From: Zhang Chen <zhangckid@gmail.com>
To: qemu-devel <qemu-devel@nongnu.org>,
"Dr . David Alan Gilbert" <dave@treblig.org>,
Eric Blake <eblake@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Kevin Wolf <kwolf@redhat.com>, Jason Wang <jasowang@redhat.com>,
Fam Zheng <fam@euphon.net>
Cc: Zhang Chen <zhangckid@gmail.com>
Subject: [PATCH V9 15/17] qapi: examine IOThread attachment status via query-iothreads
Date: Wed, 24 Jun 2026 15:08:49 +0800 [thread overview]
Message-ID: <20260624070851.13342-16-zhangckid@gmail.com> (raw)
In-Reply-To: <20260624070851.13342-1-zhangckid@gmail.com>
Extend the 'IOThreadInfo' structure to include attachment metrics.
This allows users to monitor the associated devices by identify them
by their QOM paths, block nodes or monitors.
New fields added to IOThreadInfo:
@holders: IOThreadHolder of the devices currently associated with
this iothread. Users can pre-allocate multiple iothread objects
to serve as a persistent thread pool. When a device is hot-unplugged,
it is detached from its iothread, but the iothread remains available,
allowing future hot-plugged devices to attach to it. (Since 11.1)
These fields are also exposed via the Human Monitor Interface (HMP)
command 'info iothreads' to assist with manual debugging and
performance tuning.
Signed-off-by: Zhang Chen <zhangckid@gmail.com>
---
iothread.c | 22 ++++++++++++++++++++++
monitor/hmp-cmds.c | 26 ++++++++++++++++++++++++++
qapi/misc.json | 9 +++++++++
3 files changed, 57 insertions(+)
diff --git a/iothread.c b/iothread.c
index a85e960e45..5949785b32 100644
--- a/iothread.c
+++ b/iothread.c
@@ -24,6 +24,8 @@
#include "qemu/error-report.h"
#include "qemu/rcu.h"
#include "qemu/main-loop.h"
+#include "qapi/clone-visitor.h"
+#include "qapi/qapi-visit-misc.h"
/*
* iothread_ref:
@@ -119,6 +121,25 @@ static void iothread_unref(IOThread *iothread, const IOThreadHolder *holder)
object_unref(OBJECT(iothread));
}
+static IOThreadHolderList *iothread_get_holders_list(IOThread *iothread)
+{
+ IOThreadHolderList *head = NULL;
+ IOThreadHolderList **prev = &head;
+ GList *l;
+
+ for (l = iothread->holders; l; l = l->next) {
+ IOThreadHolder *src = l->data;
+ IOThreadHolderList *entry = g_new0(IOThreadHolderList, 1);
+
+ entry->value = QAPI_CLONE(IOThreadHolder, src);
+
+ *prev = entry;
+ prev = &entry->next;
+ }
+
+ return head;
+}
+
static void *iothread_run(void *opaque)
{
IOThread *iothread = opaque;
@@ -488,6 +509,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->holders = iothread_get_holders_list(iothread);
info->poll_max_ns = iothread->poll_max_ns;
info->poll_grow = iothread->poll_grow;
info->poll_shrink = iothread->poll_shrink;
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 443b8c785d..1b5883147b 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -237,11 +237,37 @@ void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
IOThreadInfoList *info_list = qmp_query_iothreads(NULL);
IOThreadInfoList *info;
IOThreadInfo *value;
+ IOThreadHolderList *h;
for (info = info_list; info; info = info->next) {
value = info->value;
monitor_printf(mon, "%s:\n", value->id);
monitor_printf(mon, " thread_id=%" PRId64 "\n", value->thread_id);
+ monitor_printf(mon, " holders=");
+ if (value->holders) {
+ for (h = value->holders; h; h = h->next) {
+ IOThreadHolder *holder = h->value;
+
+ switch (holder->type) {
+ case IO_THREAD_HOLDER_KIND_BLOCK_NODE:
+ monitor_printf(mon, "[block-node: %s]",
+ holder->u.block_node.node_name);
+ break;
+ case IO_THREAD_HOLDER_KIND_QOM_OBJECT:
+ monitor_printf(mon, "[qom-path: %s]",
+ holder->u.qom_object.qom_path);
+ break;
+ case IO_THREAD_HOLDER_KIND_MONITOR_NAME:
+ monitor_printf(mon, "[monitor-name: %s]",
+ holder->u.monitor_name.monitor_name);
+ break;
+ default:
+ monitor_printf(mon, "[unknown]");
+ break;
+ }
+ }
+ monitor_printf(mon, "\n");
+ }
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);
diff --git a/qapi/misc.json b/qapi/misc.json
index d9f82f0922..6486c62ab5 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -137,6 +137,11 @@
#
# @thread-id: ID of the underlying host thread
#
+# @holders: the QOM objects, block nodes or monitors currently
+# associated with this iothread. When an associated component is
+# detached or destroyed, it is removed from this list.
+# (Since 11.1)
+#
# @poll-max-ns: maximum polling time in ns, 0 means polling is
# disabled (since 2.9)
#
@@ -159,6 +164,7 @@
{ 'struct': 'IOThreadInfo',
'data': {'id': 'str',
'thread-id': 'int',
+ 'holders': ['IOThreadHolder'],
'poll-max-ns': 'int',
'poll-grow': 'int',
'poll-shrink': 'int',
@@ -185,6 +191,8 @@
# {
# "id":"iothread0",
# "thread-id":3134,
+# "holders":[{"qom-path": "/machine/peripheral/blk1/virtio-backend", "type": "qom-object"},
+# {"monitor-name": "compat_monitor0", "type": "monitor-name"}],
# "poll-max-ns":32768,
# "poll-grow":0,
# "poll-shrink":0,
@@ -193,6 +201,7 @@
# {
# "id":"iothread1",
# "thread-id":3135,
+# "holders":[{"node-name": "fmt_qcow2", "type": "block-node"}],
# "poll-max-ns":32768,
# "poll-grow":0,
# "poll-shrink":0,
--
2.49.0
next prev parent reply other threads:[~2026-06-24 7:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-24 7:08 [PATCH V9 00/17] iothread: Support tracking and querying IOThread holders Zhang Chen
2026-06-24 7:08 ` [PATCH V9 01/17] qapi/misc: Fix missed query-iothreads items Zhang Chen
2026-06-24 7:08 ` [PATCH V9 02/17] iothread: introduce iothread_ref/unref to track attached devices Zhang Chen
2026-06-24 15:51 ` Stefan Hajnoczi
2026-06-24 7:08 ` [PATCH V9 03/17] iothread: tracking iothread users with holder name Zhang Chen
2026-06-24 17:10 ` Stefan Hajnoczi
2026-06-24 7:08 ` [PATCH V9 04/17] iothread: introduce iothread_unsafe_get_aio_context() Zhang Chen
2026-06-24 17:19 ` Stefan Hajnoczi
2026-06-24 7:08 ` [PATCH V9 05/17] block/export: track IOThread reference in BlockExport Zhang Chen
2026-06-24 17:51 ` Stefan Hajnoczi
2026-06-24 7:08 ` [PATCH V9 06/17] monitor: refactor monitor_data_init() to pass ID Zhang Chen
2026-06-24 7:08 ` [PATCH V9 07/17] monitor: support iothread ref/unref for anonymous monitors Zhang Chen
2026-06-24 7:08 ` [PATCH V9 08/17] monitor: switch to iothread_unsafe_get_aio_context() Zhang Chen
2026-06-24 7:08 ` [PATCH V9 09/17] virtio-vq-mapping: track iothread-vq-mapping references using device path Zhang Chen
2026-06-24 7:08 ` [PATCH V9 10/17] virtio: use iothread_get/put_aio_context for thread pinning Zhang Chen
2026-06-24 7:08 ` [PATCH V9 11/17] net/colo: track IOThread references using path-based holder Zhang Chen
2026-06-24 7:08 ` [PATCH V9 12/17] virtio-balloon: Update tracking iothread users with holder Zhang Chen
2026-06-24 7:08 ` [PATCH V9 13/17] vfio-user/proxy: Update tracking iothread users with holder name Zhang Chen
2026-06-24 7:08 ` [PATCH V9 14/17] xen-block: " Zhang Chen
2026-06-24 7:08 ` Zhang Chen [this message]
2026-06-24 7:08 ` [PATCH V9 16/17] iothread: simplify API by merging iothread_get_aio_context variants Zhang Chen
2026-06-24 7:08 ` [PATCH V9 17/17] tests/unit/iothread: Update the iothread_get_aio_context Zhang Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260624070851.13342-16-zhangckid@gmail.com \
--to=zhangckid@gmail.com \
--cc=armbru@redhat.com \
--cc=dave@treblig.org \
--cc=eblake@redhat.com \
--cc=fam@euphon.net \
--cc=jasowang@redhat.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.