[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH v3 6/6] qemu: Add transient disk handler to start and stop the guest



From: Masayoshi Mizuma <m mizuma jp fujitsu com>

The transient disk is attached before the guest starts.
Remove the transient disk when the guest does shutdown.

Signed-off-by: Masayoshi Mizuma <m mizuma jp fujitsu com>
---
 src/qemu/qemu_process.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index b1af35b933..387b8071f4 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -60,6 +60,7 @@
 #include "qemu_firmware.h"
 #include "qemu_backup.h"
 #include "qemu_dbus.h"
+#include "qemu_snapshot.h"
 
 #include "cpu/cpu.h"
 #include "cpu/cpu_x86.h"
@@ -7053,6 +7054,10 @@ qemuProcessLaunch(virConnectPtr conn,
         qemuProcessAutoDestroyAdd(driver, vm, conn) < 0)
         goto cleanup;
 
+    VIR_DEBUG("Setting up transient disk");
+    if (qemuSnapshotCreateTransientDisk(driver, vm, asyncJob) < 0)
+        goto cleanup;
+
     ret = 0;
 
  cleanup:
@@ -7689,6 +7694,11 @@ void qemuProcessStop(virQEMUDriverPtr driver,
             }
 
             qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->src);
+
+            if ((disk->transient) && (disk->src->transientEstablished)) {
+                VIR_DEBUG("unlink transient disk: %s", disk->src->path);
+                unlink(disk->src->path);
+            }
         }
     }
 
-- 
2.27.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]