[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 19/97] qemu-img: fix regression copying secrets dur
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 19/97] qemu-img: fix regression copying secrets during convert |
Date: |
Mon, 1 Apr 2019 15:58:53 -0500 |
From: Daniel P. Berrangé <address@hidden>
When the convert command is creating an output file that needs
secrets, we need to ensure those secrets are passed to both the
blk_new_open and bdrv_create API calls.
This is done by qemu-img extracting all opts matching the name
suffix "key-secret". Unfortunately the code doing this was run after the
call to bdrv_create(), which meant the QemuOpts it was extracting
secrets from was now empty.
Previously this worked by luks as a bug meant the "key-secret"
parameters were not purged from the QemuOpts. This bug was fixed in
commit b76b4f604521e59f857d6177bc55f6f2e41fd392
Author: Kevin Wolf <address@hidden>
Date: Thu Jan 11 16:18:08 2018 +0100
qcow2: Use visitor for options in qcow2_create()
Exposing the latent bug in qemu-img. This fix simply moves the copying
of secrets to before the bdrv_create() call.
Cc: address@hidden
Signed-off-by: Daniel P. Berrangé <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
(cherry picked from commit 8d65a3ccfd5db7f0436e095cd952f5d0c3a873ba)
Signed-off-by: Michael Roth <address@hidden>
---
qemu-img.c | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 1acddf693c..b12f4cd19b 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -345,21 +345,6 @@ static int img_add_key_secrets(void *opaque,
return 0;
}
-static BlockBackend *img_open_new_file(const char *filename,
- QemuOpts *create_opts,
- const char *fmt, int flags,
- bool writethrough, bool quiet,
- bool force_share)
-{
- QDict *options = NULL;
-
- options = qdict_new();
- qemu_opt_foreach(create_opts, img_add_key_secrets, options, &error_abort);
-
- return img_open_file(filename, options, fmt, flags, writethrough, quiet,
- force_share);
-}
-
static BlockBackend *img_open(bool image_opts,
const char *filename,
@@ -2018,6 +2003,7 @@ static int img_convert(int argc, char **argv)
BlockDriverState *out_bs;
QemuOpts *opts = NULL, *sn_opts = NULL;
QemuOptsList *create_opts = NULL;
+ QDict *open_opts = NULL;
char *options = NULL;
Error *local_err = NULL;
bool writethrough, src_writethrough, quiet = false, image_opts = false,
@@ -2362,6 +2348,16 @@ static int img_convert(int argc, char **argv)
}
}
+ /*
+ * The later open call will need any decryption secrets, and
+ * bdrv_create() will purge "opts", so extract them now before
+ * they are lost.
+ */
+ if (!skip_create) {
+ open_opts = qdict_new();
+ qemu_opt_foreach(opts, img_add_key_secrets, open_opts, &error_abort);
+ }
+
if (!skip_create) {
/* Create the new image */
ret = bdrv_create(drv, out_filename, opts, &local_err);
@@ -2388,8 +2384,9 @@ static int img_convert(int argc, char **argv)
* That has to wait for bdrv_create to be improved
* to allow filenames in option syntax
*/
- s.target = img_open_new_file(out_filename, opts, out_fmt,
- flags, writethrough, quiet, false);
+ s.target = img_open_file(out_filename, open_opts, out_fmt,
+ flags, writethrough, quiet, false);
+ open_opts = NULL; /* blk_new_open will have freed it */
}
if (!s.target) {
ret = -1;
@@ -2464,6 +2461,7 @@ out:
qemu_opts_del(opts);
qemu_opts_free(create_opts);
qemu_opts_del(sn_opts);
+ qobject_unref(open_opts);
blk_unref(s.target);
if (s.src) {
for (bs_i = 0; bs_i < s.src_num; bs_i++) {
--
2.17.1
- [Qemu-stable] [PATCH 42/97] block/rbd: add iotest for rbd legacy keyvalue filename parsing, (continued)
- [Qemu-stable] [PATCH 42/97] block/rbd: add iotest for rbd legacy keyvalue filename parsing, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 15/97] target/arm: Use fp_status_fp16 for do_fmpa_zpzzz_h, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 90/97] slirp: check sscanf result when emulating ident, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 84/97] tpm: use loop iterator to set sts data field, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 83/97] tpm: Zero-init structure to avoid uninitialized variables in valgrind log, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 44/97] target/arm: Fix cpu_get_tb_cpu_state() for non-SVE CPUs, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 47/97] pcnet: fix possible buffer overflow, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 92/97] bitmap: Update count after a merge, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 25/97] i386: Disable TOPOEXT by default on "-cpu host", Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 62/97] fdc: fix segfault in fdctrl_stop_transfer() when DMA is disabled, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 19/97] qemu-img: fix regression copying secrets during convert,
Michael Roth <=
- [Qemu-stable] [PATCH 26/97] block: for jobs, do not clear user_paused until after the resume, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 67/97] i2c: Move typedef of bitbang_i2c_interface to i2c.h, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 88/97] acpi: Make TPM 2.0 with TIS available as MSFT0101, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 03/97] target/arm: Reorganize SVE WHILE, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 49/97] virt: Suppress external aborts on virt-2.10 and earlier, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 63/97] qemu-img: Fix typo, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 60/97] make-release: add skiboot .version file, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 34/97] tests: update acpi expected files, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 81/97] s390x: Return specification exception for unimplemented diag 308 subcodes, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 02/97] target/arm: Fix typo in do_sat_addsub_64, Michael Roth, 2019/04/01