qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v6 05/14] block/amend: refactor qcow2 amend options


From: Maxim Levitsky
Subject: Re: [PATCH v6 05/14] block/amend: refactor qcow2 amend options
Date: Sun, 17 May 2020 20:52:58 +0300

On Thu, 2020-05-14 at 15:36 +0200, Max Reitz wrote:
> 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.
Done. I so hope to get it merged so I won't need to rebase it again :-)

> 
> >  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.
Done

> 
> >          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).
Agree. I can move this here, but I also agree that it doesn't matter.

> 
> >  }
> >  
> > @@ -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.
Fixed
> 
> > +        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.
Yep. It still better that nothing.

> 
> Max
> 
> > +
> >          error_report_err(err);
> >          ret = -1;
> >          goto out
> 
> 

Best regards,
        Maxim Levitsky





reply via email to

[Prev in Thread] Current Thread [Next in Thread]