]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Allow seamless migration for domains with multiple graphics
authorMartin Kletzander <mkletzan@redhat.com>
Mon, 1 Jul 2013 12:16:51 +0000 (14:16 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Wed, 3 Jul 2013 12:58:01 +0000 (14:58 +0200)
Since commit 23e8b5d8, the code is refactored in a way that supports
domains with multiple graphics elements and commit 37b415200 allows
starting such domains.  However none of those commits take migration
into account.  Even though qemu doesn't support relocation for
anything else than SPICE and for no more than one graphics, there is no
reason to hardcode one graphics into this part of the code as well.

src/qemu/qemu_migration.c

index 69d53981a59ce5e0ec9975d24147e541b10725ef..49e9e650018096d1197d7b9231a9a46418ac98cf 100644 (file)
@@ -427,19 +427,22 @@ qemuMigrationCookieAddGraphics(qemuMigrationCookiePtr mig,
                                virQEMUDriverPtr driver,
                                virDomainObjPtr dom)
 {
+    size_t i = 0;
+
     if (mig->flags & QEMU_MIGRATION_COOKIE_GRAPHICS) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Migration graphics data already present"));
         return -1;
     }
 
-    if (dom->def->ngraphics == 1 &&
-        (dom->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
-         dom->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE)) {
-        if (!(mig->graphics =
-              qemuMigrationCookieGraphicsAlloc(driver, dom->def->graphics[0])))
-            return -1;
-        mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS;
+    for (i = 0; i < dom->def->ngraphics; i++) {
+       if (dom->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
+           if (!(mig->graphics =
+                 qemuMigrationCookieGraphicsAlloc(driver, dom->def->graphics[i])))
+               return -1;
+           mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS;
+           break;
+       }
     }
 
     return 0;
@@ -1602,11 +1605,16 @@ qemuMigrationWaitForSpice(virQEMUDriverPtr driver,
     qemuDomainObjPrivatePtr priv = vm->privateData;
     bool wait_for_spice = false;
     bool spice_migrated = false;
+    size_t i = 0;
 
-    if (vm->def->ngraphics == 1 &&
-        vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
-        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_SEAMLESS_MIGRATION))
-        wait_for_spice = true;
+    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_SEAMLESS_MIGRATION)) {
+        for (i = 0; i < vm->def->ngraphics; i++) {
+            if (vm->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
+                wait_for_spice = true;
+                break;
+            }
+        }
+    }
 
     if (!wait_for_spice)
         return 0;