|
|
1bdc94 |
From ba592010c82c1302c611f6023d4abda24ee3b689 Mon Sep 17 00:00:00 2001
|
|
|
1bdc94 |
From: Jeffrey Cody <jcody@redhat.com>
|
|
|
1bdc94 |
Date: Wed, 12 Sep 2018 13:45:43 +0200
|
|
|
1bdc94 |
Subject: [PATCH 04/49] block/rbd: Attempt to parse legacy filenames
|
|
|
1bdc94 |
|
|
|
1bdc94 |
RH-Author: Jeffrey Cody <jcody@redhat.com>
|
|
|
1bdc94 |
Message-id: <819d451b971d87d47d5bc73feaf20be5bf42e6ef.1536759805.git.jcody@redhat.com>
|
|
|
1bdc94 |
Patchwork-id: 82140
|
|
|
1bdc94 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 2/3] block/rbd: Attempt to parse legacy filenames
|
|
|
1bdc94 |
Bugzilla: 1610605
|
|
|
1bdc94 |
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
1bdc94 |
|
|
|
1bdc94 |
When we converted rbd to get rid of the older key/value-centric
|
|
|
1bdc94 |
encoding format, we broke compatibility with image files with backing
|
|
|
1bdc94 |
file strings encoded in the old format.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
This leaves a bit of an ugly conundrum, and a hacky solution.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
If the initial attempt to parse the "proper" options fails, it assumes
|
|
|
1bdc94 |
that we may have an older key/value encoded filename. Fall back to
|
|
|
1bdc94 |
attempting to parse the filename, and extract the required options from
|
|
|
1bdc94 |
it. If that fails, pass along the original error message.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
We do not support mixed modern usage alongside legacy keyvalue pair
|
|
|
1bdc94 |
usage.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
A deprecation warning has been added, although care should be taken
|
|
|
1bdc94 |
when actually deprecating since the impact is not limited to
|
|
|
1bdc94 |
commandline or qapi usage, but also opening existing images.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
1bdc94 |
Signed-off-by: Jeff Cody <jcody@redhat.com>
|
|
|
1bdc94 |
Message-id: 15b332e5432ad069441f7275a46080f465d789a0.1536704901.git.jcody@redhat.com
|
|
|
1bdc94 |
Signed-off-by: Jeff Cody <jcody@redhat.com>
|
|
|
1bdc94 |
(cherry picked from commit 866543123c3cd190c44b4caf7c9ed82844c0bcc6)
|
|
|
1bdc94 |
Signed-off-by: Jeff Cody <jcody@redhat.com>
|
|
|
1bdc94 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
1bdc94 |
---
|
|
|
1bdc94 |
block/rbd.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
|
|
|
1bdc94 |
1 file changed, 51 insertions(+), 2 deletions(-)
|
|
|
1bdc94 |
|
|
|
1bdc94 |
diff --git a/block/rbd.c b/block/rbd.c
|
|
|
1bdc94 |
index 1e4d339..8f81fbc 100644
|
|
|
1bdc94 |
--- a/block/rbd.c
|
|
|
1bdc94 |
+++ b/block/rbd.c
|
|
|
1bdc94 |
@@ -671,6 +671,33 @@ static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
|
|
|
1bdc94 |
return 0;
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
+static int qemu_rbd_attempt_legacy_options(QDict *options,
|
|
|
1bdc94 |
+ BlockdevOptionsRbd **opts,
|
|
|
1bdc94 |
+ char **keypairs)
|
|
|
1bdc94 |
+{
|
|
|
1bdc94 |
+ char *filename;
|
|
|
1bdc94 |
+ int r;
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ filename = g_strdup(qdict_get_try_str(options, "filename"));
|
|
|
1bdc94 |
+ if (!filename) {
|
|
|
1bdc94 |
+ return -EINVAL;
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+ qdict_del(options, "filename");
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ qemu_rbd_parse_filename(filename, options, NULL);
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ /* keypairs freed by caller */
|
|
|
1bdc94 |
+ *keypairs = g_strdup(qdict_get_try_str(options, "=keyvalue-pairs"));
|
|
|
1bdc94 |
+ if (*keypairs) {
|
|
|
1bdc94 |
+ qdict_del(options, "=keyvalue-pairs");
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ r = qemu_rbd_convert_options(options, opts, NULL);
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ g_free(filename);
|
|
|
1bdc94 |
+ return r;
|
|
|
1bdc94 |
+}
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
1bdc94 |
Error **errp)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
@@ -693,8 +720,30 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
1bdc94 |
|
|
|
1bdc94 |
r = qemu_rbd_convert_options(options, &opts, &local_err);
|
|
|
1bdc94 |
if (local_err) {
|
|
|
1bdc94 |
- error_propagate(errp, local_err);
|
|
|
1bdc94 |
- goto out;
|
|
|
1bdc94 |
+ /* If keypairs are present, that means some options are present in
|
|
|
1bdc94 |
+ * the modern option format. Don't attempt to parse legacy option
|
|
|
1bdc94 |
+ * formats, as we won't support mixed usage. */
|
|
|
1bdc94 |
+ if (keypairs) {
|
|
|
1bdc94 |
+ error_propagate(errp, local_err);
|
|
|
1bdc94 |
+ goto out;
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ /* If the initial attempt to convert and process the options failed,
|
|
|
1bdc94 |
+ * we may be attempting to open an image file that has the rbd options
|
|
|
1bdc94 |
+ * specified in the older format consisting of all key/value pairs
|
|
|
1bdc94 |
+ * encoded in the filename. Go ahead and attempt to parse the
|
|
|
1bdc94 |
+ * filename, and see if we can pull out the required options. */
|
|
|
1bdc94 |
+ r = qemu_rbd_attempt_legacy_options(options, &opts, &keypairs);
|
|
|
1bdc94 |
+ if (r < 0) {
|
|
|
1bdc94 |
+ error_propagate(errp, local_err);
|
|
|
1bdc94 |
+ goto out;
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+ /* Take care whenever deciding to actually deprecate; once this ability
|
|
|
1bdc94 |
+ * is removed, we will not be able to open any images with legacy-styled
|
|
|
1bdc94 |
+ * backing image strings. */
|
|
|
1bdc94 |
+ error_report("RBD options encoded in the filename as keyvalue pairs "
|
|
|
1bdc94 |
+ "is deprecated. Future versions may cease to parse "
|
|
|
1bdc94 |
+ "these options in the future.");
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/* Remove the processed options from the QDict (the visitor processes
|
|
|
1bdc94 |
--
|
|
|
1bdc94 |
1.8.3.1
|
|
|
1bdc94 |
|