From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>
Subject: [PATCH v3 3/5] libxl: introduce libxl__qmp_query_cpus
Date: Wed, 15 Jun 2016 10:31:40 +0100 [thread overview]
Message-ID: <1465983102-19308-4-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1465983102-19308-1-git-send-email-wei.liu2@citrix.com>
It interrogates QEMU for CPUs and update the bitmap accordingly.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Anthony PERARD <anthony.perard@citrix.com>
v3:
1. Initialise rc in error path.
2. Fix comment in header and a typo in log message.
---
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 3958313..cad35fb 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)
{
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-06-15 9:31 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-15 9:31 [PATCH v3 0/5] libxl: libxl: update available vcpus map in retrieve configuration function Wei Liu
2016-06-15 9:31 ` [PATCH v3 1/5] libxl: libxl_domain_need_memory shouldn't modify b_info Wei Liu
2016-06-15 13:31 ` Dario Faggioli
2016-06-15 13:38 ` Wei Liu
2016-07-08 17:35 ` Ian Jackson
2016-07-11 11:03 ` Wei Liu
2016-06-15 9:31 ` [PATCH v3 2/5] libxl: factor out libxl__get_device_modlel_version Wei Liu
2016-06-15 13:27 ` Dario Faggioli
2016-06-15 17:04 ` Anthony PERARD
2016-07-08 17:37 ` Ian Jackson
2016-06-15 9:31 ` Wei Liu [this message]
2016-06-15 13:26 ` [PATCH v3 3/5] libxl: introduce libxl__qmp_query_cpus Dario Faggioli
2016-06-15 16:48 ` Anthony PERARD
2016-07-08 17:45 ` Ian Jackson
2016-06-15 9:31 ` [PATCH v3 4/5] libxl: update vcpus bitmap in retrieved guest config Wei Liu
2016-06-15 17:20 ` Anthony PERARD
2016-07-08 17:44 ` Ian Jackson
2016-07-11 11:31 ` Wei Liu
2016-07-11 14:59 ` Wei Liu
2016-06-15 9:31 ` [PATCH v3 5/5] libxl: only issue cpu-add call to QEMU for not present CPU Wei Liu
2016-07-08 17:48 ` Ian Jackson
2016-07-11 11:32 ` Wei Liu
2016-07-02 10:22 ` [PATCH v3 0/5] libxl: libxl: update available vcpus map in retrieve configuration function Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1465983102-19308-4-git-send-email-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=anthony.perard@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).