mirror of
https://github.com/mii443/qemu.git
synced 2025-12-03 11:08:25 +00:00
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>
This commit is contained in:
committed by
Max Reitz
parent
df373fb0a3
commit
0b6786a9c1
18
qemu-img.c
18
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;
|
||||
|
||||
Reference in New Issue
Block a user