]> xenbits.xensource.com Git - libvirt.git/commitdiff
If there is a failure during Qemu offline migrate, make sure to resume the
authorChris Lalancette <clalance@redhat.com>
Fri, 27 Feb 2009 16:18:50 +0000 (16:18 +0000)
committerChris Lalancette <clalance@redhat.com>
Fri, 27 Feb 2009 16:18:50 +0000 (16:18 +0000)
guest.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
ChangeLog
src/qemu_driver.c

index cd15ce7969d5a0eb88af60e2c953dc3a6132cbdf..12715f5ce08684ab341fb43cbe88c388849ceb14 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Feb 27 17:15:00 CET 2009 Chris Lalancette <clalance@redhat.com>
+
+       * src/qemu_driver.c: If there is a failure during offline migrate,
+       make sure to resume the guest.
+
 Fri Feb 27 15:27:31 CET 2009 Daniel Veillard <veillard@redhat.com>
 
        * docs/libvirt-api.xml docs/libvirt-refs.xml
index a8a2ae723cd9825fdcac49c19ed3428c8c0fedbf..11782b458d8ca292111718f6f4d3a28fd00a15f2 100644 (file)
@@ -4331,6 +4331,7 @@ qemudDomainMigratePerform (virDomainPtr dom,
     char cmd[HOST_NAME_MAX+50];
     char *info = NULL;
     int ret = -1;
+    int paused = 0;
 
     qemuDriverLock(driver);
     vm = virDomainFindByID(&driver->domains, dom->id);
@@ -4348,10 +4349,14 @@ qemudDomainMigratePerform (virDomainPtr dom,
 
     if (!(flags & VIR_MIGRATE_LIVE)) {
         /* Pause domain for non-live migration */
-        snprintf(cmd, sizeof cmd, "%s", "stop");
-        qemudMonitorCommand (vm, cmd, &info);
+        if (qemudMonitorCommand (vm, "stop", &info) < 0) {
+            qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
+                             "%s", _("off-line migration specified, but suspend operation failed"));
+            goto cleanup;
+        }
         DEBUG ("stop reply: %s", info);
         VIR_FREE(info);
+        paused = 1;
 
         event = virDomainEventNewFromObj(vm,
                                          VIR_DOMAIN_EVENT_SUSPENDED,
@@ -4396,6 +4401,7 @@ qemudDomainMigratePerform (virDomainPtr dom,
 
     /* Clean up the source domain. */
     qemudShutdownVMDaemon (dom->conn, driver, vm);
+    paused = 0;
 
     event = virDomainEventNewFromObj(vm,
                                      VIR_DOMAIN_EVENT_STOPPED,
@@ -4407,7 +4413,31 @@ qemudDomainMigratePerform (virDomainPtr dom,
     ret = 0;
 
 cleanup:
+    /* Note that we have to free info *first*, since we are re-using the
+     * variable below (and otherwise might cause a memory leak)
+     */
     VIR_FREE(info);
+
+    if (paused) {
+        /* we got here through some sort of failure; start the domain again */
+        if (qemudMonitorCommand (vm, "cont", &info) < 0) {
+            /* Hm, we already know we are in error here.  We don't want to
+             * overwrite the previous error, though, so we just throw something
+             * to the logs and hope for the best
+             */
+            qemudLog(QEMUD_ERROR, _("Failed to resume guest %s after failure\n"),
+                     vm->def->name);
+        }
+        else {
+            DEBUG ("cont reply: %s", info);
+            VIR_FREE(info);
+        }
+
+        event = virDomainEventNewFromObj(vm,
+                                         VIR_DOMAIN_EVENT_RESUMED,
+                                         VIR_DOMAIN_EVENT_RESUMED_MIGRATED);
+    }
+
     if (vm)
         virDomainObjUnlock(vm);
     if (event)