qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v4 4/4] qemu-img: copy *key-secret opts when ope


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH v4 4/4] qemu-img: copy *key-secret opts when opening newly created files
Date: Thu, 13 Apr 2017 21:54:29 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0

On 12.04.2017 18:44, Daniel P. Berrange wrote:
> The qemu-img dd/convert commands will create a image file and
> then try to open it. Historically it has been possible to open
> new files without passing any options. With encrypted files
> though, the *key-secret options are mandatory, so we need to
> provide those options when opening the newly created file.
> 
> Signed-off-by: Daniel P. Berrange <address@hidden>
> ---
>  qemu-img.c | 41 +++++++++++++++++++++++++++++++++++------
>  1 file changed, 35 insertions(+), 6 deletions(-)

Thanks!

> diff --git a/qemu-img.c b/qemu-img.c
> index 31c4923..3d9e7b3 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c

[...]

> @@ -332,6 +334,33 @@ static BlockBackend *img_open_file(const char *filename,
>  }
>  
>  
> +static int img_add_key_secrets(void *opaque,
> +                               const char *name, const char *value,
> +                               Error **errp)
> +{
> +    QDict *options = opaque;
> +
> +    if (g_str_has_suffix(name, "key-secret")) {
> +        qdict_put(options, name, qstring_from_str(value));
> +    }
> +
> +    return 0;
> +}
> +
> +static BlockBackend *img_open_new_file(const char *filename,
> +                                       QemuOpts *create_opts,
> +                                       const char *fmt, int flags,
> +                                       bool writethrough, bool quiet)
> +{
> +    QDict *options = NULL;
> +
> +    options = qdict_new();
> +    qemu_opt_foreach(create_opts, img_add_key_secrets, options, NULL);

I'd prefer &error_abort instead of NULL there. Not a hard requirement,
but I don't see a reason not to use it.

Max

> +
> +    return img_open_file(filename, options, fmt, flags, writethrough, quiet);
> +}
> +
> +
>  static BlockBackend *img_open(bool image_opts,
>                                const char *filename,
>                                const char *fmt, int flags, bool writethrough,
> @@ -351,7 +380,7 @@ static BlockBackend *img_open(bool image_opts,
[...]

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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