From: Peter Krempa Date: Mon, 28 May 2018 13:31:42 +0000 (+0200) Subject: qemu: domain: Don't delete aliases of secret objects associated with disks X-Git-Tag: v4.5.0-rc1~341 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04c890cc8bdba8ca2c0567ec5ba75a83e15b97ed;p=thirdparty%2Flibvirt.git qemu: domain: Don't delete aliases of secret objects associated with disks We need to reference the secret objects by name when hot-unplugging disks. Don't remove the alias so that it does not need to be recalculated. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f72c49f392..0c90fead29 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1440,31 +1440,23 @@ qemuDomainSecretInfoTLSNew(qemuDomainObjPrivatePtr priv, } -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 * - * Clear and destroy memory associated with the secret + * Clears unnecessary data associated with disk secret objects. */ void qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk) { - virStorageSourcePtr next; + qemuDomainStorageSourcePrivatePtr srcPriv; + virStorageSourcePtr n; - for (next = disk->src; virStorageSourceIsBacking(next); next = next->backingStore) - qemuDomainSecretStorageSourceDestroy(next); + for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) { + if ((srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(n))) { + qemuDomainSecretInfoDestroy(srcPriv->secinfo); + qemuDomainSecretInfoDestroy(srcPriv->encinfo); + } + } } @@ -1698,8 +1690,7 @@ qemuDomainSecretChardevPrepare(virQEMUDriverConfigPtr cfg, /* qemuDomainSecretDestroy: * @vm: Domain object * - * Once completed with the generation of the command line it is - * expect to remove the secrets + * Removes all unnecessary data which was needed to generate 'secret' objects. */ void qemuDomainSecretDestroy(virDomainObjPtr vm)