[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 41/97] block/rbd: Attempt to parse legacy filenames
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 41/97] block/rbd: Attempt to parse legacy filenames |
Date: |
Mon, 1 Apr 2019 15:59:15 -0500 |
From: Jeff Cody <address@hidden>
When we converted rbd to get rid of the older key/value-centric
encoding format, we broke compatibility with image files with backing
file strings encoded in the old format.
This leaves a bit of an ugly conundrum, and a hacky solution.
If the initial attempt to parse the "proper" options fails, it assumes
that we may have an older key/value encoded filename. Fall back to
attempting to parse the filename, and extract the required options from
it. If that fails, pass along the original error message.
We do not support mixed modern usage alongside legacy keyvalue pair
usage.
A deprecation warning has been added, although care should be taken
when actually deprecating since the impact is not limited to
commandline or qapi usage, but also opening existing images.
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Jeff Cody <address@hidden>
Message-id: address@hidden
Signed-off-by: Jeff Cody <address@hidden>
(cherry picked from commit 084d1d13bdb753d558b991996e7686c077bd6d80)
Signed-off-by: Michael Roth <address@hidden>
---
block/rbd.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
index b199450f9f..014c68d629 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -678,6 +678,33 @@ static int qemu_rbd_convert_options(QDict *options,
BlockdevOptionsRbd **opts,
return 0;
}
+static int qemu_rbd_attempt_legacy_options(QDict *options,
+ BlockdevOptionsRbd **opts,
+ char **keypairs)
+{
+ char *filename;
+ int r;
+
+ filename = g_strdup(qdict_get_try_str(options, "filename"));
+ if (!filename) {
+ return -EINVAL;
+ }
+ qdict_del(options, "filename");
+
+ qemu_rbd_parse_filename(filename, options, NULL);
+
+ /* keypairs freed by caller */
+ *keypairs = g_strdup(qdict_get_try_str(options, "=keyvalue-pairs"));
+ if (*keypairs) {
+ qdict_del(options, "=keyvalue-pairs");
+ }
+
+ r = qemu_rbd_convert_options(options, opts, NULL);
+
+ g_free(filename);
+ return r;
+}
+
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
@@ -700,8 +727,31 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict
*options, int flags,
r = qemu_rbd_convert_options(options, &opts, &local_err);
if (local_err) {
- error_propagate(errp, local_err);
- goto out;
+ /* If keypairs are present, that means some options are present in
+ * the modern option format. Don't attempt to parse legacy option
+ * formats, as we won't support mixed usage. */
+ if (keypairs) {
+ error_propagate(errp, local_err);
+ goto out;
+ }
+
+ /* If the initial attempt to convert and process the options failed,
+ * we may be attempting to open an image file that has the rbd options
+ * specified in the older format consisting of all key/value pairs
+ * encoded in the filename. Go ahead and attempt to parse the
+ * filename, and see if we can pull out the required options. */
+ r = qemu_rbd_attempt_legacy_options(options, &opts, &keypairs);
+ if (r < 0) {
+ /* Propagate the original error, not the legacy parsing fallback
+ * error, as the latter was just a best-effort attempt. */
+ error_propagate(errp, local_err);
+ goto out;
+ }
+ /* Take care whenever deciding to actually deprecate; once this ability
+ * is removed, we will not be able to open any images with
legacy-styled
+ * backing image strings. */
+ error_report("RBD options encoded in the filename as keyvalue pairs "
+ "is deprecated");
}
/* Remove the processed options from the QDict (the visitor processes
--
2.17.1
- [Qemu-stable] [PATCH 07/97] target/arm: Fix offset for LD1R instructions, (continued)
- [Qemu-stable] [PATCH 07/97] target/arm: Fix offset for LD1R instructions, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 85/97] tpm: Make sure new locality passed to tpm_tis_prep_abort() is valid, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 77/97] pc:piix4: Update smbus I/O space after a migration, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 96/97] usb-mtp: outlaw slashes in filenames, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 95/97] 9p: fix QEMU crash when renaming files, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 94/97] nvme: fix out-of-bounds access to the CMB, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 32/97] vhost: fix invalid downcast, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 57/97] migration: Stop postcopy fault thread before notifying, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 46/97] rtl8139: fix possible out of bound access, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 05/97] target/arm: Fix typo in helper_sve_ld1hss_r, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 41/97] block/rbd: Attempt to parse legacy filenames,
Michael Roth <=
- [Qemu-stable] [PATCH 55/97] intel_iommu: better handling of dmar state switch, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 93/97] qga: update docs with systemd suspend support info, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 97/97] usb-mtp: use O_NOFOLLOW and O_CLOEXEC., Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 39/97] clean up callback when del virtqueue, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 51/97] block-backend: Set werror/rerror defaults in blk_new(), Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 40/97] block/rbd: pull out qemu_rbd_convert_options, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 24/97] vnc: fix memleak of the "vnc-worker-output" name, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 87/97] block: Fix invalidate_cache error path for parent activation, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 06/97] target/arm: Fix sign-extension in sve do_ldr/do_str, Michael Roth, 2019/04/01
- [Qemu-stable] [PATCH 72/97] mirror: fix dead-lock, Michael Roth, 2019/04/01