qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC][PATCH 2/7] qemu-config: Make qemu_config_parse more g


From: Kevin Wolf
Subject: [Qemu-devel] [RFC][PATCH 2/7] qemu-config: Make qemu_config_parse more generic
Date: Mon, 15 Mar 2010 18:08:30 +0100

qemu_config_parse gets the option groups as a parameter now instead of
hardcoding the VM configuration groups. This way it can be used for other
configurations, too.

Signed-off-by: Kevin Wolf <address@hidden>
---
 qemu-config.c |   15 ++++++++-------
 qemu-config.h |    2 +-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/qemu-config.c b/qemu-config.c
index 8166b5e..e121f2a 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -290,7 +290,7 @@ QemuOptsList qemu_cpudef_opts = {
     },
 };
 
-static QemuOptsList *lists[] = {
+static QemuOptsList *vm_config_groups[] = {
     &qemu_drive_opts,
     &qemu_chardev_opts,
     &qemu_device_opts,
@@ -303,7 +303,7 @@ static QemuOptsList *lists[] = {
     NULL,
 };
 
-static QemuOptsList *find_list(const char *group)
+static QemuOptsList *find_list(QemuOptsList **lists, const char *group)
 {
     int i;
 
@@ -330,7 +330,7 @@ int qemu_set_option(const char *str)
         return -1;
     }
 
-    list = find_list(group);
+    list = find_list(vm_config_groups, group);
     if (list == NULL) {
         return -1;
     }
@@ -415,6 +415,7 @@ static int config_write_opts(QemuOpts *opts, void *opaque)
 void qemu_config_write(FILE *fp)
 {
     struct ConfigWriteData data = { .fp = fp };
+    QemuOptsList **lists = vm_config_groups;
     int i;
 
     fprintf(fp, "# qemu config file\n\n");
@@ -424,7 +425,7 @@ void qemu_config_write(FILE *fp)
     }
 }
 
-int qemu_config_parse(FILE *fp)
+int qemu_config_parse(FILE *fp, QemuOptsList **lists)
 {
     char line[1024], group[64], id[64], arg[64], value[1024];
     QemuOptsList *list = NULL;
@@ -441,7 +442,7 @@ int qemu_config_parse(FILE *fp)
         }
         if (sscanf(line, "[%63s \"%63[^\"]\"]", group, id) == 2) {
             /* group with id */
-            list = find_list(group);
+            list = find_list(lists, group);
             if (list == NULL)
                 return -1;
             opts = qemu_opts_create(list, id, 1);
@@ -449,7 +450,7 @@ int qemu_config_parse(FILE *fp)
         }
         if (sscanf(line, "[%63[^]]]", group) == 1) {
             /* group without id */
-            list = find_list(group);
+            list = find_list(lists, group);
             if (list == NULL)
                 return -1;
             opts = qemu_opts_create(list, NULL, 0);
@@ -481,7 +482,7 @@ int qemu_read_config_file(const char *filename)
         return -errno;
     }
 
-    if (qemu_config_parse(f) != 0) {
+    if (qemu_config_parse(f, vm_config_groups) != 0) {
         return -EINVAL;
     }
     fclose(f);
diff --git a/qemu-config.h b/qemu-config.h
index bbe9d41..086aa2a 100644
--- a/qemu-config.h
+++ b/qemu-config.h
@@ -16,7 +16,7 @@ int qemu_global_option(const char *str);
 void qemu_add_globals(void);
 
 void qemu_config_write(FILE *fp);
-int qemu_config_parse(FILE *fp);
+int qemu_config_parse(FILE *fp, QemuOptsList **lists);
 
 int qemu_read_config_file(const char *filename);
 
-- 
1.6.6.1





reply via email to

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