From patchwork Wed Apr 11 21:34: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: 151917 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 CB242B7076 for ; Thu, 12 Apr 2012 08:50:59 +1000 (EST) Received: from localhost ([::1]:44290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SI5Cf-0005mA-Mp for incoming@patchwork.ozlabs.org; Wed, 11 Apr 2012 17:35:49 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SI5Br-0003yc-4P for qemu-devel@nongnu.org; Wed, 11 Apr 2012 17:35:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SI5Bp-000478-2p for qemu-devel@nongnu.org; Wed, 11 Apr 2012 17:34:58 -0400 Received: from mail-wg0-f53.google.com ([74.125.82.53]:48120) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SI5Bo-000420-Q6 for qemu-devel@nongnu.org; Wed, 11 Apr 2012 17:34:57 -0400 Received: by mail-wg0-f53.google.com with SMTP id fm10so1223518wgb.10 for ; Wed, 11 Apr 2012 14:34:55 -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=pTEvlbPosMDRSps2f7c6D+eayR54gcDSgoYceCyfWL0=; b=hxhLKbiRRX8MiCciZRVAkgdINRunxilVvPiqN4FbSrwLRMzXUslnUBu8nsttWsPnFl Azz1qGo6HbpSGxC04GmO47DS/bILJBpi7GiCmTe8PLH7fk23G0QjGKbNr20H2cWzoq+g H8OiPFL7W8C1UlYiptMWtn9Nfsf71LRdKIaF3PjWP3g5/SFS/AbMFB6Z+KyiGMVGwg9m BijGkhxWPEQo+v3SRs2f6zEKBSKQDUTgrnIM+fIhwKC3q9wGigYiPVsKfZAVBiBOe4jN raJ2+Yg30JYxGpsT/DsfEvcngvXukJplDlTp7KQaf4k1e/jH4NrPZFUVT4wN6bkUwnYM zVVQ== Received: by 10.180.107.104 with SMTP id hb8mr94889wib.8.1334180095900; Wed, 11 Apr 2012 14:34:55 -0700 (PDT) Received: from yakj.lan (93-34-182-16.ip50.fastwebnet.it. [93.34.182.16]) by mx.google.com with ESMTPS id ev10sm27383707wid.10.2012.04.11.14.34.54 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Apr 2012 14:34:55 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 11 Apr 2012 23:34:33 +0200 Message-Id: <1334180081-6172-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.9.3 In-Reply-To: <1334180081-6172-1-git-send-email-pbonzini@redhat.com> References: <1334180081-6172-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.82.53 Subject: [Qemu-devel] [PATCH v2 06/14] 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 7f537be..a280c4c 100644 --- a/vl.c +++ b/vl.c @@ -2267,7 +2267,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 = NULL; const char *pid_file = NULL; @@ -2312,7 +2312,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; @@ -2379,7 +2378,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 */ @@ -2948,10 +2947,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; @@ -3213,11 +3208,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. @@ -3307,7 +3310,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; @@ -3492,8 +3495,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)