From 0b239ab1df3f430f6d1163dc9571e89b99939812 Mon Sep 17 00:00:00 2001
From: Jeffrey Cody <jcody@redhat.com>
Date: Wed, 12 Sep 2018 13:45:42 +0200
Subject: [PATCH 03/49] block/rbd: pull out qemu_rbd_convert_options
RH-Author: Jeffrey Cody <jcody@redhat.com>
Message-id: <695a2a1c89a6bfd5076d050f5396aa7937e00cc5.1536759805.git.jcody@redhat.com>
Patchwork-id: 82143
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 1/3] block/rbd: pull out qemu_rbd_convert_options
Bugzilla: 1610605
RH-Acked-by: Eric Blake <eblake@redhat.com>
RH-Acked-by: John Snow <jsnow@redhat.com>
RH-Acked-by: Fam Zheng <famz@redhat.com>
Code movement to pull the conversion from Qdict to BlockdevOptionsRbd
into a helper function.
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Message-id: 5b49a980f2cde6610ab1df41bb0277d00b5db893.1536704901.git.jcody@redhat.com
Signed-off-by: Jeff Cody <jcody@redhat.com>
(cherry picked from commit 862e99966b5b59c107255fa806af40cf00ecacec)
Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
block/rbd.c | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
index b93046b..1e4d339 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -648,12 +648,34 @@ failed_opts:
return r;
}
+static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
+ Error **errp)
+{
+ Visitor *v;
+ Error *local_err = NULL;
+
+ /* Convert the remaining options into a QAPI object */
+ v = qobject_input_visitor_new_flat_confused(options, errp);
+ if (!v) {
+ return -EINVAL;
+ }
+
+ visit_type_BlockdevOptionsRbd(v, NULL, opts, &local_err);
+ visit_free(v);
+
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVRBDState *s = bs->opaque;
BlockdevOptionsRbd *opts = NULL;
- Visitor *v;
const QDictEntry *e;
Error *local_err = NULL;
char *keypairs, *secretid;
@@ -669,19 +691,9 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
qdict_del(options, "password-secret");
}
- /* Convert the remaining options into a QAPI object */
- v = qobject_input_visitor_new_flat_confused(options, errp);
- if (!v) {
- r = -EINVAL;
- goto out;
- }
-
- visit_type_BlockdevOptionsRbd(v, NULL, &opts, &local_err);
- visit_free(v);
-
+ r = qemu_rbd_convert_options(options, &opts, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- r = -EINVAL;
goto out;
}
--
1.8.3.1