qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/4] Load global config files by default


From: Anthony Liguori
Subject: [Qemu-devel] [PATCH 2/4] Load global config files by default
Date: Thu, 21 Jan 2010 12:48:51 -0600

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 <address@hidden>
---
 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
address@hidden -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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]