From patchwork Wed Jun 2 12:40:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 54363 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 212CFB7D5E for ; Wed, 2 Jun 2010 22:40:50 +1000 (EST) Received: from localhost ([127.0.0.1]:44297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJnFX-000663-GZ for incoming@patchwork.ozlabs.org; Wed, 02 Jun 2010 08:40:47 -0400 Received: from [140.186.70.92] (port=59945 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJnEy-00065t-OG for qemu-devel@nongnu.org; Wed, 02 Jun 2010 08:40:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJnEw-0007UK-VX for qemu-devel@nongnu.org; Wed, 02 Jun 2010 08:40:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30242) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJnEw-0007U4-P4 for qemu-devel@nongnu.org; Wed, 02 Jun 2010 08:40:10 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o52Ce9Vf013875 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 2 Jun 2010 08:40:09 -0400 Received: from localhost.localdomain (vpn2-9-65.ams2.redhat.com [10.36.9.65]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o52Ce7sZ010269; Wed, 2 Jun 2010 08:40:08 -0400 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Wed, 2 Jun 2010 13:40:06 +0100 Message-Id: <1275482406-31020-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH] Change 'query-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 A previous discussion brought up the fact that clients should not have to parse version string from QMP, it should be given to them pre-split. Change query-version output format from: { "qemu": "0.11.50", "package": "" } to: { "major": 0, "minor": 11, "micro": 5, "package": "" } major, minor & micro are all integer values. package is an arbitrary string whose format is defined by the OS package maintainer. There is no need to preserve the existing 'qemu' field, since QMP is not yet declared stable. --- monitor.c | 33 ++++++++++++++++++++++++++------- 1 files changed, 26 insertions(+), 7 deletions(-) diff --git a/monitor.c b/monitor.c index 3ee365c..a33f7a8 100644 --- a/monitor.c +++ b/monitor.c @@ -673,8 +673,11 @@ static void do_info_version_print(Monitor *mon, const QObject *data) qdict = qobject_to_qdict(data); - 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(qdict, "major"), + qdict_get_int(qdict, "minor"), + qdict_get_int(qdict, "micro"), + qdict_get_str(qdict, "package")); } /** @@ -682,17 +685,33 @@ static void do_info_version_print(Monitor *mon, const QObject *data) * * Return a QDict with the following information: * - * - "qemu": QEMU's version - * - "package": package's version + * - "major": QEMU's major version + * - "minor": QEMU's minor version + * - "micro": QEMU's micro version + * - "package": QEMU packager's version + * + * The first three values are guarenteed to be + * integers. The final 'package' value is a string + * in an arbitrary packager specific format * * Example: * - * { "qemu": "0.11.50", "package": "" } + * { "major": 0, "minor": 11, "micro": 5, "package": "" } */ static void do_info_version(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("{ 'major': %d, 'minor': %d, 'micro': %d, 'package': %s }", + major, minor, micro, QEMU_PKGVERSION); } static void do_info_name_print(Monitor *mon, const QObject *data)