]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: domain: Don't delete aliases of secret objects associated with disks
authorPeter Krempa <pkrempa@redhat.com>
Mon, 28 May 2018 13:31:42 +0000 (15:31 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 5 Jun 2018 06:11:12 +0000 (08:11 +0200)
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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain.c

index f72c49f39251b47479b458b28d424466ca7ac904..0c90fead298f75edd73ac1cf1c9b6158da87ed36 100644 (file)
@@ -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)