{
int actualType = virStorageSourceGetActualType(src);
virJSONValuePtr fileprops = NULL;
- virJSONValuePtr ret = NULL;
switch ((virStorageType) actualType) {
case VIR_STORAGE_TYPE_BLOCK:
switch ((virStorageNetProtocol) src->protocol) {
case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
if (!(fileprops = qemuBlockStorageSourceGetGlusterProps(src)))
- goto cleanup;
+ return NULL;
break;
case VIR_STORAGE_NET_PROTOCOL_VXHS:
if (!(fileprops = qemuBlockStorageSourceGetVxHSProps(src)))
- goto cleanup;
+ return NULL;
break;
case VIR_STORAGE_NET_PROTOCOL_NBD:
break;
}
- if (virJSONValueObjectCreate(&ret, "a:file", fileprops, NULL) < 0)
- goto cleanup;
-
- fileprops = NULL;
-
- cleanup:
- virJSONValueFree(fileprops);
- return ret;
+ return fileprops;
}
}
+/**
+ * qemuDiskSourceGetProps:
+ * @src: disk source struct
+ *
+ * Returns the disk source struct wrapped so that it can be used as disk source
+ * directly by converting it from json.
+ */
+static virJSONValuePtr
+qemuDiskSourceGetProps(virStorageSourcePtr src)
+{
+ virJSONValuePtr props;
+ virJSONValuePtr ret;
+
+ if (!(props = qemuBlockStorageSourceGetBackendProps(src)))
+ return NULL;
+
+ if (virJSONValueObjectCreate(&ret, "a:file", props, NULL) < 0) {
+ virJSONValueFree(props);
+ return NULL;
+ }
+
+ return ret;
+}
+
+
static int
qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
virQEMUDriverConfigPtr cfg,
int ret = -1;
if (qemuDiskSourceNeedsProps(disk->src) &&
- !(srcprops = qemuBlockStorageSourceGetBackendProps(disk->src)))
+ !(srcprops = qemuDiskSourceGetProps(disk->src)))
goto cleanup;
if (!srcprops &&