]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: block: Add support for formatting gluster debug level via JSON
authorPeter Krempa <pkrempa@redhat.com>
Thu, 23 Nov 2017 15:07:47 +0000 (16:07 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 23 Nov 2017 17:50:04 +0000 (18:50 +0100)
Improve the formatter so that we can use the 'debug' property straight
away when using json.

src/qemu/qemu_block.c

index 29a341f149502ddb885ea74a9cf77962694fdb0e..585f0255eea99ed9e07355bb736ddf44d29e2ced 100644 (file)
@@ -654,6 +654,7 @@ static virJSONValuePtr
 qemuBlockStorageSourceGetGlusterProps(virStorageSourcePtr src)
 {
     virJSONValuePtr servers = NULL;
+    virJSONValuePtr props = NULL;
     virJSONValuePtr ret = NULL;
 
     if (!(servers = qemuBlockStorageSourceBuildHostsJSONSocketAddress(src, true)))
@@ -665,12 +666,24 @@ qemuBlockStorageSourceGetGlusterProps(virStorageSourcePtr src)
       *   server :[{type:"tcp", host:"1.2.3.4", port:24007},
       *            {type:"unix", socket:"/tmp/glusterd.socket"}, ...]}
       */
-    if (virJSONValueObjectCreate(&ret,
+    if (virJSONValueObjectCreate(&props,
                                  "s:driver", "gluster",
                                  "s:volume", src->volume,
                                  "s:path", src->path,
                                  "a:server", servers, NULL) < 0)
-          virJSONValueFree(servers);
+        goto cleanup;
+
+    servers = NULL;
+
+    if (src->debug &&
+        virJSONValueObjectAdd(props, "u:debug", src->debugLevel, NULL) < 0)
+        goto cleanup;
+
+    VIR_STEAL_PTR(ret, props);
+
+ cleanup:
+    virJSONValueFree(servers);
+    virJSONValueFree(props);
 
     return ret;
 }