]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Prohibit migration of guests with host devices
authorJiri Denemark <jdenemar@redhat.com>
Wed, 13 Oct 2010 13:51:50 +0000 (15:51 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 14 Oct 2010 07:36:54 +0000 (09:36 +0200)
Explicitly raising a nice error in the case user tries to migrate a
guest with assigned host devices is much better than waiting for a
mysterious error with no clue for the reason.

src/qemu/qemu_driver.c

index f68995fc42b808b2edd2c9c3fe6ed7e431e7c014..16f34f70c2e3016e67a4034ac7935556c5665509 100644 (file)
@@ -10380,6 +10380,19 @@ static void qemuDomainEventQueue(struct qemud_driver *driver,
 
 /* Migration support. */
 
+static bool ATTRIBUTE_NONNULL(1)
+qemuDomainIsMigratable(virDomainDefPtr def)
+{
+    if (def->nhostdevs > 0) {
+        qemuReportError(VIR_ERR_OPERATION_INVALID,
+                _("Domain with assigned host devices cannot be migrated"));
+        return false;
+    }
+
+    return true;
+}
+
+
 /* Tunnelled migration stream support */
 struct qemuStreamMigFile {
     int fd;
@@ -10709,6 +10722,9 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn,
         goto cleanup;
     }
 
+    if (!qemuDomainIsMigratable(def))
+        goto cleanup;
+
     /* Target domain name, maybe renamed. */
     if (dname) {
         VIR_FREE(def->name);
@@ -10976,6 +10992,9 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
         goto cleanup;
     }
 
+    if (!qemuDomainIsMigratable(def))
+        goto cleanup;
+
     /* Target domain name, maybe renamed. */
     if (dname) {
         VIR_FREE(def->name);