On 04/12/2017 11:44 AM, 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 > --- > qemu-img.c | 41 +++++++++++++++++++++++++++++++++++------ > 1 file changed, 35 insertions(+), 6 deletions(-) Reviewed-by: Eric Blake > @@ -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)); If my patch to add qdict_put_str() lands (probably through Markus' qapi-next tree) before yours, you can simplify this line. If yours lands first, we just rerun my Coccinelle script to simplify it as part of my patch. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org