Blame SOURCES/kvm-block-rbd-pull-out-qemu_rbd_convert_options.patch

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