qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: John Cooper <john.cooper@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Gerd Hoffman <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 2/4] Load global config files by default
Date: Thu, 21 Jan 2010 12:48:51 -0600	[thread overview]
Message-ID: <1264099733-29666-3-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1264099733-29666-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.

The ordering is a little troubling.  Command line options are parsed before
loading the default configs which means that the command line configs will be
loaded before the default config.  The effect is that the default config will
override -readconfig directives.

It's unclear the best way to handle this.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 qemu-options.hx |    7 +++++++
 vl.c            |   23 +++++++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index ee60d8a..57f453d 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1965,6 +1965,13 @@ 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 file\n")
+STEXI
+@item -nodefconfig
+Do not load default config files.
+ETEXI
 
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
diff --git a/vl.c b/vl.c
index e070ec9..cf12ab0 100644
--- a/vl.c
+++ b/vl.c
@@ -4690,6 +4690,7 @@ int main(int argc, char **argv, char **envp)
 #endif
     CPUState *env;
     int show_vnc_port = 0;
+    int defconfig = 1;
 
     init_clocks();
 
@@ -5457,6 +5458,9 @@ int main(int argc, char **argv, char **envp)
                     fclose(fp);
                     break;
                 }
+            case QEMU_OPTION_nodefconfig:
+                defconfig=0;
+                break;
             }
         }
     }
@@ -5471,6 +5475,25 @@ int main(int argc, char **argv, char **envp)
         data_dir = CONFIG_QEMU_SHAREDIR;
     }
 
+    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);
+        }
+    }
+
     /*
      * Default to max_cpus = smp_cpus, in case the user doesn't
      * specify a max_cpus value.
-- 
1.6.5.2

  parent reply	other threads:[~2010-01-21 18:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-21 18:48 [Qemu-devel] [PATCH 0/4] Introduce global config and default devices Anthony Liguori
2010-01-21 18:48 ` [Qemu-devel] [PATCH 1/4] Support --confdir in configure to specify path to configuration files Anthony Liguori
2010-01-22 12:43   ` [Qemu-devel] " Paolo Bonzini
2010-01-22 14:39     ` Anthony Liguori
2010-01-21 18:48 ` Anthony Liguori [this message]
2010-01-22 10:33   ` [Qemu-devel] Re: [PATCH 2/4] Load global config files by default Gerd Hoffmann
2010-01-21 18:48 ` [Qemu-devel] [PATCH 3/4] Add -defaults option to allow default devices to be overridden Anthony Liguori
2010-01-22 10:15   ` Markus Armbruster
2010-01-22 15:45     ` Anthony Liguori
2010-01-21 18:48 ` [Qemu-devel] [PATCH 4/4] Allow default network type " Anthony Liguori
2010-01-22 11:00   ` [Qemu-devel] " Gerd Hoffmann
2010-01-22 14:44     ` 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=1264099733-29666-3-git-send-email-aliguori@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=john.cooper@redhat.com \
    --cc=kraxel@redhat.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).