Normally a PCI hostdev can't be migrated, so
qemuMigrationSrcIsAllowedHostdev() won't permit it. In the case of a
PCI hostdev that has the backupAlias attribute 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(a)redhat.com>
---
src/qemu/qemu_migration.c | 48 +++++++++++++++++++++++++++++++++++----
1 file changed, 44 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 29d228a8d9..f675b445d5 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1093,10 +1093,50 @@ 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 a backupAlias is defined, the device will be auto-unplugged
+ * during migration.
+ */
+ if (hostdev->source.subsys.u.pci.backupAlias)
+ 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.24.1