QemuOpts: allow new option groups be registered at runtime.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
diff --git a/qemu-config.c b/qemu-config.c
index 730ffd9..e84e15e 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -340,7 +340,7 @@
},
};
-static QemuOptsList *vm_config_groups[] = {
+static QemuOptsList *vm_config_groups[32] = {
&qemu_drive_opts,
&qemu_chardev_opts,
&qemu_device_opts,
@@ -372,6 +372,22 @@
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_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);