[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 15/24] qmp: add query-iothreads command
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 15/24] qmp: add query-iothreads command |
Date: |
Wed, 12 Mar 2014 11:29:23 +0100 |
The "query-iothreads" command returns a list of information about
iothreads. See the patch for API documentation.
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
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 ff46ea9..0c38ebc 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"
@@ -140,3 +141,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 6c381b7..be18642 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -883,6 +883,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 d982cd6..a22621f 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2327,6 +2327,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
- [Qemu-devel] [PULL 08/24] rfifolock: add recursive FIFO lock, (continued)
- [Qemu-devel] [PULL 08/24] rfifolock: add recursive FIFO lock, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 10/24] iothread: add I/O thread object, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 09/24] aio: add aio_context_acquire() and aio_context_release(), Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 12/24] iothread: add "iothread" qdev property type, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 13/24] dataplane: replace internal thread with IOThread, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 17/24] qcow2: Don't write with BDRV_O_INCOMING, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 14/24] iothread: stash thread ID away, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 03/24] qcow2: Check bs->drv in copy_sectors(), Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 05/24] iotests: Test corruption during COW request, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 11/24] qdev: make get_pointer() handle temporary strings, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 15/24] qmp: add query-iothreads command,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 21/24] block/raw-posix: bdrv_parse_filename() for floppy, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 19/24] qemu-io: Fix warnings from static code analysis, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 24/24] block/raw-win32: bdrv_parse_filename() for hdev, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 16/24] qcow2: Keep option in qcow2_invalidate_cache(), Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 18/24] block: Unlink temporary file, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 20/24] block/raw-posix: bdrv_parse_filename() for hdev, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 22/24] block/raw-posix: bdrv_parse_filename() for cdrom, Stefan Hajnoczi, 2014/03/12
- [Qemu-devel] [PULL 23/24] block/raw-posix: Strip protocol prefix on creation, Stefan Hajnoczi, 2014/03/12
- Re: [Qemu-devel] [PULL 00/24] Block patches for QEMU 2.0, Peter Maydell, 2014/03/12