qemu-img: Ignore Error objects where the return value suffices

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200707160613.848843-44-armbru@redhat.com>
[One more in img_amend() due to commit 0bc2a50e17 "qemu-option: Use
returned bool to check for failure"]
This commit is contained in:
Markus Armbruster 2020-07-07 18:06:11 +02:00
parent 386f6c07d2
commit 9e194e063f
1 changed files with 3 additions and 12 deletions

View File

@ -465,22 +465,18 @@ static int add_old_style_options(const char *fmt, QemuOpts *opts,
const char *base_filename, const char *base_filename,
const char *base_fmt) const char *base_fmt)
{ {
Error *err = NULL;
if (base_filename) { if (base_filename) {
if (!qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename, if (!qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename,
&err)) { NULL)) {
error_report("Backing file not supported for file format '%s'", error_report("Backing file not supported for file format '%s'",
fmt); fmt);
error_free(err);
return -1; return -1;
} }
} }
if (base_fmt) { if (base_fmt) {
if (!qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt, &err)) { if (!qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt, NULL)) {
error_report("Backing file format not supported for file " error_report("Backing file format not supported for file "
"format '%s'", fmt); "format '%s'", fmt);
error_free(err);
return -1; return -1;
} }
} }
@ -4214,17 +4210,12 @@ static int img_amend(int argc, char **argv)
opts = qemu_opts_create(amend_opts, NULL, 0, &error_abort); opts = qemu_opts_create(amend_opts, NULL, 0, &error_abort);
if (!qemu_opts_do_parse(opts, options, NULL, &err)) { if (!qemu_opts_do_parse(opts, options, NULL, &err)) {
/* Try to parse options using the create options */ /* Try to parse options using the create options */
Error *err1 = NULL;
amend_opts = qemu_opts_append(amend_opts, bs->drv->create_opts); amend_opts = qemu_opts_append(amend_opts, bs->drv->create_opts);
qemu_opts_del(opts); qemu_opts_del(opts);
opts = qemu_opts_create(amend_opts, NULL, 0, &error_abort); opts = qemu_opts_create(amend_opts, NULL, 0, &error_abort);
qemu_opts_do_parse(opts, options, NULL, &err1); if (qemu_opts_do_parse(opts, options, NULL, NULL)) {
if (!err1) {
error_append_hint(&err, error_append_hint(&err,
"This option is only supported for image creation\n"); "This option is only supported for image creation\n");
} else {
error_free(err1);
} }
error_report_err(err); error_report_err(err);