mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
block/amend: separate amend and create options for qemu-img
Some options are only useful for creation (or hard to be amended, like cluster size for qcow2), while some other options are only useful for amend, like upcoming keyslot management options for luks Since currently only qcow2 supports amend, move all its options to a common macro and then include it in each action option list. In future it might be useful to remove some options which are not supported anyway from amend list, which currently cause an error message if amended. Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200608094030.670121-5-mlevitsk@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
a3579bfa0a
commit
df373fb0a3
3 changed files with 107 additions and 88 deletions
18
qemu-img.c
18
qemu-img.c
|
@ -4068,11 +4068,11 @@ static int print_amend_option_help(const char *format)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Every driver supporting amendment must have create_opts */
|
||||
assert(drv->create_opts);
|
||||
/* Every driver supporting amendment must have amend_opts */
|
||||
assert(drv->amend_opts);
|
||||
|
||||
printf("Creation options for '%s':\n", format);
|
||||
qemu_opts_print_help(drv->create_opts, false);
|
||||
qemu_opts_print_help(drv->amend_opts, false);
|
||||
printf("\nNote that not all of these options may be amendable.\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -4082,7 +4082,7 @@ static int img_amend(int argc, char **argv)
|
|||
Error *err = NULL;
|
||||
int c, ret = 0;
|
||||
char *options = NULL;
|
||||
QemuOptsList *create_opts = NULL;
|
||||
QemuOptsList *amend_opts = NULL;
|
||||
QemuOpts *opts = NULL;
|
||||
const char *fmt = NULL, *filename, *cache;
|
||||
int flags;
|
||||
|
@ -4213,11 +4213,11 @@ static int img_amend(int argc, char **argv)
|
|||
goto out;
|
||||
}
|
||||
|
||||
/* Every driver supporting amendment must have create_opts */
|
||||
assert(bs->drv->create_opts);
|
||||
/* Every driver supporting amendment must have amend_opts */
|
||||
assert(bs->drv->amend_opts);
|
||||
|
||||
create_opts = qemu_opts_append(create_opts, bs->drv->create_opts);
|
||||
opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
|
||||
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) {
|
||||
error_report_err(err);
|
||||
|
@ -4240,7 +4240,7 @@ out:
|
|||
out_no_progress:
|
||||
blk_unref(blk);
|
||||
qemu_opts_del(opts);
|
||||
qemu_opts_free(create_opts);
|
||||
qemu_opts_free(amend_opts);
|
||||
g_free(options);
|
||||
|
||||
if (ret) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue