From patchwork Mon Jun 7 14:42:23 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: 54875 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 AE80BB7D4F for ; Tue, 8 Jun 2010 01:12:24 +1000 (EST) Received: from localhost ([127.0.0.1]:55957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLdzx-0006tS-K9 for incoming@patchwork.ozlabs.org; Mon, 07 Jun 2010 11:12:21 -0400 Received: from [140.186.70.92] (port=56290 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLdYN-0005sW-C4 for qemu-devel@nongnu.org; Mon, 07 Jun 2010 10:44:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OLdXq-0005Ba-TD for qemu-devel@nongnu.org; Mon, 07 Jun 2010 10:43:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45848) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OLdXq-0005BE-Lx for qemu-devel@nongnu.org; Mon, 07 Jun 2010 10:43:18 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o57EhHaI013332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 7 Jun 2010 10:43:18 -0400 Received: from localhost.localdomain (dhcp-1-192.lcy.redhat.com [10.32.224.192]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o57EgrCb031909; Mon, 7 Jun 2010 10:43:15 -0400 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Mon, 7 Jun 2010 15:42:23 +0100 Message-Id: <1275921752-29420-11-git-send-email-berrange@redhat.com> In-Reply-To: <1275921752-29420-1-git-send-email-berrange@redhat.com> References: <1275921752-29420-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH 10/19] Add a query-machines command to QMP 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 Add a new QMP monitor command 'query-machines' to discover what machines are defined in the QEMU binary. This is an easily parsable replacement for 'qemu -M ?' [ { "name": "pc-0.13", "description": "Standard PC", "default": 0 }, { "name": "pc", "description": "Standard PC", "canonical": "pc-0.13", "default": 1 }, { "name": "pc-0.12", "description": "Standard PC", "default": 0 }, .... ] No legacy readline monitor output is provided. In the future it would be desirable for each machine's QDict to also include details of any qdev devices that are included by default in the machine type. Signed-off-by: Daniel P. Berrange --- hw/boards.h | 1 + monitor.c | 9 +++++++ vl.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 0 deletions(-) diff --git a/hw/boards.h b/hw/boards.h index 6f0f0d7..2f6003d 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -32,6 +32,7 @@ typedef struct QEMUMachine { } QEMUMachine; int qemu_register_machine(QEMUMachine *m); +void do_info_machines(Monitor *mon, QObject **data); extern QEMUMachine *current_machine; diff --git a/monitor.c b/monitor.c index f0406e8..b6aa2b4 100644 --- a/monitor.c +++ b/monitor.c @@ -55,6 +55,7 @@ #include "json-streamer.h" #include "json-parser.h" #include "osdep.h" +#include "hw/boards.h" //#define DEBUG //#define DEBUG_COMPLETION @@ -2449,6 +2450,14 @@ static const mon_cmd_t info_cmds[] = { .mhandler.info_new = do_info_version, }, { + .name = "machines", + .args_type = "", + .params = "", + .help = "show the machine boards", + .user_print = monitor_user_noop, + .mhandler.info_new = do_info_machines, + }, + { .name = "commands", .args_type = "", .params = "", diff --git a/vl.c b/vl.c index 0b38d62..8043fac 100644 --- a/vl.c +++ b/vl.c @@ -1537,6 +1537,76 @@ static QEMUMachine *find_default_machine(void) return NULL; } + +/** + * do_info_machines(): Show machine boards + * + * Returns a QList object listing all machine boards + * available with this QEMU target. Each element in + * the list is a QDict object containing the following + * keys + * + * - "name": short name for the machine board + * - "description": long description of the board + * - "alias": name of an alias + * + * Example: + * + * [ + * { + * "name": "pc-0.13", + * "description": "Standard PC", + * "default": 0 + * }, + * { + * "name": "pc", + * "description": "Standard PC", + * "canonical": "pc-0.13", + * "default": 1 + * }, + * { + * "name": "pc-0.12", + * "description": "Standard PC", + * "default": 0 + * }, + * .... + * ] + * + */ +/* XXX probably better in a hw/boards.c file, but 'first_machine' + * and all accessors are defined in this file already + */ +void do_info_machines(Monitor *mon, QObject **data) +{ + QList *machines = qlist_new(); + QEMUMachine *m; + + for (m = first_machine; m != NULL; m = m->next) { + QObject *entry; + + entry = qobject_from_jsonf("{ 'name': %s, 'description': %s, 'default': %d}", + m->name, m->desc, + !m->alias && m->is_default ? 1 : 0); + + qlist_append_obj(machines, entry); + + if (m->alias) { + QObject *alias; + + alias = qobject_from_jsonf("{ 'name': %s, 'description': %s, 'default': %d, 'canonical': %s}", + m->alias, m->desc, + m->is_default ? 1 : 0, m->name); + + qlist_append_obj(machines, alias); + } + + /* XXX list the default devices for each machine type here too ? */ + } + + *data = QOBJECT(machines); +} + + /***********************************************************/ /* main execution loop */