[PATCH 3/3] qemu: migration: Check domain live state after exitting the monitor

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

 



In qemuMigrationToFile we enter the monitor multiple times and don't
check if the VM is still alive after returning form the monitor. Add the
checks to skip pieces of code in case the VM crashes while saving it's
state.
---
 src/qemu/qemu_migration.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 767d840..50a1eab 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -4731,6 +4731,13 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
         qemuDomainObjExitMonitor(driver, vm);
     }

+    if (!virDomainObjIsActive(vm)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("guest unexpectedly quit"));
+        /* nothing to tear down */
+        return -1;
+    }
+
     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
         (!compressor || pipe(pipeFD) == 0)) {
         /* All right! We can use fd migration, which means that qemu
@@ -4818,6 +4825,12 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
     }
     qemuDomainObjExitMonitor(driver, vm);

+    if (!virDomainObjIsActive(vm)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("guest unexpectedly quit"));
+        goto cleanup;
+    }
+
     if (rc < 0)
         goto cleanup;

@@ -4827,7 +4840,8 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
         if (rc == -2) {
             orig_err = virSaveLastError();
             virCommandAbort(cmd);
-            if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
+            if (virDomainObjIsActive(vm) &&
+                qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
                 qemuMonitorMigrateCancel(priv->mon);
                 qemuDomainObjExitMonitor(driver, vm);
             }
@@ -4845,7 +4859,8 @@ qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
         orig_err = virSaveLastError();

     /* Restore max migration bandwidth */
-    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
+    if (virDomainObjIsActive(vm) &&
+        qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
         qemuMonitorSetMigrationSpeed(priv->mon, saveMigBandwidth);
         priv->migMaxBandwidth = saveMigBandwidth;
         qemuDomainObjExitMonitor(driver, vm);
-- 
2.0.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]