[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v6 05/14] block/amend: refactor qcow2 amend options
From: |
Max Reitz |
Subject: |
Re: [PATCH v6 05/14] block/amend: refactor qcow2 amend options |
Date: |
Thu, 14 May 2020 15:36:06 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
On 10.05.20 15:40, Maxim Levitsky wrote:
> 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 <address@hidden>
> Reviewed-by: Daniel P. Berrangé <address@hidden>
> ---
> block/qcow2.c | 108 ++++++---------------
> qemu-img.c | 18 +++-
> tests/qemu-iotests/049.out | 102 ++++++++++----------
> tests/qemu-iotests/061.out | 12 ++-
> tests/qemu-iotests/079.out | 18 ++--
> tests/qemu-iotests/082.out | 149 ++++------------------------
> tests/qemu-iotests/085.out | 38 ++++----
> tests/qemu-iotests/087.out | 6 +-
> tests/qemu-iotests/115.out | 2 +-
> tests/qemu-iotests/121.out | 4 +-
> tests/qemu-iotests/125.out | 192 ++++++++++++++++++-------------------
> tests/qemu-iotests/134.out | 2 +-
> tests/qemu-iotests/144.out | 4 +-
> tests/qemu-iotests/158.out | 4 +-
> tests/qemu-iotests/182.out | 2 +-
> tests/qemu-iotests/185.out | 8 +-
> tests/qemu-iotests/188.out | 2 +-
> tests/qemu-iotests/189.out | 4 +-
> tests/qemu-iotests/198.out | 4 +-
> tests/qemu-iotests/243.out | 16 ++--
> tests/qemu-iotests/250.out | 2 +-
> tests/qemu-iotests/255.out | 8 +-
> tests/qemu-iotests/259.out | 2 +-
> tests/qemu-iotests/263.out | 4 +-
> tests/qemu-iotests/280.out | 2 +-
These reference output hunks need some rebasing due to the new
compression_type option.
> 25 files changed, 284 insertions(+), 429 deletions(-)
>
> diff --git a/block/qcow2.c b/block/qcow2.c
> index fc494c7591..db86500839 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
[...]
> @@ -5552,37 +5506,6 @@ void qcow2_signal_corruption(BlockDriverState *bs,
> bool fatal, int64_t offset,
> .help = "The external data file must stay valid " \
> "as a raw image" \
> }, \
> - { \
> - .name = BLOCK_OPT_ENCRYPT, \
> - .type = QEMU_OPT_BOOL, \
> - .help = "Encrypt the image with format 'aes'. (Deprecated " \
> - "in favor of " BLOCK_OPT_ENCRYPT_FORMAT "=aes)", \
> - }, \
> - { \
> - .name = BLOCK_OPT_ENCRYPT_FORMAT, \
> - .type = QEMU_OPT_STRING, \
> - .help = "Encrypt the image, format choices: 'aes', 'luks'", \
> - }, \
> - BLOCK_CRYPTO_OPT_DEF_KEY_SECRET("encrypt.", \
> - "ID of secret providing qcow AES key or LUKS passphrase"), \
> - BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_ALG("encrypt."), \
> - BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_MODE("encrypt."), \
> - BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_ALG("encrypt."), \
> - BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_HASH_ALG("encrypt."), \
> - BLOCK_CRYPTO_OPT_DEF_LUKS_HASH_ALG("encrypt."), \
> - BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME("encrypt."), \
> - { \
> - .name = BLOCK_OPT_CLUSTER_SIZE, \
> - .type = QEMU_OPT_SIZE, \
> - .help = "qcow2 cluster size", \
> - .def_value_str = stringify(DEFAULT_CLUSTER_SIZE) \
> - }, \
> - { \
> - .name = BLOCK_OPT_PREALLOC, \
> - .type = QEMU_OPT_STRING, \
> - .help = "Preallocation mode (allowed values: off, " \
> - "metadata, falloc, full)" \
> - }, \
> { \
> .name = BLOCK_OPT_LAZY_REFCOUNTS, \
> .type = QEMU_OPT_BOOL, \
> @@ -5600,6 +5523,37 @@ static QemuOptsList qcow2_create_opts = {
> .name = "qcow2-create-opts",
> .head = QTAILQ_HEAD_INITIALIZER(qcow2_create_opts.head),
> .desc = {
> + { \
> + .name = BLOCK_OPT_ENCRYPT, \
> + .type = QEMU_OPT_BOOL, \
> + .help = "Encrypt the image with format 'aes'. (Deprecated " \
> + "in favor of " BLOCK_OPT_ENCRYPT_FORMAT "=aes)", \
> + }, \
> + { \
> + .name = BLOCK_OPT_ENCRYPT_FORMAT, \
> + .type = QEMU_OPT_STRING, \
> + .help = "Encrypt the image, format choices: 'aes', 'luks'", \
> + }, \
> + BLOCK_CRYPTO_OPT_DEF_KEY_SECRET("encrypt.", \
> + "ID of secret providing qcow AES key or LUKS passphrase"), \
> + BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_ALG("encrypt."), \
> + BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_MODE("encrypt."), \
> + BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_ALG("encrypt."), \
> + BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_HASH_ALG("encrypt."), \
> + BLOCK_CRYPTO_OPT_DEF_LUKS_HASH_ALG("encrypt."), \
> + BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME("encrypt."), \
> + { \
> + .name = BLOCK_OPT_CLUSTER_SIZE, \
> + .type = QEMU_OPT_SIZE, \
> + .help = "qcow2 cluster size", \
> + .def_value_str = stringify(DEFAULT_CLUSTER_SIZE) \
> + }, \
> + { \
> + .name = BLOCK_OPT_PREALLOC, \
> + .type = QEMU_OPT_STRING, \
> + .help = "Preallocation mode (allowed values: off, " \
> + "metadata, falloc, full)" \
> + }, \
compression_type should now be moved as well.
> QCOW_COMMON_OPTIONS,
> { /* end of list */ }
> }
> diff --git a/qemu-img.c b/qemu-img.c
> index 8f69366f03..b291081249 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -3939,9 +3939,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;
Hm, this hunk would make more sense in the previous patch, but in
practice it’s better here, because it’s only in this patch that
amend_opts is actually limited (compared to create_opts).
> }
>
> @@ -4087,7 +4086,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*/
Missing a space before the closing asterisk.
> + 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);
> + }
I’m not sure whether this is really that helpful, but, well, why not,
now that you’ve already written the code for it.
Max
> +
> error_report_err(err);
> ret = -1;
> goto out
signature.asc
Description: OpenPGP digital signature
[PATCH v6 05/14] block/amend: refactor qcow2 amend options, Maxim Levitsky, 2020/05/10
- Re: [PATCH v6 05/14] block/amend: refactor qcow2 amend options,
Max Reitz <=
[PATCH v6 08/14] block/qcow2: extend qemu-img amend interface with crypto options, Maxim Levitsky, 2020/05/10
[PATCH v6 09/14] iotests: filter few more luks specific create options, Maxim Levitsky, 2020/05/10
[PATCH v6 10/14] iotests: qemu-img tests for luks key management, Maxim Levitsky, 2020/05/10
[PATCH v6 07/14] block/crypto: implement the encryption key management, Maxim Levitsky, 2020/05/10