mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-30 13:31:52 -06:00
QemuOpts: Propagate errors through opts_parse()
Since I'm touching qemu_opts_parse() anyway, write a function comment for it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
d93ae3cfb9
commit
4f81273dd9
1 changed files with 20 additions and 9 deletions
|
@ -813,7 +813,7 @@ int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname
|
||||||
}
|
}
|
||||||
|
|
||||||
static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
|
static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
|
||||||
int permit_abbrev, bool defaults)
|
int permit_abbrev, bool defaults, Error **errp)
|
||||||
{
|
{
|
||||||
const char *firstname;
|
const char *firstname;
|
||||||
char value[1024], *id = NULL;
|
char value[1024], *id = NULL;
|
||||||
|
@ -842,17 +842,13 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
|
||||||
assert(!defaults || list->merge_lists);
|
assert(!defaults || list->merge_lists);
|
||||||
opts = qemu_opts_create(list, id, !defaults, &local_err);
|
opts = qemu_opts_create(list, id, !defaults, &local_err);
|
||||||
if (opts == NULL) {
|
if (opts == NULL) {
|
||||||
if (local_err) {
|
error_propagate(errp, local_err);
|
||||||
qerror_report_err(local_err);
|
|
||||||
error_free(local_err);
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
opts_do_parse(opts, params, firstname, defaults, &local_err);
|
opts_do_parse(opts, params, firstname, defaults, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
qerror_report_err(local_err);
|
error_propagate(errp, local_err);
|
||||||
error_free(local_err);
|
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -860,10 +856,25 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
|
||||||
return opts;
|
return opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a QemuOpts in @list and with options parsed from @params.
|
||||||
|
* If @permit_abbrev, the first key=value in @params may omit key=,
|
||||||
|
* and is treated as if key was @list->implied_opt_name.
|
||||||
|
* Report errors with qerror_report_err().
|
||||||
|
* Return the new QemuOpts on success, null pointer on error.
|
||||||
|
*/
|
||||||
QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
|
QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
|
||||||
int permit_abbrev)
|
int permit_abbrev)
|
||||||
{
|
{
|
||||||
return opts_parse(list, params, permit_abbrev, false);
|
Error *err = NULL;
|
||||||
|
QemuOpts *opts;
|
||||||
|
|
||||||
|
opts = opts_parse(list, params, permit_abbrev, false, &err);
|
||||||
|
if (!opts) {
|
||||||
|
qerror_report_err(err);
|
||||||
|
error_free(err);
|
||||||
|
}
|
||||||
|
return opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_opts_set_defaults(QemuOptsList *list, const char *params,
|
void qemu_opts_set_defaults(QemuOptsList *list, const char *params,
|
||||||
|
@ -871,7 +882,7 @@ void qemu_opts_set_defaults(QemuOptsList *list, const char *params,
|
||||||
{
|
{
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
|
|
||||||
opts = opts_parse(list, params, permit_abbrev, true);
|
opts = opts_parse(list, params, permit_abbrev, true, NULL);
|
||||||
assert(opts);
|
assert(opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue