From patchwork Mon Aug 9 17:00:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Di Ciurcio Filho X-Patchwork-Id: 61295 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5546CB70A9 for ; Tue, 10 Aug 2010 03:01:32 +1000 (EST) Received: from localhost ([127.0.0.1]:36685 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OiVj7-00031B-6C for incoming@patchwork.ozlabs.org; Mon, 09 Aug 2010 13:01:29 -0400 Received: from [140.186.70.92] (port=44020 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OiVfV-0001Sw-W3 for qemu-devel@nongnu.org; Mon, 09 Aug 2010 12:57:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OiVfT-0006N9-IR for qemu-devel@nongnu.org; Mon, 09 Aug 2010 12:57:44 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:44542) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OiVfT-0006N2-F7 for qemu-devel@nongnu.org; Mon, 09 Aug 2010 12:57:43 -0400 Received: by ywt2 with SMTP id 2so3844985ywt.4 for ; Mon, 09 Aug 2010 09:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=N9j4QULBHUkx66tNQNcPFq+mWD1FLTMa87AvxP5umvI=; b=o1aPDBgM5iaOWoW8jmeZ51/myXigb+tc135Bn5lS8iKLJRfiwGn5PPwjGDUckPh4DG qPAbJ0oAo1WSsQVE/BGxocwdYIU8Il/VXWlmnMc2iabBmU+IRJKvNNllsdAnfuC5Qxdy V9ekv5kOH/iCLmv+EKZCi6pfwXDie8DifdJqs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=YpBz+rvQRwpKbl51Mh7T6tOwQ6n0hMZ6wxoF4AKF2dEYK85v9gsqtzi9YV3uYfIVDB dnvmg07P6qhd/E+6R21GqlTfKZId7t2KwLD4q04n/n8q1Fu4pKF9ws6PsVKzDwtPrqNo bX+o4/FbfsoNMnSL4/sK29jokyG8dLJAZz9pE= Received: by 10.150.75.11 with SMTP id x11mr17866385yba.392.1281373062801; Mon, 09 Aug 2010 09:57:42 -0700 (PDT) Received: from localhost.localdomain (quake.ic.unicamp.br [143.106.7.51]) by mx.google.com with ESMTPS id u41sm4934709yba.10.2010.08.09.09.57.28 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 09 Aug 2010 09:57:36 -0700 (PDT) From: Miguel Di Ciurcio Filho To: qemu-devel@nongnu.org Date: Mon, 9 Aug 2010 14:00:56 -0300 Message-Id: <1281373256-602-3-git-send-email-miguel.filho@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1281373256-602-1-git-send-email-miguel.filho@gmail.com> References: <1281373256-602-1-git-send-email-miguel.filho@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: Miguel Di Ciurcio Filho , armbru@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH 2/2] QMP/monitor: update do_info_version() to output broken down version string X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This code was originally developed by Daniel P. Berrange Signed-off-by: Miguel Di Ciurcio Filho --- 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)