From patchwork Fri Jul 27 13:37:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 173671 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 A4D482C009A for ; Fri, 27 Jul 2012 23:38:17 +1000 (EST) Received: from localhost ([::1]:55306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SukkB-0002c7-Qd for incoming@patchwork.ozlabs.org; Fri, 27 Jul 2012 09:38:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sukk0-0002Qz-Ly for qemu-devel@nongnu.org; Fri, 27 Jul 2012 09:38:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sukjw-0008QQ-Eb for qemu-devel@nongnu.org; Fri, 27 Jul 2012 09:38:04 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:49445) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sukjw-0008QM-An for qemu-devel@nongnu.org; Fri, 27 Jul 2012 09:38:00 -0400 Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 27 Jul 2012 09:37:35 -0400 Received: from d01dlp03.pok.ibm.com (9.56.224.17) by e8.ny.us.ibm.com (192.168.1.108) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 27 Jul 2012 09:37:29 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id C4C34C90048 for ; Fri, 27 Jul 2012 09:37:28 -0400 (EDT) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6RDbSl766715756 for ; Fri, 27 Jul 2012 09:37:28 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6RDbRGp009281 for ; Fri, 27 Jul 2012 10:37:27 -0300 Received: from titi.austin.rr.com ([9.76.49.219]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6RDbN5K008888; Fri, 27 Jul 2012 10:37:27 -0300 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Fri, 27 Jul 2012 08:37:15 -0500 Message-Id: <1343396239-19272-4-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1343396239-19272-1-git-send-email-aliguori@us.ibm.com> References: <1343396239-19272-1-git-send-email-aliguori@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12072713-9360-0000-0000-000008D36158 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.182.138 Cc: Peter Maydell , Anthony Liguori , libvir-list@redhat.com, Alexander Graf , Markus Armbruster , Eric Blake Subject: [Qemu-devel] [PATCH 3/7] 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 This provides the same output as -M ? but in a structured way. Signed-off-by: Anthony Liguori --- qapi-schema.json | 28 ++++++++++++++++++++++++++++ qmp-commands.hx | 6 ++++++ vl.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 0 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 28e9914..5b47026 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2200,3 +2200,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 5c55528..a6f82fc 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2222,3 +2222,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 8904db1..cd900e0 100644 --- a/vl.c +++ b/vl.c @@ -1209,6 +1209,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 */