[PATCH 1/6] qemuBlockStorageSourceGetRBDProps: Simplify generation of auth modes

Peter Krempa pkrempa at redhat.com
Wed Dec 22 12:02:37 UTC 2021


The auth mode array is static, parse it from a JSON string.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_block.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 2e606e99b4..e5ff653a60 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -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;
     }

-- 
2.31.1




More information about the libvir-list mailing list