@@ -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);
@@ -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);
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 <kwolf@redhat.com> --- qemu-config.c | 15 ++++++++------- qemu-config.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-)