render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From a86311164657b4bc304705b1dd5cea3db83c7c12 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <a86311164657b4bc304705b1dd5cea3db83c7c12@dist-git>
a41c76
From: Laine Stump <laine@redhat.com>
a41c76
Date: Thu, 30 Jan 2020 14:12:42 -0500
a41c76
Subject: [PATCH] qemu: allow migration with assigned PCI hostdev if <teaming>
a41c76
 is set
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Normally a PCI hostdev can't be migrated, so
a41c76
qemuMigrationSrcIsAllowedHostdev() won't permit it. In the case of a a
a41c76
hostdev network interface that has <teaming type='transient'/> set,
a41c76
QEMU will automatically unplug the device prior to migration, and
a41c76
re-plug a corresponding device on the destination. This patch modifies
a41c76
qemuMigrationSrcIsAllowedHostdev() to allow domains with those devices
a41c76
to be migrated.
a41c76
a41c76
Signed-off-by: Laine Stump <laine@redhat.com>
a41c76
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
a41c76
(cherry picked from commit 2758f680b7d586baf084f340b153d7706b8ce12b)
a41c76
a41c76
https://bugzilla.redhat.com/1693587
a41c76
Signed-off-by: Laine Stump <laine@redhat.com>
a41c76
Message-Id: <20200130191244.24174-5-laine@redhat.com>
a41c76
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_migration.c | 52 ++++++++++++++++++++++++++++++++++++---
a41c76
 1 file changed, 48 insertions(+), 4 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
a41c76
index 29d228a8d9..46612a3c84 100644
a41c76
--- a/src/qemu/qemu_migration.c
a41c76
+++ b/src/qemu/qemu_migration.c
a41c76
@@ -1093,10 +1093,54 @@ qemuMigrationSrcIsAllowedHostdev(const virDomainDef *def)
a41c76
      * forbidden. */
a41c76
     for (i = 0; i < def->nhostdevs; i++) {
a41c76
         virDomainHostdevDefPtr hostdev = def->hostdevs[i];
a41c76
-        if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
a41c76
-            hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
a41c76
-            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
a41c76
-                           _("domain has assigned non-USB host devices"));
a41c76
+        switch ((virDomainHostdevMode)hostdev->mode) {
a41c76
+        case VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES:
a41c76
+            virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
a41c76
+                           _("cannot migrate a domain with <hostdev mode='capabilities'>"));
a41c76
+            return false;
a41c76
+
a41c76
+        case VIR_DOMAIN_HOSTDEV_MODE_SUBSYS:
a41c76
+            switch ((virDomainHostdevSubsysType)hostdev->source.subsys.type) {
a41c76
+            case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
a41c76
+                /* USB devices can be "migrated" */
a41c76
+                continue;
a41c76
+
a41c76
+            case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
a41c76
+            case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
a41c76
+            case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
a41c76
+                virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
a41c76
+                               _("cannot migrate a domain with <hostdev mode='subsystem' type='%s'>"),
a41c76
+                               virDomainHostdevSubsysTypeToString(hostdev->source.subsys.type));
a41c76
+                return false;
a41c76
+
a41c76
+            case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
a41c76
+                /*
a41c76
+                 * if this is a network interface with 
a41c76
+                 * type='transient'>, migration *is* allowed because
a41c76
+                 * the device will be auto-unplugged by QEMU during
a41c76
+                 * migration.
a41c76
+                 */
a41c76
+                if (hostdev->parentnet &&
a41c76
+                    hostdev->parentnet->teaming.type == VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT) {
a41c76
+                    continue;
a41c76
+                }
a41c76
+
a41c76
+                /* all other PCI hostdevs can't be migrated */
a41c76
+                virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
a41c76
+                               _("cannot migrate a domain with <hostdev mode='subsystem' type='%s'>"),
a41c76
+                               virDomainHostdevSubsysTypeToString(hostdev->source.subsys.type));
a41c76
+                return false;
a41c76
+
a41c76
+            case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
a41c76
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
a41c76
+                               _("invalid hostdev subsystem type"));
a41c76
+                return false;
a41c76
+            }
a41c76
+            break;
a41c76
+
a41c76
+        case VIR_DOMAIN_HOSTDEV_MODE_LAST:
a41c76
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
a41c76
+                           _("invalid hostdev mode"));
a41c76
             return false;
a41c76
         }
a41c76
     }
a41c76
-- 
a41c76
2.25.0
a41c76