From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Shergill, Gurinder" <gurinder.shergill@hp.com>,
Paolo Bonzini <pbonzini@redhat.com>,
"Vinod, Chegu" <chegu_vinod@hp.com>,
Luiz Capitulino <lcapitulino@redhat.com>
Subject: [Qemu-devel] [PATCH 2/2] qmp: add query-iothreads command
Date: Fri, 21 Feb 2014 15:51:20 +0100 [thread overview]
Message-ID: <1392994280-9675-3-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1392994280-9675-1-git-send-email-stefanha@redhat.com>
The "query-iothreads" command returns a list of information about
iothreads. See the patch for API documentation.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
iothread.c | 36 ++++++++++++++++++++++++++++++++++++
qapi-schema.json | 29 +++++++++++++++++++++++++++++
qmp-commands.hx | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 104 insertions(+)
diff --git a/iothread.c b/iothread.c
index 1a0d1ec..7aa8463 100644
--- a/iothread.c
+++ b/iothread.c
@@ -17,6 +17,7 @@
#include "qemu/thread.h"
#include "block/aio.h"
#include "sysemu/iothread.h"
+#include "qmp-commands.h"
#define IOTHREADS_PATH "/objects"
@@ -151,3 +152,38 @@ AioContext *iothread_get_aio_context(IOThread *iothread)
{
return iothread->ctx;
}
+
+static int query_one_iothread(Object *object, void *opaque)
+{
+ IOThreadInfoList ***prev = opaque;
+ IOThreadInfoList *elem;
+ IOThreadInfo *info;
+ IOThread *iothread;
+
+ iothread = (IOThread *)object_dynamic_cast(object, TYPE_IOTHREAD);
+ if (!iothread) {
+ return 0;
+ }
+
+ info = g_new0(IOThreadInfo, 1);
+ info->id = iothread_get_id(iothread);
+ info->thread_id = iothread->thread_id;
+
+ elem = g_new0(IOThreadInfoList, 1);
+ elem->value = info;
+ elem->next = NULL;
+
+ **prev = elem;
+ *prev = &elem->next;
+ return 0;
+}
+
+IOThreadInfoList *qmp_query_iothreads(Error **errp)
+{
+ IOThreadInfoList *head = NULL;
+ IOThreadInfoList **prev = &head;
+ Object *container = container_get(object_get_root(), IOTHREADS_PATH);
+
+ object_child_foreach(container, query_one_iothread, &prev);
+ return head;
+}
diff --git a/qapi-schema.json b/qapi-schema.json
index 473c096..6795a01 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -884,6 +884,35 @@
{ 'command': 'query-cpus', 'returns': ['CpuInfo'] }
##
+# @IOThreadInfo:
+#
+# Information about an iothread
+#
+# @id: the identifier of the iothread
+#
+# @thread_id: ID of the underlying host thread
+#
+# Since: 2.0
+##
+{ 'type': 'IOThreadInfo',
+ 'data': {'id': 'str', 'thread_id': 'int'} }
+
+##
+# @query-iothreads:
+#
+# Returns a list of information about each iothread.
+#
+# Note this list excludes the QEMU main loop thread, which is not declared
+# using the -object iothread command-line option. It is always the main thread
+# of the process.
+#
+# Returns: a list of @IOThreadInfo for each iothread
+#
+# Since: 2.0
+##
+{ 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] }
+
+##
# @BlockDeviceInfo:
#
# Information about the backing device for a block device.
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 8a0e832..ba16b61 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2304,6 +2304,45 @@ EQMP
},
SQMP
+query-iothreads
+---------------
+
+Returns a list of information about each iothread.
+
+Note this list excludes the QEMU main loop thread, which is not declared
+using the -object iothread command-line option. It is always the main thread
+of the process.
+
+Return a json-array. Each iothread is represented by a json-object, which contains:
+
+- "id": name of iothread (json-str)
+- "thread_id": ID of the underlying host thread (json-int)
+
+Example:
+
+-> { "execute": "query-iothreads" }
+<- {
+ "return":[
+ {
+ "id":"iothread0",
+ "thread_id":3134
+ },
+ {
+ "id":"iothread1",
+ "thread_id":3135
+ }
+ ]
+ }
+
+EQMP
+
+ {
+ .name = "query-iothreads",
+ .args_type = "",
+ .mhandler.cmd_new = qmp_marshal_input_query_iothreads,
+ },
+
+SQMP
query-pci
---------
--
1.8.5.3
next prev parent reply other threads:[~2014-02-21 14:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-21 14:51 [Qemu-devel] [PATCH 0/2] dataplane: add query-iothreads QMP command Stefan Hajnoczi
2014-02-21 14:51 ` [Qemu-devel] [PATCH 1/2] iothread: stash thread ID away Stefan Hajnoczi
2014-02-21 15:18 ` Paolo Bonzini
2014-02-24 15:53 ` Stefan Hajnoczi
2014-02-24 16:48 ` Paolo Bonzini
2014-02-25 15:42 ` Stefan Hajnoczi
2014-02-25 16:10 ` Paolo Bonzini
2014-02-25 16:17 ` Stefan Hajnoczi
2014-02-25 16:27 ` Paolo Bonzini
2014-02-21 14:51 ` Stefan Hajnoczi [this message]
2014-02-21 15:27 ` [Qemu-devel] [PATCH 2/2] qmp: add query-iothreads command Eric Blake
2014-02-24 15:54 ` Stefan Hajnoczi
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=1392994280-9675-3-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=chegu_vinod@hp.com \
--cc=gurinder.shergill@hp.com \
--cc=lcapitulino@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).