]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Make migration fail when port profile association fails on the dst host
authorChristian Benvenuti <benve@cisco.com>
Tue, 27 Mar 2012 20:00:01 +0000 (13:00 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 28 Mar 2012 16:45:22 +0000 (10:45 -0600)
In the current V3 migration protocol, Libvirt does not
check the result of the function

  qemuMigrationVPAssociatePortProfiles

This means that it is possible for a migration to complete
successfully even when the VM loses network connectivity on
the destination host.

With this change libvirt aborts the migration
(during the "finish" step) when the above function fails, that
is to say when at least one of the port profile associations fails.

Signed-off by: Christian Benvenuti <benve@cisco.com>

AUTHORS
src/qemu/qemu_migration.c

diff --git a/AUTHORS b/AUTHORS
index 881a8c155208a62994b2390a655d32af5f420794..33154400a2321efa07064c7dca4ee9e481b73c3f 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -227,6 +227,7 @@ Patches have also been contributed by:
   Peng Zhou            <ailvpeng25@gmail.com>
   Li Zhang             <zhlcindy@linux.vnet.ibm.com>
   Stef Walter          <stefw@gnome.org>
+  Christian Benvenuti  <benve@cisco.com>
 
   [....send patches to get your name here....]
 
index 802785f3412f6f88c6bd8da2d30a10f57637ea86..49a260de2f3003f82f3652ebf6684ef028386b22 100644 (file)
@@ -2716,7 +2716,7 @@ qemuMigrationPerform(struct qemud_driver *driver,
     }
 }
 
-static void
+static int
 qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def) {
     int i;
     int last_good_net = -1;
@@ -2731,13 +2731,19 @@ qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def) {
                                                virDomainNetGetActualDirectDev(net),
                                                -1,
                                                def->uuid,
-                                               VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_FINISH, false) < 0)
+                                               VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_FINISH,
+                                               false) < 0) {
+                qemuReportError(VIR_ERR_OPERATION_FAILED,
+                                _("Port profile Associate failed for %s"),
+                                net->ifname);
                 goto err_exit;
+            }
+            VIR_DEBUG("Port profile Associate succeeded for %s", net->ifname);
         }
         last_good_net = i;
     }
 
-    return;
+    return 0;
 
 err_exit:
     for (i = 0; i < last_good_net; i++) {
@@ -2751,6 +2757,7 @@ err_exit:
                                                            VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_FINISH));
         }
     }
+    return -1;
 }
 
 
@@ -2805,7 +2812,14 @@ qemuMigrationFinish(struct qemud_driver *driver,
             goto endjob;
         }
 
-        qemuMigrationVPAssociatePortProfiles(vm->def);
+        if (qemuMigrationVPAssociatePortProfiles(vm->def) < 0) {
+            qemuProcessStop(driver, vm, 1, VIR_DOMAIN_SHUTOFF_FAILED);
+            virDomainAuditStop(vm, "failed");
+            event = virDomainEventNewFromObj(vm,
+                                             VIR_DOMAIN_EVENT_STOPPED,
+                                             VIR_DOMAIN_EVENT_STOPPED_FAILED);
+            goto endjob;
+        }
 
         if (flags & VIR_MIGRATE_PERSIST_DEST) {
             virDomainDefPtr vmdef;