aboutsummaryrefslogtreecommitdiff
path: root/iothread.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2014-02-27 11:48:42 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2014-03-13 14:42:24 +0100
commitdc3dd0d2bed6edf3b60041f31200c674348168e9 (patch)
tree5b390cd8da5ebcf82d83844d858c6fd8f4e08d9d /iothread.c
parent88eb7c29e4320597d2f246adf731f0aac97cfbcc (diff)
qmp: add query-iothreads command
The "query-iothreads" command returns a list of information about iothreads. See the patch for API documentation. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'iothread.c')
-rw-r--r--iothread.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/iothread.c b/iothread.c
index f90bbc339e..cb5986b6c9 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;
+}