qemu: block: Add support for formatting gluster debug level via JSON

Improve the formatter so that we can use the 'debug' property straight
away when using json.
This commit is contained in:
Peter Krempa 2017-11-23 16:07:47 +01:00
parent 0a1870ddd0
commit eeaf6657f7

View 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;
}