summaryrefslogtreecommitdiff
path: root/qemu-img.c
diff options
context:
space:
mode:
authorMaxim Levitsky <mlevitsk@redhat.com>2020-06-25 14:55:40 +0200
committerMax Reitz <mreitz@redhat.com>2020-07-06 08:49:28 +0200
commit0b6786a9c1539c9bdacee71e09534e0bf972d865 (patch)
tree198863b5cc2f9aba3aa6ab275d9d73eecf6f9879 /qemu-img.c
parentdf373fb0a3a26c2b1b92d27c91bea22a0f5b598d (diff)
downloadqemu-0b6786a9c1539c9bdacee71e09534e0bf972d865.zip
block/amend: refactor qcow2 amend options
Some qcow2 create options can't be used for amend. Remove them from the qcow2 create options and add generic logic to detect such options in qemu-img Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> [mreitz: Dropped some iotests reference output hunks that became unnecessary thanks to "iotests: Make _filter_img_create more active"] Signed-off-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200625125548.870061-12-mreitz@redhat.com>
Diffstat (limited to 'qemu-img.c')
-rw-r--r--qemu-img.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/qemu-img.c b/qemu-img.c
index 1a0a85089b..7f4938a5ef 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -4071,9 +4071,8 @@ static int print_amend_option_help(const char *format)
/* Every driver supporting amendment must have amend_opts */
assert(drv->amend_opts);
- printf("Creation options for '%s':\n", format);
+ printf("Amend options for '%s':\n", format);
qemu_opts_print_help(drv->amend_opts, false);
- printf("\nNote that not all of these options may be amendable.\n");
return 0;
}
@@ -4219,7 +4218,22 @@ static int img_amend(int argc, char **argv)
amend_opts = qemu_opts_append(amend_opts, bs->drv->amend_opts);
opts = qemu_opts_create(amend_opts, NULL, 0, &error_abort);
qemu_opts_do_parse(opts, options, NULL, &err);
+
if (err) {
+ /* Try to parse options using the create options */
+ Error *err1 = NULL;
+ amend_opts = qemu_opts_append(amend_opts, bs->drv->create_opts);
+ qemu_opts_del(opts);
+ opts = qemu_opts_create(amend_opts, NULL, 0, &error_abort);
+ qemu_opts_do_parse(opts, options, NULL, &err1);
+
+ if (!err1) {
+ error_append_hint(&err,
+ "This option is only supported for image creation\n");
+ } else {
+ error_free(err1);
+ }
+
error_report_err(err);
ret = -1;
goto out;