qemu: domain: Destroy secrets for complete backing chain

This commit is contained in:
Peter Krempa 2017-10-20 14:16:28 +02:00
parent e53a42f0f6
commit d565877312

View File

@ -1325,6 +1325,19 @@ qemuDomainSecretInfoTLSNew(virConnectPtr conn,
}
static void
qemuDomainSecretStorageSourceDestroy(virStorageSourcePtr src)
{
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
if (srcPriv && srcPriv->secinfo)
qemuDomainSecretInfoFree(&srcPriv->secinfo);
if (srcPriv && srcPriv->encinfo)
qemuDomainSecretInfoFree(&srcPriv->encinfo);
}
/* qemuDomainSecretDiskDestroy:
* @disk: Pointer to a disk definition
*
@ -1333,13 +1346,10 @@ qemuDomainSecretInfoTLSNew(virConnectPtr conn,
void
qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
{
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
virStorageSourcePtr next;
if (srcPriv && srcPriv->secinfo)
qemuDomainSecretInfoFree(&srcPriv->secinfo);
if (srcPriv && srcPriv->encinfo)
qemuDomainSecretInfoFree(&srcPriv->encinfo);
for (next = disk->src; virStorageSourceIsBacking(next); next = next->backingStore)
qemuDomainSecretStorageSourceDestroy(next);
}