@@ -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
@@ -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,
@@ -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;
+}
@@ -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 */
@@ -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);
}
}
Move the list to an array, with a "type" field to identify the config file purpose/type. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- 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(-)