[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] libxl: introduce libxl__qmp_query_cpus
commit 324bd8f5dce20d0a1dbbd9480f89673a18e1db53 Author: Wei Liu <wei.liu2@xxxxxxxxxx> AuthorDate: Tue Jun 7 10:03:39 2016 +0100 Commit: Wei Liu <wei.liu2@xxxxxxxxxx> CommitDate: Tue Jul 12 12:49:41 2016 +0100 libxl: introduce libxl__qmp_query_cpus It interrogates QEMU for CPUs and update the bitmap accordingly. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Reviewed-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx> Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_qmp.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index de77579..e33c710 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 bitmap of CPUs */ +_hidden int libxl__qmp_query_cpus(libxl__gc *gc, int domid, + libxl_bitmap *map); /* 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..63c49c5 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -979,6 +979,44 @@ 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) +{ + libxl_bitmap *map = opaque; + unsigned int i; + const libxl__json_object *cpu = NULL; + int rc; + GC_INIT(qmp->ctx); + + libxl_bitmap_set_none(map); + for (i = 0; (cpu = libxl__json_array_get(response, i)); i++) { + unsigned int idx; + const libxl__json_object *o; + + o = libxl__json_map_get("CPU", cpu, JSON_INTEGER); + if (!o) { + LOG(ERROR, "Failed to retrieve CPU index."); + rc = ERROR_FAIL; + goto out; + } + + idx = libxl__json_object_get_integer(o); + libxl_bitmap_set(map, idx); + } + + rc = 0; +out: + GC_FREE; + return rc; +} + +int libxl__qmp_query_cpus(libxl__gc *gc, int domid, libxl_bitmap *map) +{ + return qmp_run_command(gc, domid, "query-cpus", NULL, + query_cpus_callback, map); +} + int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid, const char *host, const char *port) { -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |