@@ -848,12 +848,11 @@ int qemu_opts_print(QemuOpts *opts, void *dummy)
return 0;
}
-static int opts_do_parse(QemuOpts *opts, const char *params,
- const char *firstname, bool prepend)
+static void opts_do_parse(QemuOpts *opts, const char *params,
+ const char *firstname, bool prepend, Error **errp)
{
char option[128], value[1024];
const char *p,*pe,*pc;
- Error *local_err = NULL;
for (p = params; *p != '\0'; p++) {
pe = strchr(p, '=');
@@ -885,23 +884,29 @@ static int opts_do_parse(QemuOpts *opts, const char *params,
}
if (strcmp(option, "id") != 0) {
/* store and parse */
- opt_set(opts, option, value, prepend, &local_err);
- if (error_is_set(&local_err)) {
- qerror_report_err(local_err);
- error_free(local_err);
- return -1;
+ opt_set(opts, option, value, prepend, errp);
+ if (error_is_set(errp)) {
+ return;
}
}
if (*p != ',') {
break;
}
}
- return 0;
}
int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname)
{
- return opts_do_parse(opts, params, firstname, false);
+ Error *local_err = NULL;
+
+ opts_do_parse(opts, params, firstname, false, &local_err);
+ if (error_is_set(&local_err)) {
+ qerror_report_err(local_err);
+ error_free(local_err);
+ return -1;
+ }
+
+ return 0;
}
static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
@@ -934,18 +939,23 @@ static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
}
if (opts == NULL) {
if (error_is_set(&local_err)) {
- qerror_report_err(local_err);
- error_free(local_err);
+ goto exit_err;
}
return NULL;
}
- if (opts_do_parse(opts, params, firstname, defaults) != 0) {
+ opts_do_parse(opts, params, firstname, defaults, &local_err);
+ if (error_is_set(&local_err)) {
qemu_opts_del(opts);
- return NULL;
+ goto exit_err;
}
return opts;
+
+exit_err:
+ qerror_report_err(local_err);
+ error_free(local_err);
+ return NULL;
}
QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params,
The functions qemu_opts_do_parse() and opts_parse() both call opts_do_parse(), but their callers expect QError semantics. Thus, both functions call qerro_report_err() to keep the expected semantics. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> --- qemu-option.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-)