qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
To: qemu-devel@nongnu.org
Cc: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>,
	armbru@redhat.com, lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH 2/2] QMP/monitor: update do_info_version() to output broken down version string
Date: Mon,  9 Aug 2010 14:00:56 -0300	[thread overview]
Message-ID: <1281373256-602-3-git-send-email-miguel.filho@gmail.com> (raw)
In-Reply-To: <1281373256-602-1-git-send-email-miguel.filho@gmail.com>

This code was originally developed by Daniel P. Berrange <berrange@redhat.com>

Signed-off-by: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
---
 monitor.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/monitor.c b/monitor.c
index c313d5a..e82c48f 100644
--- a/monitor.c
+++ b/monitor.c
@@ -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)
-- 
1.7.1

  parent reply	other threads:[~2010-08-09 16:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-09 17:00 [Qemu-devel] [PATCH 0/2] QMP: update 'query-version' Miguel Di Ciurcio Filho
2010-08-09 17:00 ` [Qemu-devel] [PATCH 1/2] QMP: update 'query-version' documentation Miguel Di Ciurcio Filho
2010-08-09 17:00 ` Miguel Di Ciurcio Filho [this message]
2010-08-09 18:09   ` [Qemu-devel] [PATCH 2/2] QMP/monitor: update do_info_version() to output broken down version string malc
2010-08-26 13:07 ` [Qemu-devel] Re: [PATCH 0/2] QMP: update 'query-version' Luiz Capitulino

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=1281373256-602-3-git-send-email-miguel.filho@gmail.com \
    --to=miguel.filho@gmail.com \
    --cc=armbru@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.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).