[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [RFC v1 3/6] qemu: add check ephemeral devices only for PCI host devices



currently, we only support PCI host devices with ephemeral flag.
and USB already supports migration. so maybe in the near future we
can support SCSI.

Signed-off-by: Chen Fan <chen fan fnst cn fujitsu com>
---
 src/qemu/qemu_command.c   | 10 ++++++++++
 src/qemu/qemu_migration.c | 11 +++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fc81214..5acd8b4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10182,6 +10182,16 @@ qemuBuildCommandLine(virConnectPtr conn,
 
         /* PCI */
         if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+            hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB &&
+            (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
+             hostdev->ephemeral)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("non-USB and non-PCI device assignment with ephemeral "
+                             "flag are not supported by this version of qemu"));
+            goto error;
+        }
+
+        if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
             hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
             int backend = hostdev->source.subsys.u.pci.backend;
 
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 83be435..56112f9 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1981,21 +1981,24 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
         def = vm->def;
     }
 
-    /* Migration with USB host devices is allowed, all other devices are
-     * forbidden.
+    /*
+     * Migration with USB and ephemeral PCI host devices host devices are 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) {
+            (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB &&
+            !hostdev->ephemeral)) {
             forbid = true;
             break;
         }
     }
     if (forbid) {
         virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-                       _("domain has assigned non-USB host devices"));
+                       _("domain has assigned non-USB and "
+                         "non-ephemeral host devices"));
         return false;
     }
 
-- 
1.9.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]