From patchwork Fri Jan 22 16:09:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 43498 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 B3ED4B7CDA for ; Sat, 23 Jan 2010 03:18:09 +1100 (EST) Received: from localhost ([127.0.0.1]:60183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NYMBy-0003hu-60 for incoming@patchwork.ozlabs.org; Fri, 22 Jan 2010 11:17:02 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NYM5m-0001vh-1C for qemu-devel@nongnu.org; Fri, 22 Jan 2010 11:10:38 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NYM5g-0001tF-Ge for qemu-devel@nongnu.org; Fri, 22 Jan 2010 11:10:36 -0500 Received: from [199.232.76.173] (port=60502 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NYM5g-0001t8-42 for qemu-devel@nongnu.org; Fri, 22 Jan 2010 11:10:32 -0500 Received: from e34.co.us.ibm.com ([32.97.110.152]:44534) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NYM5f-0003cZ-Gb for qemu-devel@nongnu.org; Fri, 22 Jan 2010 11:10:31 -0500 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e34.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id o0MG4Pba029689 for ; Fri, 22 Jan 2010 09:04:25 -0700 Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id o0MGA9BZ216650 for ; Fri, 22 Jan 2010 09:10:09 -0700 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o0MG97VZ006360 for ; Fri, 22 Jan 2010 09:09:07 -0700 Received: from localhost.localdomain (sig-9-76-206-57.mts.ibm.com [9.76.206.57]) by d03av05.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o0MG94L4006236; Fri, 22 Jan 2010 09:09:07 -0700 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Fri, 22 Jan 2010 10:09:02 -0600 Message-Id: <1264176542-5316-4-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.6.5.2 In-Reply-To: <1264176542-5316-1-git-send-email-aliguori@us.ibm.com> References: <1264176542-5316-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: John Cooper , Paolo Bonzini , Anthony Liguori , Gerd Hoffman Subject: [Qemu-devel] [PATCH 3/3] Load global config files by default (v2) 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 A new option, -nodefconfig is introduced to prevent loading from the default config location. Otherwise, two configuration files will be searched for, qemu.conf and target-.conf. To ensure that the default configuration is overridden by a user specified config, we introduce a two stage option parsing mechanism. Signed-off-by: Anthony Liguori --- v1->v2 - Introduce two stage option parsing to make sure global config file is overridden by command line options --- qemu-options.hx | 9 +++++++++ vl.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 0 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index ee60d8a..9294e07 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1965,6 +1965,15 @@ STEXI @item -writeconfig @var{file} Write device configuration to @var{file}. ETEXI +DEF("nodefconfig", 0, QEMU_OPTION_nodefconfig, + "-nodefconfig\n" + " do not load default config files at startup\n") +STEXI +@item -nodefconfig +Normally QEMU loads a configuration file from @var{sysconfdir}/qemu.conf and +@var{sysconfdir}/target-@var{ARCH}.conf on startup. The @code{-nodefconfig} +option will prevent QEMU from loading these configuration files at startup. +ETEXI HXCOMM This is the last statement. Insert new options before this line! STEXI diff --git a/vl.c b/vl.c index e00ae0d..a90c330 100644 --- a/vl.c +++ b/vl.c @@ -4730,6 +4730,7 @@ int main(int argc, char **argv, char **envp) #endif CPUState *env; int show_vnc_port = 0; + int defconfig = 1; init_clocks(); @@ -4789,6 +4790,44 @@ int main(int argc, char **argv, char **envp) tb_size = 0; autostart= 1; + /* first pass of option parsing */ + optind = 1; + while (optind < argc) { + if (argv[optind][0] != '-') { + /* disk image */ + continue; + } else { + const QEMUOption *popt; + + popt = lookup_opt(argc, argv, &optarg, &optind); + switch (popt->index) { + case QEMU_OPTION_nodefconfig: + defconfig=0; + break; + } + } + } + + if (defconfig) { + FILE *fp; + fp = fopen(CONFIG_QEMU_SYSCONFDIR "/qemu.conf", "r"); + if (fp) { + if (qemu_config_parse(fp) != 0) { + exit(1); + } + fclose(fp); + } + + fp = fopen(CONFIG_QEMU_SYSCONFDIR "/target-" TARGET_ARCH ".conf", "r"); + if (fp) { + if (qemu_config_parse(fp) != 0) { + exit(1); + } + fclose(fp); + } + } + + /* second pass of option parsing */ optind = 1; for(;;) { if (optind >= argc)