From dc3dd0d2bed6edf3b60041f31200c674348168e9 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Thu, 27 Feb 2014 11:48:42 +0100 Subject: 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 Signed-off-by: Stefan Hajnoczi --- iothread.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'iothread.c') 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; +} -- cgit v1.2.3