In case current kernel does not support /dev/iommu, qemu will probably fail first because /sys/bus/pci/devices/*/vfio-dev/ is not present, since QEMU opens it before /dev/iommu.
Instead, report an error directly when initializing iommufd object, to inform user that kernel does not support it, with a hint about missing CONFIG_IOMMUFD. Signed-off-by: Pierrick Bouvier <[email protected]> --- backends/iommufd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backends/iommufd.c b/backends/iommufd.c index acfab907c03..c4eb3de1307 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -32,6 +32,11 @@ static void iommufd_backend_init(Object *obj) { IOMMUFDBackend *be = IOMMUFD_BACKEND(obj); + if (!g_file_test("/dev/iommu", G_FILE_TEST_EXISTS)) { + error_setg(&error_fatal, "/dev/iommu does not exist" + " (is your kernel config missing CONFIG_IOMMUFD?)"); + } + be->fd = -1; be->users = 0; be->owned = true; -- 2.47.3
