qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
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	[thread overview]
Message-ID: <1332169722-11126-2-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1332169722-11126-1-git-send-email-ehabkost@redhat.com>

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(-)

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

  reply	other threads:[~2012-03-19 15:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-19 15:08 [Qemu-devel] [RFC PATCH 0/3] Move CPU model config file to /usr/share Eduardo Habkost
2012-03-19 15:08 ` Eduardo Habkost [this message]
2012-03-19 15:08 ` [Qemu-devel] [RFC PATCH 2/3] implement -readconfig help=defconfig option Eduardo Habkost
2012-03-19 15:08 ` [Qemu-devel] [RFC PATCH 3/3] move cpudef config sections to /usr/share/qemu/cpudefs-x86_64.conf Eduardo Habkost

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=1332169722-11126-2-git-send-email-ehabkost@redhat.com \
    --to=ehabkost@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).