]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuBlockStorageSourceGetRBDProps: Simplify generation of auth modes
authorPeter Krempa <pkrempa@redhat.com>
Mon, 20 Dec 2021 13:22:06 +0000 (14:22 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 22 Dec 2021 12:48:35 +0000 (13:48 +0100)
The auth mode array is static, parse it from a JSON string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
src/qemu/qemu_block.c

index 2e606e99b4c3a3971ba900f4edee6377c05cd5c6..e5ff653a6032b4fee640400e67263b55e8e182f2 100644 (file)
@@ -881,7 +881,6 @@ qemuBlockStorageSourceGetRBDProps(virStorageSource *src,
     const char *encformat;
     const char *username = NULL;
     g_autoptr(virJSONValue) authmodes = NULL;
-    g_autoptr(virJSONValue) mode = NULL;
     const char *keysecret = NULL;
 
     if (src->nhosts > 0 &&
@@ -892,14 +891,7 @@ qemuBlockStorageSourceGetRBDProps(virStorageSource *src,
         username = srcPriv->secinfo->username;
         keysecret = srcPriv->secinfo->alias;
         /* the auth modes are modelled after our old command line generator */
-        authmodes = virJSONValueNewArray();
-
-        if (!(mode = virJSONValueNewString("cephx")) ||
-            virJSONValueArrayAppend(authmodes, &mode) < 0)
-            return NULL;
-
-        if (!(mode = virJSONValueNewString("none")) ||
-            virJSONValueArrayAppend(authmodes, &mode) < 0)
+        if (!(authmodes = virJSONValueFromString("[\"cephx\",\"none\"]")))
             return NULL;
     }