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