26ba25
From 04d398c3738cfc37dba9dc5c1df4e9d41931cf63 Mon Sep 17 00:00:00 2001
26ba25
From: John Snow <jsnow@redhat.com>
26ba25
Date: Wed, 10 Oct 2018 20:30:12 +0100
26ba25
Subject: [PATCH 1/4] block/rbd: pull out qemu_rbd_convert_options
26ba25
26ba25
RH-Author: John Snow <jsnow@redhat.com>
26ba25
Message-id: <20181010203015.11719-2-jsnow@redhat.com>
26ba25
Patchwork-id: 82627
26ba25
O-Subject: [RHEL8/rhel qemu-kvm PATCH 1/4] block/rbd: pull out qemu_rbd_convert_options
26ba25
Bugzilla: 1635585
26ba25
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
26ba25
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
26ba25
RH-Acked-by: Thomas Huth <thuth@redhat.com>
26ba25
26ba25
From: Jeff Cody <jcody@redhat.com>
26ba25
26ba25
Code movement to pull the conversion from Qdict to BlockdevOptionsRbd
26ba25
into a helper function.
26ba25
26ba25
Reviewed-by: Eric Blake <eblake@redhat.com>
26ba25
Reviewed-by: John Snow <jsnow@redhat.com>
26ba25
Signed-off-by: Jeff Cody <jcody@redhat.com>
26ba25
Message-id: 5b49a980f2cde6610ab1df41bb0277d00b5db893.1536704901.git.jcody@redhat.com
26ba25
Signed-off-by: Jeff Cody <jcody@redhat.com>
26ba25
(cherry picked from commit f24b03b56cdb28d753b4ff9ae210d555f14cb0d8)
26ba25
Signed-off-by: John Snow <jsnow@redhat.com>
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 block/rbd.c | 36 ++++++++++++++++++++++++------------
26ba25
 1 file changed, 24 insertions(+), 12 deletions(-)
26ba25
26ba25
diff --git a/block/rbd.c b/block/rbd.c
26ba25
index b93046b..1e4d339 100644
26ba25
--- a/block/rbd.c
26ba25
+++ b/block/rbd.c
26ba25
@@ -648,12 +648,34 @@ failed_opts:
26ba25
     return r;
26ba25
 }
26ba25
 
26ba25
+static int qemu_rbd_convert_options(QDict *options, BlockdevOptionsRbd **opts,
26ba25
+                                    Error **errp)
26ba25
+{
26ba25
+    Visitor *v;
26ba25
+    Error *local_err = NULL;
26ba25
+
26ba25
+    /* Convert the remaining options into a QAPI object */
26ba25
+    v = qobject_input_visitor_new_flat_confused(options, errp);
26ba25
+    if (!v) {
26ba25
+        return -EINVAL;
26ba25
+    }
26ba25
+
26ba25
+    visit_type_BlockdevOptionsRbd(v, NULL, opts, &local_err);
26ba25
+    visit_free(v);
26ba25
+
26ba25
+    if (local_err) {
26ba25
+        error_propagate(errp, local_err);
26ba25
+        return -EINVAL;
26ba25
+    }
26ba25
+
26ba25
+    return 0;
26ba25
+}
26ba25
+
26ba25
 static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
26ba25
                          Error **errp)
26ba25
 {
26ba25
     BDRVRBDState *s = bs->opaque;
26ba25
     BlockdevOptionsRbd *opts = NULL;
26ba25
-    Visitor *v;
26ba25
     const QDictEntry *e;
26ba25
     Error *local_err = NULL;
26ba25
     char *keypairs, *secretid;
26ba25
@@ -669,19 +691,9 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
26ba25
         qdict_del(options, "password-secret");
26ba25
     }
26ba25
 
26ba25
-    /* Convert the remaining options into a QAPI object */
26ba25
-    v = qobject_input_visitor_new_flat_confused(options, errp);
26ba25
-    if (!v) {
26ba25
-        r = -EINVAL;
26ba25
-        goto out;
26ba25
-    }
26ba25
-
26ba25
-    visit_type_BlockdevOptionsRbd(v, NULL, &opts, &local_err);
26ba25
-    visit_free(v);
26ba25
-
26ba25
+    r = qemu_rbd_convert_options(options, &opts, &local_err);
26ba25
     if (local_err) {
26ba25
         error_propagate(errp, local_err);
26ba25
-        r = -EINVAL;
26ba25
         goto out;
26ba25
     }
26ba25
 
26ba25
-- 
26ba25
1.8.3.1
26ba25