1
The following changes since commit 19b599f7664b2ebfd0f405fb79c14dd241557452:
1
The following changes since commit ca61fa4b803e5d0abaf6f1ceb690f23bb78a4def:
2
2
3
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2018-08-27-v2' into staging (2018-08-27 16:44:20 +0100)
3
Merge remote-tracking branch 'remotes/quic/tags/pull-hex-20211006' into staging (2021-10-06 12:11:14 -0700)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
git://github.com/codyprime/qemu-kvm-jtc.git tags/block-pull-request
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to 8af2eb7b43a1b694fd6d1d090025027d6b72caac:
9
for you to fetch changes up to 1cc7eada97914f090125e588497986f6f7900514:
10
10
11
block/rbd: add deprecation documentation for filename keyvalue pairs (2018-09-12 08:51:45 -0400)
11
iothread: use IOThreadParamInfo in iothread_[set|get]_param() (2021-10-07 15:29:50 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches for RBD
14
Pull request
15
15
----------------------------------------------------------------
16
----------------------------------------------------------------
16
17
17
Jeff Cody (4):
18
Stefano Garzarella (2):
18
block/rbd: pull out qemu_rbd_convert_options
19
iothread: rename PollParamInfo to IOThreadParamInfo
19
block/rbd: Attempt to parse legacy filenames
20
iothread: use IOThreadParamInfo in iothread_[set|get]_param()
20
block/rbd: add iotest for rbd legacy keyvalue filename parsing
21
block/rbd: add deprecation documentation for filename keyvalue pairs
22
21
23
block/rbd.c | 89 ++++++++++++++++++++++++++++++++------
22
iothread.c | 28 +++++++++++++++-------------
24
qemu-deprecated.texi | 15 +++++++
23
1 file changed, 15 insertions(+), 13 deletions(-)
25
tests/qemu-iotests/231 | 62 ++++++++++++++++++++++++++
26
tests/qemu-iotests/231.out | 9 ++++
27
tests/qemu-iotests/group | 1 +
28
5 files changed, 162 insertions(+), 14 deletions(-)
29
create mode 100755 tests/qemu-iotests/231
30
create mode 100644 tests/qemu-iotests/231.out
31
24
32
--
25
--
33
2.17.1
26
2.31.1
34
27
35
28
29
diff view generated by jsdifflib
1
Signed-off-by: Jeff Cody <jcody@redhat.com>
1
From: Stefano Garzarella <sgarzare@redhat.com>
2
Message-id: 647f5b5ab7efd8bf567a504c832b1d2d6f719b23.1536704901.git.jcody@redhat.com
2
3
Signed-off-by: Jeff Cody <jcody@redhat.com>
3
Commit 1793ad0247 ("iothread: add aio-max-batch parameter") added
4
a new parameter (aio-max-batch) to IOThread and used PollParamInfo
5
structure to handle it.
6
7
Since it is not a parameter of the polling mechanism, we rename the
8
structure to a more generic IOThreadParamInfo.
9
10
Suggested-by: Kevin Wolf <kwolf@redhat.com>
11
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
Message-id: 20210727145936.147032-2-sgarzare@redhat.com
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4
---
15
---
5
qemu-deprecated.texi | 15 +++++++++++++++
16
iothread.c | 14 +++++++-------
6
1 file changed, 15 insertions(+)
17
1 file changed, 7 insertions(+), 7 deletions(-)
7
18
8
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
19
diff --git a/iothread.c b/iothread.c
9
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
10
--- a/qemu-deprecated.texi
21
--- a/iothread.c
11
+++ b/qemu-deprecated.texi
22
+++ b/iothread.c
12
@@ -XXX,XX +XXX,XX @@ used instead.
23
@@ -XXX,XX +XXX,XX @@ static void iothread_complete(UserCreatable *obj, Error **errp)
13
In order to prevent QEMU from automatically opening an image's backing
24
typedef struct {
14
chain, use ``"backing": null'' instead.
25
const char *name;
15
26
ptrdiff_t offset; /* field's byte offset in IOThread struct */
16
+@subsubsection rbd keyvalue pair encoded filenames: "" (since 3.1.0)
27
-} PollParamInfo;
17
+
28
+} IOThreadParamInfo;
18
+Options for ``rbd'' should be specified according to its runtime options,
29
19
+like other block drivers. Legacy parsing of keyvalue pair encoded
30
-static PollParamInfo poll_max_ns_info = {
20
+filenames is useful to open images with the old format for backing files;
31
+static IOThreadParamInfo poll_max_ns_info = {
21
+These image files should be updated to use the current format.
32
"poll-max-ns", offsetof(IOThread, poll_max_ns),
22
+
33
};
23
+Example of legacy encoding:
34
-static PollParamInfo poll_grow_info = {
24
+
35
+static IOThreadParamInfo poll_grow_info = {
25
+@code{json:@{"file.driver":"rbd", "file.filename":"rbd:rbd/name"@}}
36
"poll-grow", offsetof(IOThread, poll_grow),
26
+
37
};
27
+The above, converted to the current supported format:
38
-static PollParamInfo poll_shrink_info = {
28
+
39
+static IOThreadParamInfo poll_shrink_info = {
29
+@code{json:@{"file.driver":"rbd", "file.pool":"rbd", "file.image":"name"@}}
40
"poll-shrink", offsetof(IOThread, poll_shrink),
30
+
41
};
31
@subsection vio-spapr-device device options
42
-static PollParamInfo aio_max_batch_info = {
32
43
+static IOThreadParamInfo aio_max_batch_info = {
33
@subsubsection "irq": "" (since 3.0.0)
44
"aio-max-batch", offsetof(IOThread, aio_max_batch),
45
};
46
47
@@ -XXX,XX +XXX,XX @@ static void iothread_get_param(Object *obj, Visitor *v,
48
const char *name, void *opaque, Error **errp)
49
{
50
IOThread *iothread = IOTHREAD(obj);
51
- PollParamInfo *info = opaque;
52
+ IOThreadParamInfo *info = opaque;
53
int64_t *field = (void *)iothread + info->offset;
54
55
visit_type_int64(v, name, field, errp);
56
@@ -XXX,XX +XXX,XX @@ static bool iothread_set_param(Object *obj, Visitor *v,
57
const char *name, void *opaque, Error **errp)
58
{
59
IOThread *iothread = IOTHREAD(obj);
60
- PollParamInfo *info = opaque;
61
+ IOThreadParamInfo *info = opaque;
62
int64_t *field = (void *)iothread + info->offset;
63
int64_t value;
64
34
--
65
--
35
2.17.1
66
2.31.1
36
67
37
68
diff view generated by jsdifflib
1
Code movement to pull the conversion from Qdict to BlockdevOptionsRbd
1
From: Stefano Garzarella <sgarzare@redhat.com>
2
into a helper function.
3
2
4
Reviewed-by: Eric Blake <eblake@redhat.com>
3
Commit 0445409d74 ("iothread: generalize
5
Reviewed-by: John Snow <jsnow@redhat.com>
4
iothread_set_param/iothread_get_param") moved common code to set and
6
Signed-off-by: Jeff Cody <jcody@redhat.com>
5
get IOThread parameters in two new functions.
7
Message-id: 5b49a980f2cde6610ab1df41bb0277d00b5db893.1536704901.git.jcody@redhat.com
6
8
Signed-off-by: Jeff Cody <jcody@redhat.com>
7
These functions are called inside callbacks, so we don't need to use an
8
opaque pointer. Let's replace `void *opaque` parameter with
9
`IOThreadParamInfo *info`.
10
11
Suggested-by: Kevin Wolf <kwolf@redhat.com>
12
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Message-id: 20210727145936.147032-3-sgarzare@redhat.com
15
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
---
16
---
10
block/rbd.c | 36 ++++++++++++++++++++++++------------
17
iothread.c | 18 ++++++++++--------
11
1 file changed, 24 insertions(+), 12 deletions(-)
18
1 file changed, 10 insertions(+), 8 deletions(-)
12
19
13
diff --git a/block/rbd.c b/block/rbd.c
20
diff --git a/iothread.c b/iothread.c
14
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
15
--- a/block/rbd.c
22
--- a/iothread.c
16
+++ b/block/rbd.c
23
+++ b/iothread.c
17
@@ -XXX,XX +XXX,XX @@ failed_opts:
24
@@ -XXX,XX +XXX,XX @@ static IOThreadParamInfo aio_max_batch_info = {
18
return r;
25
};
26
27
static void iothread_get_param(Object *obj, Visitor *v,
28
- const char *name, void *opaque, Error **errp)
29
+ const char *name, IOThreadParamInfo *info, Error **errp)
30
{
31
IOThread *iothread = IOTHREAD(obj);
32
- IOThreadParamInfo *info = opaque;
33
int64_t *field = (void *)iothread + info->offset;
34
35
visit_type_int64(v, name, field, errp);
19
}
36
}
20
37
21
+static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
38
static bool iothread_set_param(Object *obj, Visitor *v,
22
+ Error **errp)
39
- const char *name, void *opaque, Error **errp)
23
+{
40
+ const char *name, IOThreadParamInfo *info, Error **errp)
24
+ Visitor *v;
25
+ Error *local_err = NULL;
26
+
27
+ /* Convert the remaining options into a QAPI object */
28
+ v = qobject_input_visitor_new_flat_confused(options, errp);
29
+ if (!v) {
30
+ return -EINVAL;
31
+ }
32
+
33
+ visit_type_BlockdevOptionsRbd(v, NULL, opts, &local_err);
34
+ visit_free(v);
35
+
36
+ if (local_err) {
37
+ error_propagate(errp, local_err);
38
+ return -EINVAL;
39
+ }
40
+
41
+ return 0;
42
+}
43
+
44
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
45
Error **errp)
46
{
41
{
47
BDRVRBDState *s = bs->opaque;
42
IOThread *iothread = IOTHREAD(obj);
48
BlockdevOptionsRbd *opts = NULL;
43
- IOThreadParamInfo *info = opaque;
49
- Visitor *v;
44
int64_t *field = (void *)iothread + info->offset;
50
const QDictEntry *e;
45
int64_t value;
51
Error *local_err = NULL;
46
52
char *keypairs, *secretid;
47
@@ -XXX,XX +XXX,XX @@ static bool iothread_set_param(Object *obj, Visitor *v,
53
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
48
static void iothread_get_poll_param(Object *obj, Visitor *v,
54
qdict_del(options, "password-secret");
49
const char *name, void *opaque, Error **errp)
50
{
51
+ IOThreadParamInfo *info = opaque;
52
53
- iothread_get_param(obj, v, name, opaque, errp);
54
+ iothread_get_param(obj, v, name, info, errp);
55
}
56
57
static void iothread_set_poll_param(Object *obj, Visitor *v,
58
const char *name, void *opaque, Error **errp)
59
{
60
IOThread *iothread = IOTHREAD(obj);
61
+ IOThreadParamInfo *info = opaque;
62
63
- if (!iothread_set_param(obj, v, name, opaque, errp)) {
64
+ if (!iothread_set_param(obj, v, name, info, errp)) {
65
return;
55
}
66
}
56
67
57
- /* Convert the remaining options into a QAPI object */
68
@@ -XXX,XX +XXX,XX @@ static void iothread_set_poll_param(Object *obj, Visitor *v,
58
- v = qobject_input_visitor_new_flat_confused(options, errp);
69
static void iothread_get_aio_param(Object *obj, Visitor *v,
59
- if (!v) {
70
const char *name, void *opaque, Error **errp)
60
- r = -EINVAL;
71
{
61
- goto out;
72
+ IOThreadParamInfo *info = opaque;
62
- }
73
63
-
74
- iothread_get_param(obj, v, name, opaque, errp);
64
- visit_type_BlockdevOptionsRbd(v, NULL, &opts, &local_err);
75
+ iothread_get_param(obj, v, name, info, errp);
65
- visit_free(v);
76
}
66
-
77
67
+ r = qemu_rbd_convert_options(options, &opts, &local_err);
78
static void iothread_set_aio_param(Object *obj, Visitor *v,
68
if (local_err) {
79
const char *name, void *opaque, Error **errp)
69
error_propagate(errp, local_err);
80
{
70
- r = -EINVAL;
81
IOThread *iothread = IOTHREAD(obj);
71
goto out;
82
+ IOThreadParamInfo *info = opaque;
83
84
- if (!iothread_set_param(obj, v, name, opaque, errp)) {
85
+ if (!iothread_set_param(obj, v, name, info, errp)) {
86
return;
72
}
87
}
73
88
74
--
89
--
75
2.17.1
90
2.31.1
76
91
77
92
diff view generated by jsdifflib
Deleted patch
1
When we converted rbd to get rid of the older key/value-centric
2
encoding format, we broke compatibility with image files with backing
3
file strings encoded in the old format.
4
1
5
This leaves a bit of an ugly conundrum, and a hacky solution.
6
7
If the initial attempt to parse the "proper" options fails, it assumes
8
that we may have an older key/value encoded filename. Fall back to
9
attempting to parse the filename, and extract the required options from
10
it. If that fails, pass along the original error message.
11
12
We do not support mixed modern usage alongside legacy keyvalue pair
13
usage.
14
15
A deprecation warning has been added, although care should be taken
16
when actually deprecating since the impact is not limited to
17
commandline or qapi usage, but also opening existing images.
18
19
Reviewed-by: Eric Blake <eblake@redhat.com>
20
Signed-off-by: Jeff Cody <jcody@redhat.com>
21
Message-id: 15b332e5432ad069441f7275a46080f465d789a0.1536704901.git.jcody@redhat.com
22
Signed-off-by: Jeff Cody <jcody@redhat.com>
23
---
24
block/rbd.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
25
1 file changed, 51 insertions(+), 2 deletions(-)
26
27
diff --git a/block/rbd.c b/block/rbd.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/block/rbd.c
30
+++ b/block/rbd.c
31
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
32
return 0;
33
}
34
35
+static int qemu_rbd_attempt_legacy_options(QDict *options,
36
+ BlockdevOptionsRbd **opts,
37
+ char **keypairs)
38
+{
39
+ char *filename;
40
+ int r;
41
+
42
+ filename = g_strdup(qdict_get_try_str(options, "filename"));
43
+ if (!filename) {
44
+ return -EINVAL;
45
+ }
46
+ qdict_del(options, "filename");
47
+
48
+ qemu_rbd_parse_filename(filename, options, NULL);
49
+
50
+ /* keypairs freed by caller */
51
+ *keypairs = g_strdup(qdict_get_try_str(options, "=keyvalue-pairs"));
52
+ if (*keypairs) {
53
+ qdict_del(options, "=keyvalue-pairs");
54
+ }
55
+
56
+ r = qemu_rbd_convert_options(options, opts, NULL);
57
+
58
+ g_free(filename);
59
+ return r;
60
+}
61
+
62
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
63
Error **errp)
64
{
65
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
66
67
r = qemu_rbd_convert_options(options, &opts, &local_err);
68
if (local_err) {
69
- error_propagate(errp, local_err);
70
- goto out;
71
+ /* If keypairs are present, that means some options are present in
72
+ * the modern option format. Don't attempt to parse legacy option
73
+ * formats, as we won't support mixed usage. */
74
+ if (keypairs) {
75
+ error_propagate(errp, local_err);
76
+ goto out;
77
+ }
78
+
79
+ /* If the initial attempt to convert and process the options failed,
80
+ * we may be attempting to open an image file that has the rbd options
81
+ * specified in the older format consisting of all key/value pairs
82
+ * encoded in the filename. Go ahead and attempt to parse the
83
+ * filename, and see if we can pull out the required options. */
84
+ r = qemu_rbd_attempt_legacy_options(options, &opts, &keypairs);
85
+ if (r < 0) {
86
+ error_propagate(errp, local_err);
87
+ goto out;
88
+ }
89
+ /* Take care whenever deciding to actually deprecate; once this ability
90
+ * is removed, we will not be able to open any images with legacy-styled
91
+ * backing image strings. */
92
+ error_report("RBD options encoded in the filename as keyvalue pairs "
93
+ "is deprecated. Future versions may cease to parse "
94
+ "these options in the future.");
95
}
96
97
/* Remove the processed options from the QDict (the visitor processes
98
--
99
2.17.1
100
101
diff view generated by jsdifflib
Deleted patch
1
This is a small test that will check for the ability to parse
2
both legacy and modern options for rbd.
3
1
4
The way the test is set up is for failure to occur, but without
5
having to wait to timeout on a non-existent rbd server. The error
6
messages in the success path show that the arguments were parsed.
7
8
The failure behavior prior to the patch series that has this test, is
9
qemu-img complaining about mandatory options (e.g. 'pool') not being
10
provided.
11
12
Reviewed-by: Eric Blake <eblake@redhat.com>
13
Signed-off-by: Jeff Cody <jcody@redhat.com>
14
Message-id: f830580e339b974a83ed4870d11adcdc17f49a47.1536704901.git.jcody@redhat.com
15
Signed-off-by: Jeff Cody <jcody@redhat.com>
16
---
17
tests/qemu-iotests/231 | 62 ++++++++++++++++++++++++++++++++++++++
18
tests/qemu-iotests/231.out | 9 ++++++
19
tests/qemu-iotests/group | 1 +
20
3 files changed, 72 insertions(+)
21
create mode 100755 tests/qemu-iotests/231
22
create mode 100644 tests/qemu-iotests/231.out
23
24
diff --git a/tests/qemu-iotests/231 b/tests/qemu-iotests/231
25
new file mode 100755
26
index XXXXXXX..XXXXXXX
27
--- /dev/null
28
+++ b/tests/qemu-iotests/231
29
@@ -XXX,XX +XXX,XX @@
30
+#!/bin/bash
31
+#
32
+# Test legacy and modern option parsing for rbd/ceph. This will not
33
+# actually connect to a ceph server, but rather looks for the appropriate
34
+# error message that indicates we parsed the options correctly.
35
+#
36
+# Copyright (C) 2018 Red Hat, Inc.
37
+#
38
+# This program is free software; you can redistribute it and/or modify
39
+# it under the terms of the GNU General Public License as published by
40
+# the Free Software Foundation; either version 2 of the License, or
41
+# (at your option) any later version.
42
+#
43
+# This program is distributed in the hope that it will be useful,
44
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
45
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46
+# GNU General Public License for more details.
47
+#
48
+# You should have received a copy of the GNU General Public License
49
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
50
+#
51
+
52
+# creator
53
+owner=jcody@redhat.com
54
+
55
+seq=`basename $0`
56
+echo "QA output created by $seq"
57
+
58
+here=`pwd`
59
+status=1    # failure is the default!
60
+
61
+_cleanup()
62
+{
63
+ rm "${BOGUS_CONF}"
64
+}
65
+trap "_cleanup; exit \$status" 0 1 2 3 15
66
+
67
+# get standard environment, filters and checks
68
+. ./common.rc
69
+. ./common.filter
70
+
71
+_supported_fmt generic
72
+_supported_proto rbd
73
+_supported_os Linux
74
+
75
+BOGUS_CONF=${TEST_DIR}/ceph-$$.conf
76
+touch "${BOGUS_CONF}"
77
+
78
+_filter_conf()
79
+{
80
+ sed -e "s#$BOGUS_CONF#BOGUS_CONF#g"
81
+}
82
+
83
+# We expect this to fail, with no monitor ip provided and a null conf file. Just want it
84
+# to fail in the right way.
85
+$QEMU_IMG info "json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=${BOGUS_CONF}'}" 2>&1 | _filter_conf
86
+$QEMU_IMG info "json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'${BOGUS_CONF}'}" 2>&1 | _filter_conf
87
+
88
+# success, all done
89
+echo "*** done"
90
+rm -f $seq.full
91
+status=0
92
diff --git a/tests/qemu-iotests/231.out b/tests/qemu-iotests/231.out
93
new file mode 100644
94
index XXXXXXX..XXXXXXX
95
--- /dev/null
96
+++ b/tests/qemu-iotests/231.out
97
@@ -XXX,XX +XXX,XX @@
98
+QA output created by 231
99
+qemu-img: RBD options encoded in the filename as keyvalue pairs is deprecated. Future versions may cease to parse these options in the future.
100
+unable to get monitor info from DNS SRV with service name: ceph-mon
101
+no monitors specified to connect to.
102
+qemu-img: Could not open 'json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=BOGUS_CONF'}': error connecting: No such file or directory
103
+unable to get monitor info from DNS SRV with service name: ceph-mon
104
+no monitors specified to connect to.
105
+qemu-img: Could not open 'json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'BOGUS_CONF'}': error connecting: No such file or directory
106
+*** done
107
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
108
index XXXXXXX..XXXXXXX 100644
109
--- a/tests/qemu-iotests/group
110
+++ b/tests/qemu-iotests/group
111
@@ -XXX,XX +XXX,XX @@
112
226 auto quick
113
227 auto quick
114
229 auto quick
115
+231 auto quick
116
--
117
2.17.1
118
119
diff view generated by jsdifflib