mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 13:05:27 +00:00
qemu: block: Introduce and use AUTOPTR func for qemuBlockStorageSourceAttachDataPtr
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
e0befb78b1
commit
1d2eb86682
@ -1543,7 +1543,7 @@ qemuBlockStorageSourceAttachDataFree(qemuBlockStorageSourceAttachDataPtr data)
|
||||
qemuBlockStorageSourceAttachDataPtr
|
||||
qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src)
|
||||
{
|
||||
qemuBlockStorageSourceAttachDataPtr data;
|
||||
VIR_AUTOPTR(qemuBlockStorageSourceAttachData) data = NULL;
|
||||
qemuBlockStorageSourceAttachDataPtr ret = NULL;
|
||||
|
||||
if (VIR_ALLOC(data) < 0)
|
||||
@ -1559,7 +1559,6 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src)
|
||||
VIR_STEAL_PTR(ret, data);
|
||||
|
||||
cleanup:
|
||||
qemuBlockStorageSourceAttachDataFree(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,9 @@ struct qemuBlockStorageSourceAttachData {
|
||||
void
|
||||
qemuBlockStorageSourceAttachDataFree(qemuBlockStorageSourceAttachDataPtr data);
|
||||
|
||||
VIR_DEFINE_AUTOPTR_FUNC(qemuBlockStorageSourceAttachData,
|
||||
qemuBlockStorageSourceAttachDataFree);
|
||||
|
||||
qemuBlockStorageSourceAttachDataPtr
|
||||
qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src);
|
||||
|
||||
|
@ -2554,7 +2554,7 @@ qemuBuildDiskSourceCommandLine(virCommandPtr cmd,
|
||||
{
|
||||
qemuBlockStorageSourceAttachDataPtr *data = NULL;
|
||||
size_t ndata = 0;
|
||||
qemuBlockStorageSourceAttachDataPtr tmp = NULL;
|
||||
VIR_AUTOPTR(qemuBlockStorageSourceAttachData) tmp = NULL;
|
||||
virJSONValuePtr copyOnReadProps = NULL;
|
||||
virStorageSourcePtr n;
|
||||
char *str = NULL;
|
||||
@ -2613,7 +2613,6 @@ qemuBuildDiskSourceCommandLine(virCommandPtr cmd,
|
||||
for (i = 0; i < ndata; i++)
|
||||
qemuBlockStorageSourceAttachDataFree(data[i]);
|
||||
VIR_FREE(data);
|
||||
qemuBlockStorageSourceAttachDataFree(tmp);
|
||||
virJSONValueFree(copyOnReadProps);
|
||||
VIR_FREE(str);
|
||||
return ret;
|
||||
@ -11162,18 +11161,19 @@ qemuBlockStorageSourceAttachDataPtr
|
||||
qemuBuildStorageSourceAttachPrepareDrive(virDomainDiskDefPtr disk,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
qemuBlockStorageSourceAttachDataPtr data = NULL;
|
||||
VIR_AUTOPTR(qemuBlockStorageSourceAttachData) data = NULL;
|
||||
qemuBlockStorageSourceAttachDataPtr ret = NULL;
|
||||
|
||||
if (VIR_ALLOC(data) < 0)
|
||||
return NULL;
|
||||
|
||||
if (!(data->driveCmd = qemuBuildDriveStr(disk, qemuCaps)) ||
|
||||
!(data->driveAlias = qemuAliasDiskDriveFromDisk(disk))) {
|
||||
qemuBlockStorageSourceAttachDataFree(data);
|
||||
!(data->driveAlias = qemuAliasDiskDriveFromDisk(disk)))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return data;
|
||||
VIR_STEAL_PTR(ret, data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -531,7 +531,7 @@ qemuHotplugRemoveStorageSourcePrepareData(virStorageSourcePtr src,
|
||||
|
||||
{
|
||||
qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
|
||||
qemuBlockStorageSourceAttachDataPtr data;
|
||||
VIR_AUTOPTR(qemuBlockStorageSourceAttachData) data = NULL;
|
||||
qemuBlockStorageSourceAttachDataPtr ret = NULL;
|
||||
|
||||
if (VIR_ALLOC(data) < 0)
|
||||
@ -571,7 +571,6 @@ qemuHotplugRemoveStorageSourcePrepareData(virStorageSourcePtr src,
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(driveAlias);
|
||||
qemuBlockStorageSourceAttachDataFree(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -582,7 +581,7 @@ qemuHotplugDiskSourceRemovePrepare(virDomainDiskDefPtr disk,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||
qemuBlockStorageSourceAttachDataPtr backend = NULL;
|
||||
VIR_AUTOPTR(qemuBlockStorageSourceAttachData) backend = NULL;
|
||||
qemuHotplugDiskSourceDataPtr data = NULL;
|
||||
qemuHotplugDiskSourceDataPtr ret = NULL;
|
||||
char *drivealias = NULL;
|
||||
@ -617,7 +616,6 @@ qemuHotplugDiskSourceRemovePrepare(virDomainDiskDefPtr disk,
|
||||
VIR_STEAL_PTR(ret, data);
|
||||
|
||||
cleanup:
|
||||
qemuBlockStorageSourceAttachDataFree(backend);
|
||||
qemuHotplugDiskSourceDataFree(data);
|
||||
return ret;
|
||||
}
|
||||
@ -637,7 +635,7 @@ qemuHotplugDiskSourceAttachPrepare(virDomainDiskDefPtr disk,
|
||||
virStorageSourcePtr src,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
qemuBlockStorageSourceAttachDataPtr backend = NULL;
|
||||
VIR_AUTOPTR(qemuBlockStorageSourceAttachData) backend = NULL;
|
||||
qemuHotplugDiskSourceDataPtr data;
|
||||
qemuHotplugDiskSourceDataPtr ret = NULL;
|
||||
virStorageSourcePtr savesrc = NULL;
|
||||
@ -683,7 +681,6 @@ qemuHotplugDiskSourceAttachPrepare(virDomainDiskDefPtr disk,
|
||||
if (savesrc)
|
||||
VIR_STEAL_PTR(disk->src, savesrc);
|
||||
|
||||
qemuBlockStorageSourceAttachDataFree(backend);
|
||||
qemuHotplugDiskSourceDataFree(data);
|
||||
return ret;
|
||||
}
|
||||
|
@ -787,7 +787,7 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr driver,
|
||||
unsigned int mirror_flags,
|
||||
const char *tlsAlias)
|
||||
{
|
||||
qemuBlockStorageSourceAttachDataPtr data = NULL;
|
||||
VIR_AUTOPTR(qemuBlockStorageSourceAttachData) data = NULL;
|
||||
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||
int mon_ret = 0;
|
||||
int ret = -1;
|
||||
@ -849,7 +849,6 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr driver,
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
qemuBlockStorageSourceAttachDataFree(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user