From patchwork Fri Feb 19 13:27:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 8361051 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9CE269F372 for ; Fri, 19 Feb 2016 13:28:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 042A12041E for ; Fri, 19 Feb 2016 13:28:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 49F8E20382 for ; Fri, 19 Feb 2016 13:28:09 +0000 (UTC) Received: from localhost ([::1]:52281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWl6O-0004qr-JL for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Feb 2016 08:28:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWl6C-0004qR-1r for qemu-devel@nongnu.org; Fri, 19 Feb 2016 08:27:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWl6A-0000IA-IS for qemu-devel@nongnu.org; Fri, 19 Feb 2016 08:27:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43610) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWl6A-0000Hz-Cv for qemu-devel@nongnu.org; Fri, 19 Feb 2016 08:27:54 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 15DAF7EBA0 for ; Fri, 19 Feb 2016 13:27:54 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-67.ams2.redhat.com [10.36.116.67]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1JDRq1x011257 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 19 Feb 2016 08:27:53 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1FE063003848; Fri, 19 Feb 2016 14:27:50 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 19 Feb 2016 14:27:49 +0100 Message-Id: <1455888469-3206-6-git-send-email-armbru@redhat.com> In-Reply-To: <1455888469-3206-1-git-send-email-armbru@redhat.com> References: <1455888469-3206-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/5] vl: Clean up machine selection in main(). 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We set machine_class to the default first, and update it to the real one later. Any use of machine_class in between is almost certainly wrong (there are no such uses right now). Set it once and for all instead. Signed-off-by: Markus Armbruster Reviewed-by: Laszlo Ersek Reviewed-by: Marcel Apfelbaum --- vl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vl.c b/vl.c index 8c1a1ff..b87e292 100644 --- a/vl.c +++ b/vl.c @@ -2762,8 +2762,9 @@ static const QEMUOption *lookup_opt(int argc, char **argv, return popt; } -static void set_machine_options(MachineClass **machine_class) +static MachineClass *select_machine(void) { + MachineClass *machine_class = find_default_machine(); const char *optarg; QemuOpts *opts; Location loc; @@ -2775,16 +2776,17 @@ static void set_machine_options(MachineClass **machine_class) optarg = qemu_opt_get(opts, "type"); if (optarg) { - *machine_class = machine_parse(optarg); + machine_class = machine_parse(optarg); } - if (*machine_class == NULL) { + if (!machine_class) { error_report("No machine specified, and there is no default"); error_printf("Use -machine help to list supported machines\n"); exit(1); } loc_pop(&loc); + return machine_class; } static int machine_set_property(void *opaque, @@ -3031,7 +3033,6 @@ int main(int argc, char **argv, char **envp) os_setup_early_signal_handling(); module_call_init(MODULE_INIT_MACHINE); - machine_class = find_default_machine(); cpu_model = NULL; snapshot = 0; cyls = heads = secs = 0; @@ -4022,7 +4023,7 @@ int main(int argc, char **argv, char **envp) replay_configure(icount_opts); - set_machine_options(&machine_class); + machine_class = select_machine(); set_memory_options(&ram_slots, &maxram_size, machine_class);