]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Allow migration with host USB devices
authorJiri Denemark <jdenemar@redhat.com>
Fri, 19 Oct 2012 11:36:33 +0000 (13:36 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 19 Oct 2012 12:18:26 +0000 (14:18 +0200)
Recently, patches were added support for (managed)saving, restoring, and
migrating domains with host USB devices. However, qemu driver would
still forbid migration of such domains because qemuMigrationIsAllowed
was not updated.

src/qemu/qemu_migration.c

index 65cd6ec5ea87cd0d340960c7622dd2a73f72e131..a2402ce2f474a65077d732d023ee390ba1a8ad60 100644 (file)
@@ -800,6 +800,8 @@ qemuMigrationIsAllowed(struct qemud_driver *driver, virDomainObjPtr vm,
                        virDomainDefPtr def)
 {
     int nsnapshots;
+    bool forbid;
+    int i;
 
     if (vm) {
         if (qemuProcessAutoDestroyActive(driver, vm)) {
@@ -817,9 +819,23 @@ qemuMigrationIsAllowed(struct qemud_driver *driver, virDomainObjPtr vm,
 
         def = vm->def;
     }
-    if (def->nhostdevs > 0) {
-        virReportError(VIR_ERR_OPERATION_INVALID,
-                       "%s", _("Domain with assigned host devices cannot be migrated"));
+
+    /* Migration with USB host devices is allowed, all other devices are
+     * forbidden.
+     */
+    forbid = false;
+    for (i = 0; i < def->nhostdevs; i++) {
+        virDomainHostdevDefPtr hostdev = def->hostdevs[i];
+        if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+            hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
+            forbid = true;
+            break;
+        }
+    }
+    if (forbid) {
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("Domain with assigned non-USB host devices "
+                         "cannot be migrated"));
         return false;
     }