From patchwork Mon Aug 13 19:49:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 177137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id ED5082C0085 for ; Tue, 14 Aug 2012 07:25:48 +1000 (EST) Received: from localhost ([::1]:51293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T128w-0003ur-Us for incoming@patchwork.ozlabs.org; Mon, 13 Aug 2012 17:25:46 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T10e2-000295-Mh for qemu-devel@nongnu.org; Mon, 13 Aug 2012 15:49:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T10dz-0003yo-EP for qemu-devel@nongnu.org; Mon, 13 Aug 2012 15:49:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35377) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T10dz-0003yZ-2S for qemu-devel@nongnu.org; Mon, 13 Aug 2012 15:49:43 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7DJnguW024640 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Aug 2012 15:49:42 -0400 Received: from localhost (ovpn-113-98.phx2.redhat.com [10.3.113.98]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7DJnfjQ016441; Mon, 13 Aug 2012 15:49:41 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Mon, 13 Aug 2012 16:49:05 -0300 Message-Id: <1344887349-13041-45-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1344887349-13041-1-git-send-email-lcapitulino@redhat.com> References: <1344887349-13041-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 44/48] qapi: add query-machines command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Anthony Liguori This provides the same output as -M ? but in a structured way. Signed-off-by: Anthony Liguori Signed-off-by: Luiz Capitulino --- qapi-schema.json | 28 ++++++++++++++++++++++++++++ qmp-commands.hx | 6 ++++++ vl.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/qapi-schema.json b/qapi-schema.json index 1731a92..e51753c 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2194,3 +2194,31 @@ # Since: 0.14.0 ## { 'command': 'closefd', 'data': {'fdname': 'str'} } + +## +# @MachineInfo: +# +# Information describing a machine. +# +# @name: the name of the machine +# +# @alias: #optional an alias for the machine name +# +# @default: #optional whether the machine is default +# +# Since: 1.2.0 +## +{ 'type': 'MachineInfo', + 'data': { 'name': 'str', '*alias': 'str', + '*is-default': 'bool' } } + +## +# @query-machines: +# +# Return a list of supported machines +# +# Returns: a list of MachineInfo +# +# Since: 1.2.0 +## +{ 'command': 'query-machines', 'returns': ['MachineInfo'] } diff --git a/qmp-commands.hx b/qmp-commands.hx index e9e0410..fd87775 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2224,3 +2224,9 @@ EQMP .mhandler.cmd_new = qmp_marshal_input_device_list_properties, }, + { + .name = "query-machines", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_machines, + }, + diff --git a/vl.c b/vl.c index 97ab39f..d01256a 100644 --- a/vl.c +++ b/vl.c @@ -1213,6 +1213,37 @@ QEMUMachine *find_default_machine(void) return NULL; } +MachineInfoList *qmp_query_machines(Error **errp) +{ + MachineInfoList *mach_list = NULL; + QEMUMachine *m; + + for (m = first_machine; m; m = m->next) { + MachineInfoList *entry; + MachineInfo *info; + + info = g_malloc0(sizeof(*info)); + if (m->is_default) { + info->has_is_default = true; + info->is_default = true; + } + + if (m->alias) { + info->has_alias = true; + info->alias = g_strdup(m->alias); + } + + info->name = g_strdup(m->name); + + entry = g_malloc0(sizeof(*entry)); + entry->value = info; + entry->next = mach_list; + mach_list = entry; + } + + return mach_list; +} + /***********************************************************/ /* main execution loop */