mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 18:05:20 +00:00
qemu: block: Refactor and rename qemuGetDriveSourceProps
Rename it to qemuBlockStorageSourceGetBackendProps and refactor it to return the JSON object instead of filling a pointer since now it's always expected to return data.
This commit is contained in:
parent
7677f8a7d9
commit
bb8ebe69dd
@ -519,14 +519,19 @@ qemuBuildGlusterDriveJSON(virStorageSourcePtr src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
/**
|
||||||
qemuGetDriveSourceProps(virStorageSourcePtr src,
|
* qemuBlockStorageSourceGetBackendProps:
|
||||||
virJSONValuePtr *props)
|
* @src: disk source
|
||||||
|
*
|
||||||
|
* Creates a JSON object describing the underlying storage or protocol of a
|
||||||
|
* storage source. Returns NULL on error and reports an appropriate error message.
|
||||||
|
*/
|
||||||
|
virJSONValuePtr
|
||||||
|
qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
|
||||||
{
|
{
|
||||||
int actualType = virStorageSourceGetActualType(src);
|
int actualType = virStorageSourceGetActualType(src);
|
||||||
virJSONValuePtr fileprops = NULL;
|
virJSONValuePtr fileprops = NULL;
|
||||||
|
virJSONValuePtr ret = NULL;
|
||||||
*props = NULL;
|
|
||||||
|
|
||||||
switch ((virStorageType) actualType) {
|
switch ((virStorageType) actualType) {
|
||||||
case VIR_STORAGE_TYPE_BLOCK:
|
case VIR_STORAGE_TYPE_BLOCK:
|
||||||
@ -538,19 +543,35 @@ qemuGetDriveSourceProps(virStorageSourcePtr src,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_STORAGE_TYPE_NETWORK:
|
case VIR_STORAGE_TYPE_NETWORK:
|
||||||
if (src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER &&
|
switch ((virStorageNetProtocol) src->protocol) {
|
||||||
src->nhosts > 1) {
|
case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
|
||||||
if (!(fileprops = qemuBuildGlusterDriveJSON(src)))
|
if (!(fileprops = qemuBuildGlusterDriveJSON(src)))
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_STORAGE_NET_PROTOCOL_NBD:
|
||||||
|
case VIR_STORAGE_NET_PROTOCOL_RBD:
|
||||||
|
case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG:
|
||||||
|
case VIR_STORAGE_NET_PROTOCOL_ISCSI:
|
||||||
|
case VIR_STORAGE_NET_PROTOCOL_HTTP:
|
||||||
|
case VIR_STORAGE_NET_PROTOCOL_HTTPS:
|
||||||
|
case VIR_STORAGE_NET_PROTOCOL_FTP:
|
||||||
|
case VIR_STORAGE_NET_PROTOCOL_FTPS:
|
||||||
|
case VIR_STORAGE_NET_PROTOCOL_TFTP:
|
||||||
|
case VIR_STORAGE_NET_PROTOCOL_SSH:
|
||||||
|
case VIR_STORAGE_NET_PROTOCOL_NONE:
|
||||||
|
case VIR_STORAGE_NET_PROTOCOL_LAST:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileprops &&
|
if (virJSONValueObjectCreate(&ret, "a:file", fileprops, NULL) < 0)
|
||||||
virJSONValueObjectCreate(props, "a:file", fileprops, NULL) < 0) {
|
goto cleanup;
|
||||||
virJSONValueFree(fileprops);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
fileprops = NULL;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virJSONValueFree(fileprops);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,7 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
|
|||||||
virHashTablePtr
|
virHashTablePtr
|
||||||
qemuBlockGetNodeData(virJSONValuePtr data);
|
qemuBlockGetNodeData(virJSONValuePtr data);
|
||||||
|
|
||||||
|
virJSONValuePtr
|
||||||
int
|
qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src);
|
||||||
qemuGetDriveSourceProps(virStorageSourcePtr src,
|
|
||||||
virJSONValuePtr *props);
|
|
||||||
|
|
||||||
#endif /* __QEMU_BLOCK_H__ */
|
#endif /* __QEMU_BLOCK_H__ */
|
||||||
|
@ -1348,7 +1348,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (qemuDiskSourceNeedsProps(disk->src) &&
|
if (qemuDiskSourceNeedsProps(disk->src) &&
|
||||||
qemuGetDriveSourceProps(disk->src, &srcprops) < 0)
|
!(srcprops = qemuBlockStorageSourceGetBackendProps(disk->src)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!srcprops &&
|
if (!srcprops &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user