libvirt/SOURCES/libvirt-qemu-allow-migration-with-assigned-PCI-hostdev-if-teaming-is-set.patch

97 lines
4.2 KiB
Diff
Raw Normal View History

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