Patchwork [1/3] QemuOpts: allow new option groups be registered at runtime.

login
register
mail settings
Submitter Gerd Hoffmann
Date Aug. 20, 2010, 11:52 a.m.
Message ID <1282305122-29097-2-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/62268/
State New
Headers show

Comments

Gerd Hoffmann - Aug. 20, 2010, 11:52 a.m.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 qemu-config.c |   18 +++++++++++++++++-
 qemu-config.h |    1 +
 2 files changed, 18 insertions(+), 1 deletions(-)

Patch

diff --git a/qemu-config.c b/qemu-config.c
index 95abe61..68880c2 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -342,7 +342,7 @@  QemuOptsList qemu_cpudef_opts = {
     },
 };
 
-static QemuOptsList *vm_config_groups[] = {
+static QemuOptsList *vm_config_groups[32] = {
     &qemu_drive_opts,
     &qemu_chardev_opts,
     &qemu_device_opts,
@@ -374,6 +374,22 @@  QemuOptsList *qemu_find_opts(const char *group)
     return find_list(vm_config_groups, group);
 }
 
+void qemu_add_opts(QemuOptsList *list)
+{
+    int entries, i;
+
+    entries = ARRAY_SIZE(vm_config_groups);
+    entries--; /* keep list NULL terminated */
+    for (i = 0; i < entries; i++) {
+        if (vm_config_groups[i] == NULL) {
+            vm_config_groups[i] = list;
+            return;
+        }
+    }
+    fprintf(stderr, "ran out of space in vm_config_groups");
+    abort();
+}
+
 int qemu_set_option(const char *str)
 {
     char group[64], id[64], arg[64];
diff --git a/qemu-config.h b/qemu-config.h
index dca69d4..bf9bcc2 100644
--- a/qemu-config.h
+++ b/qemu-config.h
@@ -16,6 +16,7 @@  extern QemuOptsList qemu_mon_opts;
 extern QemuOptsList qemu_cpudef_opts;
 
 QemuOptsList *qemu_find_opts(const char *group);
+void qemu_add_opts(QemuOptsList *list);
 int qemu_set_option(const char *str);
 int qemu_global_option(const char *str);
 void qemu_add_globals(void);