summaryrefslogtreecommitdiffstats
path: root/vl.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2010-01-21 10:57:58 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2010-01-24 09:37:26 -0600
commit292444cb87f3b883146ee30628a5922b1cde4073 (patch)
tree0d44e6ecf5d6229ffc0e0f1131ab42c58912d673 /vl.c
parent6530a97bdde4504e6658e5017b5b0ab22e1e62d3 (diff)
downloadhqemu-292444cb87f3b883146ee30628a5922b1cde4073.zip
hqemu-292444cb87f3b883146ee30628a5922b1cde4073.tar.gz
Load global config files by default
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>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c39
1 files changed, 39 insertions, 0 deletions
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)
OpenPOWER on IntegriCloud