From patchwork Mon Mar 7 01:22:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 85620 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 19E2EB7104 for ; Mon, 7 Mar 2011 12:30:08 +1100 (EST) Received: from localhost ([127.0.0.1]:48732 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwPGj-00025Z-Gd for incoming@patchwork.ozlabs.org; Sun, 06 Mar 2011 20:29:53 -0500 Received: from [140.186.70.92] (port=47510 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwPAV-0007Uz-MO for qemu-devel@nongnu.org; Sun, 06 Mar 2011 20:23:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PwPAS-0000PO-P2 for qemu-devel@nongnu.org; Sun, 06 Mar 2011 20:23:27 -0500 Received: from e6.ny.us.ibm.com ([32.97.182.146]:43930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PwPAS-0000PA-JM for qemu-devel@nongnu.org; Sun, 06 Mar 2011 20:23:24 -0500 Received: from d01dlp02.pok.ibm.com (d01dlp02.pok.ibm.com [9.56.224.85]) by e6.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p270x7VK010632 for ; Sun, 6 Mar 2011 19:59:07 -0500 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 485D16E8038 for ; Sun, 6 Mar 2011 20:23:24 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p271NO97222018 for ; Sun, 6 Mar 2011 20:23:24 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p271NNL9021085 for ; Sun, 6 Mar 2011 20:23:23 -0500 Received: from localhost.localdomain (sig-9-65-217-198.mts.ibm.com [9.65.217.198]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p271N9MV020370; Sun, 6 Mar 2011 20:23:23 -0500 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Sun, 6 Mar 2011 19:22:56 -0600 Message-Id: <1299460984-15849-15-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1299460984-15849-1-git-send-email-aliguori@us.ibm.com> References: <1299460984-15849-1-git-send-email-aliguori@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 32.97.182.146 Cc: Adam Litke , Anthony Liguori , Markus Armbruster , Luiz Capitulino Subject: [Qemu-devel] [PATCH 14/22] qapi: add query-version QMP command 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 is used internally by QMP. It's also a pretty good example of a typical command conversion. Signed-off-by: Anthony Liguori diff --git a/Makefile.objs b/Makefile.objs index 5dae800..e1a2756 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -103,7 +103,7 @@ common-obj-y += block-migration.o common-obj-y += pflib.o common-obj-y += bitmap.o bitops.o common-obj-y += qmp-marshal-types.o qmp-marshal-types-core.o -common-obj-y += qmp-core.o qmp-marshal.o +common-obj-y += qmp-core.o qmp-marshal.o qmp.o common-obj-$(CONFIG_BRLAPI) += baum.o common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o diff --git a/qmp-schema.json b/qmp-schema.json index e69de29..b343f5e 100644 --- a/qmp-schema.json +++ b/qmp-schema.json @@ -0,0 +1,38 @@ +# *-*- Mode: Python -*-* +### 0.14.0 commands. Do not modify. ### + +## +# @VersionInfo: +# +# A description of QEMU's version. +# +# @qemu.major: The major version of QEMU +# +# @qemu.minor: The minor version of QEMU +# +# @qemu.micro: The micro version of QEMU. By current convention, a micro +# version of 50 signifies a development branch. A micro version +# greater than or equal to 90 signifies a release candidate for +# the next minor version. A micro version of less than 50 +# signifies a stable release. +# +# @package: QEMU will always set this field to an empty string. Downstream +# versions of QEMU should set this to a non-empty string. The +# exact format depends on the downstream however it highly +# recommended that a unique name is used. +# +# Since: 0.14.0 +## +{ 'VersionInfo': {'qemu': {'major': 'int', 'minor': 'int', 'micro': 'int'}, + 'package': 'str'} } + +## +# @query-version: +# +# Returns the current version of QEMU. +# +# Returns: A @VersionInfo object describing the current version of QEMU. +# +# Since: 0.14.0 +## +[ 'query-version', {}, {}, 'VersionInfo' ] diff --git a/qmp.c b/qmp.c new file mode 100644 index 0000000..7b626f5 --- /dev/null +++ b/qmp.c @@ -0,0 +1,31 @@ +/* + * QAPI + * + * Copyright IBM, Corp. 2011 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU LGPL, version 2. See + * the COPYING.LIB file in the top-level directory. + */ +#include "qemu-common.h" +#include "qmp-core.h" +#include "qmp.h" + +VersionInfo *qmp_query_version(Error **err) +{ + VersionInfo *info = qmp_alloc_version_info(); + const char *version = QEMU_VERSION; + char *tmp; + + info->qemu.major = strtol(version, &tmp, 10); + tmp++; + info->qemu.minor = strtol(tmp, &tmp, 10); + tmp++; + info->qemu.micro = strtol(tmp, &tmp, 10); + info->package = qemu_strdup(QEMU_PKGVERSION); + + return info; +} +