Use the checking functions to verify that the host supports PCI
passthrough before attempting it.
---
 src/qemu/qemu_hotplug.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 728c734..9320ab9 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1152,6 +1152,12 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr 
driver,
             goto error;
         }

+        if (!qemuHostdevHostSupportsPassthroughVFIO()) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("host doesn't support VFIO PCI passthrough"));
+            goto error;
+        }
+
         /* VFIO requires all of the guest's memory to be locked resident.
          * In this case, the guest's memory may already be locked, but it
          * doesn't hurt to "change" the limit to the same value.
@@ -1166,6 +1172,14 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr 
driver,

     case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT:
     case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:
+        if (!qemuHostdevHostSupportsPassthroughLegacy()) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("host doesn't support legacy PCI passthrough"));
+            goto error;
+        }
+
+        break;
+
     case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
         break;
     }
-- 
1.8.3.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to