]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: hotplug: Remove overlay of <transient> disk on disk unplug
authorPeter Krempa <pkrempa@redhat.com>
Tue, 22 Sep 2020 12:53:57 +0000 (14:53 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 1 Oct 2020 07:55:02 +0000 (09:55 +0200)
Remove the overlay if the disk was <transient/>. Note that even if we'd
forbid unplug of such a disk through the API, the disk can still be
ejected from the guest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_hotplug.c

index ed4d1580fafa88b26261f2ceceb7a3d1b3191d52..11b549b12bacf30f97473eb6074046ab37474c4e 100644 (file)
@@ -4313,6 +4313,15 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
         qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
         goto cleanup;
 
+    if (disk->transient) {
+        VIR_DEBUG("Removing transient overlay '%s' of disk '%s'",
+                  disk->src->path, disk->dst);
+        if (qemuDomainStorageFileInit(driver, vm, disk->src, NULL) >= 0) {
+            virStorageFileUnlink(disk->src);
+            virStorageFileDeinit(disk->src);
+        }
+    }
+
     ret = 0;
 
  cleanup: