qemu-option: introduce qemu_find_opts_singleton

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
Paolo Bonzini 2014-03-06 10:39:24 +01:00 committed by Michael Tokarev
parent eb6282f230
commit e96e5ae880
3 changed files with 17 additions and 10 deletions

View File

@ -8,6 +8,8 @@
QemuOptsList *qemu_find_opts(const char *group);
QemuOptsList *qemu_find_opts_err(const char *group, Error **errp);
QemuOpts *qemu_find_opts_singleton(const char *group);
void qemu_add_opts(QemuOptsList *list);
void qemu_add_drive_opts(QemuOptsList *list);
int qemu_set_option(const char *str);

View File

@ -39,6 +39,20 @@ QemuOptsList *qemu_find_opts(const char *group)
return ret;
}
QemuOpts *qemu_find_opts_singleton(const char *group)
{
QemuOptsList *list;
QemuOpts *opts;
list = qemu_find_opts(group);
assert(list);
opts = qemu_opts_find(list, NULL);
if (!opts) {
opts = qemu_opts_create(list, NULL, 0, &error_abort);
}
return opts;
}
static CommandLineParameterInfoList *query_option_descs(const QemuOptDesc *desc)
{
CommandLineParameterInfoList *param_list = NULL, *entry;

11
vl.c
View File

@ -517,16 +517,7 @@ static QemuOptsList qemu_name_opts = {
*/
QemuOpts *qemu_get_machine_opts(void)
{
QemuOptsList *list;
QemuOpts *opts;
list = qemu_find_opts("machine");
assert(list);
opts = qemu_opts_find(list, NULL);
if (!opts) {
opts = qemu_opts_create(list, NULL, 0, &error_abort);
}
return opts;
return qemu_find_opts_singleton("machine");
}
const char *qemu_get_vm_name(void)