mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
qom: Add user_creatable_parse_str()
The system emulator has a more complicated way of handling command line options in that it reorders options before it processes them. This means that parsing object options and creating the object happen at two different points. Split the parsing part into a separate function that can be reused by the system emulator command line. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
da0a932bbf
commit
ddf6dae7e3
2 changed files with 29 additions and 6 deletions
|
@ -293,7 +293,7 @@ static void user_creatable_print_help_from_qdict(QDict *args)
|
|||
}
|
||||
}
|
||||
|
||||
bool user_creatable_add_from_str(const char *optarg, Error **errp)
|
||||
ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp)
|
||||
{
|
||||
ERRP_GUARD();
|
||||
QDict *args;
|
||||
|
@ -303,12 +303,12 @@ bool user_creatable_add_from_str(const char *optarg, Error **errp)
|
|||
|
||||
args = keyval_parse(optarg, "qom-type", &help, errp);
|
||||
if (*errp) {
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
if (help) {
|
||||
user_creatable_print_help_from_qdict(args);
|
||||
qobject_unref(args);
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
v = qobject_input_visitor_new_keyval(QOBJECT(args));
|
||||
|
@ -316,12 +316,20 @@ bool user_creatable_add_from_str(const char *optarg, Error **errp)
|
|||
visit_free(v);
|
||||
qobject_unref(args);
|
||||
|
||||
if (*errp) {
|
||||
goto out;
|
||||
return options;
|
||||
}
|
||||
|
||||
bool user_creatable_add_from_str(const char *optarg, Error **errp)
|
||||
{
|
||||
ERRP_GUARD();
|
||||
ObjectOptions *options;
|
||||
|
||||
options = user_creatable_parse_str(optarg, errp);
|
||||
if (!options) {
|
||||
return false;
|
||||
}
|
||||
|
||||
user_creatable_add_qapi(options, errp);
|
||||
out:
|
||||
qapi_free_ObjectOptions(options);
|
||||
return !*errp;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue