vl: introduce machine_merge_property
It will be used to parse smp-opts config groups from configuration files. The point to note is that it does not steal a reference from the caller. This is better because this function will be called from qemu_config_foreach's callback; qemu_config_foreach does not cede its reference to the qdict to the callback, and wants to free it. To balance that extra reference, machine_parse_property_opt now needs a qobject_unref. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
7742fe64e5
commit
a3c2f12830
25
softmmu/vl.c
25
softmmu/vl.c
@ -1534,23 +1534,36 @@ static void machine_help_func(const QDict *qdict)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
machine_merge_property(const char *propname, QDict *prop, Error **errp)
|
||||||
|
{
|
||||||
|
QDict *opts;
|
||||||
|
|
||||||
|
opts = qdict_new();
|
||||||
|
/* Preserve the caller's reference to prop. */
|
||||||
|
qobject_ref(prop);
|
||||||
|
qdict_put(opts, propname, prop);
|
||||||
|
keyval_merge(machine_opts_dict, opts, errp);
|
||||||
|
qobject_unref(opts);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
machine_parse_property_opt(QemuOptsList *opts_list, const char *propname,
|
machine_parse_property_opt(QemuOptsList *opts_list, const char *propname,
|
||||||
const char *arg, Error **errp)
|
const char *arg, Error **errp)
|
||||||
{
|
{
|
||||||
QDict *opts, *prop;
|
QDict *prop = NULL;
|
||||||
bool help = false;
|
bool help = false;
|
||||||
ERRP_GUARD();
|
|
||||||
|
|
||||||
prop = keyval_parse(arg, opts_list->implied_opt_name, &help, errp);
|
prop = keyval_parse(arg, opts_list->implied_opt_name, &help, errp);
|
||||||
if (help) {
|
if (help) {
|
||||||
qemu_opts_print_help(opts_list, true);
|
qemu_opts_print_help(opts_list, true);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
opts = qdict_new();
|
if (!prop) {
|
||||||
qdict_put(opts, propname, prop);
|
return;
|
||||||
keyval_merge(machine_opts_dict, opts, errp);
|
}
|
||||||
qobject_unref(opts);
|
machine_merge_property(propname, prop, errp);
|
||||||
|
qobject_unref(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *pid_file;
|
static const char *pid_file;
|
||||||
|
Loading…
Reference in New Issue
Block a user