From patchwork Tue Mar 20 08:01:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 147768 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 5322EB6EE7 for ; Tue, 20 Mar 2012 20:08:12 +1100 (EST) Received: from localhost ([::1]:44202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9u23-0000Jo-5J for incoming@patchwork.ozlabs.org; Tue, 20 Mar 2012 04:03:03 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9u1L-0007Yx-SH for qemu-devel@nongnu.org; Tue, 20 Mar 2012 04:02:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S9u0v-0004OL-KZ for qemu-devel@nongnu.org; Tue, 20 Mar 2012 04:02:19 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:53339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9u0v-0004N8-Cb for qemu-devel@nongnu.org; Tue, 20 Mar 2012 04:01:53 -0400 Received: by mail-ee0-f45.google.com with SMTP id t10so3380185eei.4 for ; Tue, 20 Mar 2012 01:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=enb+nT+pmbUj5LvCV/aNlC0KNwcjIv0jJcaA//D+TIU=; b=HdzR4ZEC9BC5aCm/CwziT2A7bEr/NzP9uqfUrOgV4WeeC8BIa+ZeBz53TNUmIGPJyZ VSxTN7b8w+lX8IjAoc5ht8AfuSj4VpEMhnDfo2jUIUK8Vehf8t6uxxwzIRL9woEz74mE xjsq3c+bQry0BMEbshRRLrvxJ65UfQZ2If9ZrHPyqaTMjrJKILNFDfg3j1PX5Ynt57Iq Nnl/Gt+1sZCOSqc5Bo5Why26PB7Wmm/IJZvRYlUd04CHNxxdV8CzXXz+s7V9Ug/LZTl7 n2YhgaKJVrvhhQlZQraolVyvN18AcNbX6HQNnPNA1Jivt5PwnxjWCL5sffKuuxO/iOfp oftA== Received: by 10.14.200.132 with SMTP id z4mr1840814een.122.1332230512453; Tue, 20 Mar 2012 01:01:52 -0700 (PDT) Received: from yakj.lan (93-34-182-16.ip50.fastwebnet.it. [93.34.182.16]) by mx.google.com with ESMTPS id n56sm2565509eeb.4.2012.03.20.01.01.51 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Mar 2012 01:01:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 20 Mar 2012 09:01:33 +0100 Message-Id: <1332230498-20684-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1332230498-20684-1-git-send-email-pbonzini@redhat.com> References: <1332230498-20684-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.83.45 Subject: [Qemu-devel] [PATCH 07/12] cmdline: make -M a simple alias for -machine type 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 machine_parse is still being called from the -M handler. Remove this, and just call machine_parse based on the "-machine type" value. Signed-off-by: Paolo Bonzini --- vl.c | 27 ++++++++++++++------------- 1 files changed, 14 insertions(+), 13 deletions(-) diff --git a/vl.c b/vl.c index 3b9ff31..1fc5044 100644 --- a/vl.c +++ b/vl.c @@ -2274,7 +2274,7 @@ int main(int argc, char **argv, char **envp) int optind; const char *optarg; const char *loadvm = NULL; - QEMUMachine *machine; + QEMUMachine *machine = NULL; const char *cpu_model; const char *vga_model = "none"; const char *pid_file = NULL; @@ -2317,7 +2317,6 @@ int main(int argc, char **argv, char **envp) os_setup_early_signal_handling(); module_call_init(MODULE_INIT_MACHINE); - machine = find_default_machine(); cpu_model = NULL; ram_size = 0; snapshot = 0; @@ -2384,7 +2383,7 @@ int main(int argc, char **argv, char **envp) } switch(popt->index) { case QEMU_OPTION_M: - machine = machine_parse(optarg); + qemu_opts_set(qemu_find_opts("machine"), 0, "type", optarg); break; case QEMU_OPTION_cpu: /* hw initialization will check this */ @@ -2954,10 +2953,6 @@ int main(int argc, char **argv, char **envp) fprintf(stderr, "parse error: %s\n", optarg); exit(1); } - optarg = qemu_opt_get(opts, "type"); - if (optarg) { - machine = machine_parse(optarg); - } break; case QEMU_OPTION_usb: usb_enabled = 1; @@ -3218,11 +3213,19 @@ int main(int argc, char **argv, char **envp) data_dir = CONFIG_QEMU_DATADIR; } - if (machine == NULL) { - fprintf(stderr, "No machine found.\n"); - exit(1); + machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + if (machine_opts) { + optarg = qemu_opt_get(machine_opts, "type"); + if (optarg) { + machine = machine_parse(optarg); + } + } + if (!machine) { + machine = find_default_machine(); } + current_machine = machine; + /* * Default to max_cpus = smp_cpus, in case the user doesn't * specify a max_cpus value. @@ -3312,7 +3315,7 @@ int main(int argc, char **argv, char **envp) exit(1); } - machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + /* Initialize machine options */ bios_name = NULL; kernel_filename = initrd_filename = kernel_cmdline = NULL; ram_size = DEFAULT_RAM_SIZE * 1024 * 1024; @@ -3493,8 +3496,6 @@ int main(int argc, char **argv, char **envp) set_numa_modes(); - current_machine = machine; - /* init USB devices */ if (usb_enabled) { if (foreach_device_config(DEV_USB, usb_parse) < 0)