[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/3] libxl: introduce libxl__qmp_query_cpus
It interrogates QEMU for the number of cpus. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_qmp.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 38ec54d..5c22b97 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1794,6 +1794,9 @@ _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enabl _hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk); /* Add a virtual CPU */ _hidden int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int index); +/* Query the number of CPUs */ +_hidden int libxl__qmp_query_cpus(libxl__gc *gc, int domid, + unsigned int *count); /* Start NBD server */ _hidden int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid, const char *host, const char *port); diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 3eb279a..b9de867 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -979,6 +979,25 @@ int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int idx) return qmp_run_command(gc, domid, "cpu-add", args, NULL, NULL); } +static int query_cpus_callback(libxl__qmp_handler *qmp, + const libxl__json_object *response, + void *opaque) +{ + unsigned int *count = opaque; + GC_INIT(qmp->ctx); + + *count = libxl__json_array_count(response); + + GC_FREE; + return 0; +} + +int libxl__qmp_query_cpus(libxl__gc *gc, int domid, unsigned int *count) +{ + return qmp_run_command(gc, domid, "query-cpus", NULL, + query_cpus_callback, count); +} + int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid, const char *host, const char *port) { -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |