qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>
Subject: [Qemu-devel] [PATCH 3/3] Load global config files by default (v3)
Date: Sun, 24 Jan 2010 08:22:18 -0600	[thread overview]
Message-ID: <1264342938-7363-4-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1264342938-7363-1-git-send-email-aliguori@us.ibm.com>

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-<TARGET_NAME>.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 <aliguori@us.ibm.com>
---
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)
-- 
1.6.5.2

  parent reply	other threads:[~2010-01-24 14:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-24 14:22 [Qemu-devel] [PATCH 0/4] Introduce global config (v3) Anthony Liguori
2010-01-24 14:22 ` [Qemu-devel] [PATCH 1/3] Support --sysconfdir in configure to specify path to configuration files (v3) Anthony Liguori
2010-01-24 14:45   ` [Qemu-devel] " Paolo Bonzini
2010-01-24 15:23     ` Anthony Liguori
2010-01-25 14:43       ` Avi Kivity
2010-01-25 21:05         ` Paolo Bonzini
2010-01-25 21:14           ` Anthony Liguori
2010-01-25 21:19             ` Paolo Bonzini
2010-01-26  8:56           ` Avi Kivity
2010-01-24 14:22 ` [Qemu-devel] [PATCH 2/3] Move out option lookup into a separate function Anthony Liguori
2010-01-24 14:22 ` Anthony Liguori [this message]
2010-01-24 15:00 ` [Qemu-devel] [PATCH 0/4] Introduce global config (v3) Avi Kivity
2010-01-24 15:23   ` Anthony Liguori
2010-01-24 15:04 ` Avi Kivity
2010-01-24 15:10   ` Paolo Bonzini
2010-01-25 11:31     ` Daniel P. Berrange
2010-01-25 13:59       ` Anthony Liguori
2010-01-24 15:25   ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1264342938-7363-4-git-send-email-aliguori@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).