From patchwork Wed May 25 07:03:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 97354 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D72B9B6F97 for ; Thu, 26 May 2011 00:29:34 +1000 (EST) Received: from localhost ([::1]:52430 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPF5X-0002dU-KE for incoming@patchwork.ozlabs.org; Wed, 25 May 2011 10:29:31 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPF5O-0002Y5-7Z for qemu-devel@nongnu.org; Wed, 25 May 2011 10:29:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QPF5M-0007qE-PI for qemu-devel@nongnu.org; Wed, 25 May 2011 10:29:22 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:33766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPF5M-0007pO-3t for qemu-devel@nongnu.org; Wed, 25 May 2011 10:29:20 -0400 Received: from smtp02.web.de ( [172.20.0.184]) by fmmailgate01.web.de (Postfix) with ESMTP id 4438818F7CDAB; Wed, 25 May 2011 09:03:27 +0200 (CEST) Received: from [92.75.135.18] (helo=mchn199C.mchp.siemens.de) by smtp02.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1QP87r-0000Ii-00; Wed, 25 May 2011 09:03:27 +0200 Message-ID: <4DDCA9BE.1050801@web.de> Date: Wed, 25 May 2011 09:03:26 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Anthony Liguori , qemu-devel References: <4DD64E1F.8020603@siemens.com> <4DD8ECB0.9050803@web.de> <1306253200.20576.186.camel@zakaz.uk.xensource.com> <4DDBDA51.7010104@siemens.com> In-Reply-To: <4DDBDA51.7010104@siemens.com> X-Enigmail-Version: 1.1.2 X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX19vjjuHzZnTaju/H5nEoOiinluuNFNtNOEP/SSz R36F6f4f82fCW1sZymUaaZZy0jMLwpz/pph4fWLG3+iXtmTyle CkJsJmG7I= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.221 Cc: Anthony PERARD , Ian Campbell Subject: [Qemu-devel] [PATCH v3 1/2] Generalize -machine command line option 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: Jan Kiszka -machine somehow suggests that it selects the machine, but it doesn't. Fix that before this command is set in stone. Actually, -machine should supersede -M and allow to introduce arbitrary per-machine options to the command line. That will change the internal realization again, but we will be able to keep the user interface stable. CC: Anthony PERARD CC: Ian Campbell Signed-off-by: Jan Kiszka Tested-by: Ian Campbell --- Changes in v3: - fix regression of default machine options handling, -machine xenfv selects accel=xen again (I really hope we can clean up the defaults, make them more generally useful when switching to some QCFG.) Changes in v2: - fix regression of -M my factoring out machine_parse and using it for both old and new command. qemu-config.c | 5 +++++ qemu-options.hx | 20 +++++++++++++++----- vl.c | 43 ++++++++++++++++++++++++++----------------- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/qemu-config.c b/qemu-config.c index 5d7ffa2..01751b4 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -452,9 +452,14 @@ QemuOptsList qemu_option_rom_opts = { static QemuOptsList qemu_machine_opts = { .name = "machine", + .implied_opt_name = "type", .head = QTAILQ_HEAD_INITIALIZER(qemu_machine_opts.head), .desc = { { + .name = "type", + .type = QEMU_OPT_STRING, + .help = "emulated machine" + }, { .name = "accel", .type = QEMU_OPT_STRING, .help = "accelerator list", diff --git a/qemu-options.hx b/qemu-options.hx index 82e085a..0dbc028 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2033,13 +2033,23 @@ if KVM support is enabled when compiling. ETEXI DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ - "-machine accel=accel1[:accel2] use an accelerator (kvm,xen,tcg), default is tcg\n", QEMU_ARCH_ALL) + "-machine [type=]name[,prop[=value][,...]]\n" + " selects emulated machine (-machine ? for list)\n" + " property accel=accel1[:accel2[:...]] selects accelerator\n" + " supported accelerators are kvm, xen, tcg (default: tcg)\n", + QEMU_ARCH_ALL) STEXI -@item -machine accel=@var{accels} +@item -machine [type=]@var{name}[,prop=@var{value}[,...]] @findex -machine -This is use to enable an accelerator, in kvm,xen,tcg. -By default, it use only tcg. If there a more than one accelerator -specified, the next one is used if the first don't work. +Select the emulated machine by @var{name}. Use @code{-machine ?} to list +available machines. Supported machine properties are: +@table @option +@item accel=@var{accels1}[:@var{accels2}[:...]] +This is used to enable an accelerator. Depending on the target architecture, +kvm, xen, or tcg can be available. By default, tcg is used. If there is more +than one accelerator specified, the next one is used if the previous one fails +to initialize. +@end table ETEXI DEF("xen-domid", HAS_ARG, QEMU_OPTION_xen_domid, diff --git a/vl.c b/vl.c index b362871..1865a8d 100644 --- a/vl.c +++ b/vl.c @@ -1891,6 +1891,27 @@ static int debugcon_parse(const char *devname) return 0; } +static QEMUMachine *machine_parse(const char *name) +{ + QEMUMachine *m, *machine = NULL; + + if (name) { + machine = find_machine(name); + } + if (machine) { + return machine; + } + printf("Supported machines are:\n"); + for (m = first_machine; m != NULL; m = m->next) { + if (m->alias) { + printf("%-10s %s (alias of %s)\n", m->alias, m->desc, m->name); + } + printf("%-10s %s%s\n", m->name, m->desc, + m->is_default ? " (default)" : ""); + } + exit(!name || *name != '?'); +} + static int tcg_init(void) { return 0; @@ -2144,20 +2165,7 @@ int main(int argc, char **argv, char **envp) } switch(popt->index) { case QEMU_OPTION_M: - machine = find_machine(optarg); - if (!machine) { - QEMUMachine *m; - printf("Supported machines are:\n"); - for(m = first_machine; m != NULL; m = m->next) { - if (m->alias) - printf("%-10s %s (alias of %s)\n", - m->alias, m->desc, m->name); - printf("%-10s %s%s\n", - m->name, m->desc, - m->is_default ? " (default)" : ""); - } - exit(*optarg != '?'); - } + machine = machine_parse(optarg); break; case QEMU_OPTION_cpu: /* hw initialization will check this */ @@ -2675,11 +2683,12 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_machine: olist = qemu_find_opts("machine"); qemu_opts_reset(olist); - opts = qemu_opts_parse(olist, optarg, 0); + opts = qemu_opts_parse(olist, optarg, 1); if (!opts) { fprintf(stderr, "parse error: %s\n", optarg); exit(1); } + machine = machine_parse(qemu_opt_get(opts, "type")); break; case QEMU_OPTION_usb: usb_enabled = 1; @@ -2941,8 +2950,8 @@ int main(int argc, char **argv, char **envp) p = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel"); } if (p == NULL) { - opts = qemu_opts_parse(qemu_find_opts("machine"), - machine->default_machine_opts, 0); + qemu_opts_reset(list); + opts = qemu_opts_parse(list, machine->default_machine_opts, 0); if (!opts) { fprintf(stderr, "parse error for machine %s: %s\n", machine->name, machine->default_machine_opts);