From patchwork Sun Jan 24 14:22:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 43593 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 337C91007D2 for ; Mon, 25 Jan 2010 01:31:08 +1100 (EST) Received: from localhost ([127.0.0.1]:53711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZ3Sw-0003dL-TK for incoming@patchwork.ozlabs.org; Sun, 24 Jan 2010 09:29:26 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZ3MO-0001XW-Nb for qemu-devel@nongnu.org; Sun, 24 Jan 2010 09:22:41 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZ3MK-0001UZ-7V for qemu-devel@nongnu.org; Sun, 24 Jan 2010 09:22:40 -0500 Received: from [199.232.76.173] (port=51940 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZ3MJ-0001UL-IA for qemu-devel@nongnu.org; Sun, 24 Jan 2010 09:22:35 -0500 Received: from e36.co.us.ibm.com ([32.97.110.154]:57415) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NZ3MJ-0008U8-DR for qemu-devel@nongnu.org; Sun, 24 Jan 2010 09:22:35 -0500 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e36.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id o0OEJoON028932 for ; Sun, 24 Jan 2010 07:19:50 -0700 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o0OEMToK162262 for ; Sun, 24 Jan 2010 07:22:29 -0700 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o0OEMTnl028344 for ; Sun, 24 Jan 2010 07:22:29 -0700 Received: from localhost.localdomain (sig-9-65-101-121.mts.ibm.com [9.65.101.121]) by d03av04.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o0OEMOq3028158; Sun, 24 Jan 2010 07:22:28 -0700 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Sun, 24 Jan 2010 08:22:18 -0600 Message-Id: <1264342938-7363-4-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.6.5.2 In-Reply-To: <1264342938-7363-1-git-send-email-aliguori@us.ibm.com> References: <1264342938-7363-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: Anthony Liguori Subject: [Qemu-devel] [PATCH 3/3] Load global config files by default (v3) 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 --- v2->v3 - update to use confdir instead of sysconfdir 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..7fe6a39 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_CONFDIR "/qemu.conf", "r"); + if (fp) { + if (qemu_config_parse(fp) != 0) { + exit(1); + } + fclose(fp); + } + + fp = fopen(CONFIG_QEMU_CONFDIR "/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)