]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
libxl_qmp: Store advertised QEMU version in libxl__ev_qmp
authorAnthony PERARD <anthony.perard@citrix.com>
Tue, 24 Jul 2018 17:26:33 +0000 (18:26 +0100)
committerWei Liu <wei.liu2@citrix.com>
Fri, 11 Jan 2019 14:57:52 +0000 (14:57 +0000)
This will be used in a later patch.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl_internal.h
tools/libxl/libxl_qmp.c

index f30c106fbba4ea532540d9bc24fa86cb8a2f6052..6bc520864f31dfe9fde6a5793b35e0e0bfa00a3c 100644 (file)
@@ -439,6 +439,14 @@ struct libxl__ev_qmp {
     libxl__ev_qmp_callback *callback;
     int payload_fd; /* set to send a fd with the command, -1 otherwise */
 
+    /* read-only when Connected
+     * and not to be accessed by the caller otherwise */
+    struct {
+        int major;
+        int minor;
+        int micro;
+    } qemu_version;
+
     /*
      * remaining fields are private to libxl_ev_qmp_*
      */
index 4e21a504db6398a5388deb1bdfef7fa7386b1c63..6fe27c239f7552a1095dcceec8b762e72026f65b 100644 (file)
@@ -1829,6 +1829,27 @@ static int qmp_ev_handle_message(libxl__egc *egc,
             return ERROR_PROTOCOL_ERROR_QMP;
         }
 
+        /*
+         * Store advertised QEMU version
+         * { "QMP": { "version": {
+         *     "qemu": { "major": int, "minor": int, "micro": int } } } }
+         */
+        o = libxl__json_map_get("QMP", resp, JSON_MAP);
+        o = libxl__json_map_get("version", o, JSON_MAP);
+        o = libxl__json_map_get("qemu", o, JSON_MAP);
+#define GRAB_VERSION(level) do { \
+        ev->qemu_version.level = libxl__json_object_get_integer( \
+            libxl__json_map_get(#level, o, JSON_INTEGER)); \
+        } while (0)
+        GRAB_VERSION(major);
+        GRAB_VERSION(minor);
+        GRAB_VERSION(micro);
+#undef GRAB_VERSION
+        LOGD(DEBUG, ev->domid, "QEMU version: %d.%d.%d",
+             ev->qemu_version.major,
+             ev->qemu_version.minor,
+             ev->qemu_version.micro);
+
         /* Prepare next message to send */
         assert(!ev->tx_buf);
         ev->id = ev->next_id++;
@@ -1991,6 +2012,10 @@ void libxl__ev_qmp_init(libxl__ev_qmp *ev)
 
     ev->msg = NULL;
     ev->msg_id = 0;
+
+    ev->qemu_version.major = -1;
+    ev->qemu_version.minor = -1;
+    ev->qemu_version.micro = -1;
 }
 
 int libxl__ev_qmp_send(libxl__gc *unused_gc, libxl__ev_qmp *ev,