[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 1/3] move list of default config files to qemu-c
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [RFC PATCH 1/3] move list of default config files to qemu-config-arch.c |
Date: |
Mon, 19 Mar 2012 12:08:40 -0300 |
Move the list to an array, with a "type" field to identify the config
file purpose/type.
Signed-off-by: Eduardo Habkost <address@hidden>
---
arch_init.c | 1 -
arch_init.h | 2 --
qemu-config-arch.c | 36 ++++++++++++++++++++++++++++++++++++
qemu-config-arch.h | 4 ++++
vl.c | 12 +++---------
5 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index a95ef49..56b2147 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -54,7 +54,6 @@ int graphic_height = 600;
int graphic_depth = 15;
#endif
-const char arch_config_name[] = CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH
".conf";
#if defined(TARGET_ALPHA)
#define QEMU_ARCH QEMU_ARCH_ALPHA
diff --git a/arch_init.h b/arch_init.h
index 828256c..c7cb94a 100644
--- a/arch_init.h
+++ b/arch_init.h
@@ -1,8 +1,6 @@
#ifndef QEMU_ARCH_INIT_H
#define QEMU_ARCH_INIT_H
-extern const char arch_config_name[];
-
enum {
QEMU_ARCH_ALL = -1,
QEMU_ARCH_ALPHA = 1,
diff --git a/qemu-config-arch.c b/qemu-config-arch.c
index ee5d515..83a0c89 100644
--- a/qemu-config-arch.c
+++ b/qemu-config-arch.c
@@ -45,6 +45,30 @@ static QemuOptsList qemu_readconfig_opts = {
},
};
+#define MAIN_CONFIG_NAME (CONFIG_QEMU_CONFDIR "/qemu.conf")
+#define ARCH_CONFIG_NAME (CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf")
+
+/* List of default config files
+ */
+struct DefaultConfigFile {
+ /* Identifier to the default config file.
+ */
+ const char *type;
+ /* Config file path
+ */
+ const char *path;
+};
+
+static struct DefaultConfigFile arch_default_configs[] = {
+ /* user-editable config files from /etc: */
+ /* Main, generic config file: */
+ {"main", MAIN_CONFIG_NAME},
+ /* Arch-specific config file: */
+ {"arch", ARCH_CONFIG_NAME},
+
+ /* end of list */
+ {NULL, NULL},
+};
/* Read Qemu config file based on parsed QemuOpts object
*
@@ -84,3 +108,15 @@ int qemu_read_config_arg(const char *arg)
qemu_opts_del(opts);
return r;
}
+
+int qemu_read_default_configs(void)
+{
+ const struct DefaultConfigFile *cfg;
+ for (cfg = arch_default_configs; cfg->path; cfg++) {
+ int ret = qemu_read_config_filename(cfg->path);
+ if (ret < 0 && ret != -ENOENT) {
+ return ret;
+ }
+ }
+ return 0;
+}
diff --git a/qemu-config-arch.h b/qemu-config-arch.h
index 3a9943d..289ea59 100644
--- a/qemu-config-arch.h
+++ b/qemu-config-arch.h
@@ -12,4 +12,8 @@
*/
int qemu_read_config_arg(const char *arg);
+/* Read default config files for the architecture
+ */
+int qemu_read_default_configs(void);
+
#endif /* QEMU_CONFIG_ARCH_H */
diff --git a/vl.c b/vl.c
index 26e6738..2ef172b 100644
--- a/vl.c
+++ b/vl.c
@@ -2350,15 +2350,9 @@ int main(int argc, char **argv, char **envp)
}
if (defconfig) {
- int ret;
-
- ret = qemu_read_config_filename(CONFIG_QEMU_CONFDIR "/qemu.conf");
- if (ret < 0 && ret != -ENOENT) {
- exit(1);
- }
-
- ret = qemu_read_config_filename(arch_config_name);
- if (ret < 0 && ret != -ENOENT) {
+ int ret = qemu_read_default_configs();
+ if (ret < 0) {
+ fprintf(stderr, "error loading default config files: %s",
strerror(ret));
exit(1);
}
}
--
1.7.3.2