[PATCH v4 07/11] qemu: hotplug: Remove overlay of <transient> disk on disk unplug

Peter Krempa pkrempa at redhat.com
Thu Sep 24 11:43:54 UTC 2020


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 at redhat.com>
---
 src/qemu/qemu_hotplug.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index ed4d1580fa..11b549b12b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -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:
-- 
2.26.2




More information about the libvir-list mailing list