mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 20:45:18 +00:00
qemu: command: Separate wrapping of disk backend props to 'file' object
The file object is needed when formatting the command line, but it makes nesting of the objects less easy for use with blockdev. Separate the wrapping into the 'file' object into a helper used specifically for disk sources in the old code path.
This commit is contained in:
parent
7702cc1f80
commit
5e24a36e0d
@ -572,7 +572,6 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
|
||||
{
|
||||
int actualType = virStorageSourceGetActualType(src);
|
||||
virJSONValuePtr fileprops = NULL;
|
||||
virJSONValuePtr ret = NULL;
|
||||
|
||||
switch ((virStorageType) actualType) {
|
||||
case VIR_STORAGE_TYPE_BLOCK:
|
||||
@ -587,12 +586,12 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
|
||||
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:
|
||||
@ -612,12 +611,5 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
|
||||
break;
|
||||
}
|
||||
|
||||
if (virJSONValueObjectCreate(&ret, "a:file", fileprops, NULL) < 0)
|
||||
goto cleanup;
|
||||
|
||||
fileprops = NULL;
|
||||
|
||||
cleanup:
|
||||
virJSONValueFree(fileprops);
|
||||
return ret;
|
||||
return fileprops;
|
||||
}
|
||||
|
@ -1370,6 +1370,31 @@ qemuDiskSourceNeedsProps(virStorageSourcePtr src)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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,
|
||||
@ -1385,7 +1410,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
|
||||
int ret = -1;
|
||||
|
||||
if (qemuDiskSourceNeedsProps(disk->src) &&
|
||||
!(srcprops = qemuBlockStorageSourceGetBackendProps(disk->src)))
|
||||
!(srcprops = qemuDiskSourceGetProps(disk->src)))
|
||||
goto cleanup;
|
||||
|
||||
if (!srcprops &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user