Skip to contentSkip to conversation

QMP: update 'query-version'

PATCH In review Miguel Di Ciurcio Filho 3 participants 5 messages Aug 9, 2010 – Aug 26, 2010

lore
Share & tools
lore
#0 lore raw

cover QMP: update 'query-version'

This series changes how QMP exports the version of QEMU to clients.

Current behavior:
{"QMP": {"version": {"qemu": "0.13.50", "package": ""}, "capabilities": []}}

New behavior:
{"QMP": {"version": {"qemu": {"micro": 50, "minor": 13, "major": 0}, "package":
""}, "capabilities": []}}

Clients will no longer need to parse the entire string.

Regards,

Miguel

---

Miguel Di Ciurcio Filho (2):
QMP: update 'query-version' documentation
QMP/monitor: update do_info_version() to output broken down version
string

 monitor.c       |   23 +++++++++++++++++++----
 qemu-monitor.hx |   16 ++++++++++++++--
 2 files changed, 33 insertions(+), 6 deletions(-)
#1 lore raw

PATCH 1/2 QMP: update 'query-version' documentation

Update the documentation of 'query-version' to output the string version broken down.

---
 qemu-monitor.hx |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
qemu-monitor.hx +14 -2
index 2af3de6..9c27b31 100644
@@ -1623,13 +1623,25 @@ Show QEMU version.
 
 Return a json-object with the following information:
 
-- "qemu": QEMU's version (json-string)
+- "qemu": A json-object containing three integer values:
+    - "major": QEMU's major version (json-int)
+    - "minor": QEMU's minor version (json-int)
+    - "micro": QEMU's micro version (json-int)
 - "package": package's version (json-string)
 
 Example:
 
 -> { "execute": "query-version" }
-<- { "return": { "qemu": "0.11.50", "package": "" } }
+<- {
+      "return":{
+         "qemu":{
+            "major":0,
+            "minor":11,
+            "micro":5
+         },
+         "package":""
+      }
+   }
 
 EQMP
 
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/2 QMP/monitor: update do_info_version() to output broken down version string

In reply to Miguel Di Ciurcio Filho

This code was originally developed by Daniel P. Berrange <[email protected]>

---
 monitor.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)
monitor.c +19 -4
index c313d5a..e82c48f 100644
@@ -669,17 +669,32 @@ help:
 static void do_info_version_print(Monitor *mon, const QObject *data)
 {
     QDict *qdict;
+    QDict *qemu;
 
     qdict = qobject_to_qdict(data);
+    qemu = qdict_get_qdict(qdict, "qemu");
 
-    monitor_printf(mon, "%s%s\n", qdict_get_str(qdict, "qemu"),
-                                  qdict_get_str(qdict, "package"));
+    monitor_printf(mon, "%" PRId64 ".%" PRId64 ".%" PRId64 "%s\n",
+		   qdict_get_int(qemu, "major"),
+		   qdict_get_int(qemu, "minor"),
+		   qdict_get_int(qemu, "micro"),
+		   qdict_get_str(qdict, "package"));
 }
 
 static void do_info_version(Monitor *mon, QObject **ret_data)
 {
-    *ret_data = qobject_from_jsonf("{ 'qemu': %s, 'package': %s }",
-                                   QEMU_VERSION, QEMU_PKGVERSION);
+    const char *version = QEMU_VERSION;
+    int major = 0, minor = 0, micro = 0;
+    char *tmp;
+
+    major = strtol(version, &tmp, 10);
+    tmp++;
+    minor = strtol(tmp, &tmp, 10);
+    tmp++;
+    micro = strtol(tmp, &tmp, 10);
+
+    *ret_data = qobject_from_jsonf("{ 'qemu': { 'major': %d, 'minor': %d, \
+        'micro': %d }, 'package': %s }", major, minor, micro, QEMU_PKGVERSION);
 }
 
 static void do_info_name_print(Monitor *mon, const QObject *data)
Signature · 1 line
1.7.1
#3 lore raw

Re: [Qemu-devel] [PATCH 2/2] QMP/monitor: update do_info_version() to output broken down version string

Quoted 18 lines · Miguel Di Ciurcio Filho

This code was originally developed by Daniel P. Berrange <[email protected]>

---
 monitor.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)
monitor.c +1 -0
index c313d5a..e82c48f 100644
@@ -669,17 +669,32 @@ help:
 static void do_info_version_print(Monitor *mon, const QObject *data)
 {
     QDict *qdict;
+    QDict *qemu;
 
     qdict = qobject_to_qdict(data);

monitor.c help: · line 682

Quoted 10 lines
monitor.c +6 -2
+    qemu = qdict_get_qdict(qdict, "qemu");
 
-    monitor_printf(mon, "%s%s\n", qdict_get_str(qdict, "qemu"),
-                                  qdict_get_str(qdict, "package"));
+    monitor_printf(mon, "%" PRId64 ".%" PRId64 ".%" PRId64 "%s\n",
+		   qdict_get_int(qemu, "major"),
+		   qdict_get_int(qemu, "minor"),
+		   qdict_get_int(qemu, "micro"),
+		   qdict_get_str(qdict, "package"));
 }

Above snippet uses tab(s).

Quoted 20 lines
monitor.c +12 -2
 static void do_info_version(Monitor *mon, QObject **ret_data)
 {
-    *ret_data = qobject_from_jsonf("{ 'qemu': %s, 'package': %s }",
-                                   QEMU_VERSION, QEMU_PKGVERSION);
+    const char *version = QEMU_VERSION;
+    int major = 0, minor = 0, micro = 0;
+    char *tmp;
+
+    major = strtol(version, &tmp, 10);
+    tmp++;
+    minor = strtol(tmp, &tmp, 10);
+    tmp++;
+    micro = strtol(tmp, &tmp, 10);
+
+    *ret_data = qobject_from_jsonf("{ 'qemu': { 'major': %d, 'minor': %d, \
+        'micro': %d }, 'package': %s }", major, minor, micro, QEMU_PKGVERSION);
 }
 
 static void do_info_name_print(Monitor *mon, const QObject *data)
 
Signature · 1 line
mailto:[email protected]
#4 lore raw
In reply to Miguel Di Ciurcio Filho
Quoted 10 lines · On Mon, 9 Aug 2010 14:00:54 -0300 Miguel Di Ciurcio Filho…

This series changes how QMP exports the version of QEMU to clients.

Current behavior:
{"QMP": {"version": {"qemu": "0.13.50", "package": ""}, "capabilities": []}}

New behavior:
{"QMP": {"version": {"qemu": {"micro": 50, "minor": 13, "major": 0}, "package":
""}, "capabilities": []}}

Clients will no longer need to parse the entire string.

Forgot to reply this one: it looks good to me and has already been merged on master.