]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
backends/iommufd: report error when /dev/iommu is not available
authorPierrick Bouvier <pierrick.bouvier@linaro.org>
Thu, 19 Mar 2026 20:59:41 +0000 (13:59 -0700)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Mon, 23 Mar 2026 16:48:06 +0000 (17:48 +0100)
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 completing an iommufd object, to
inform user that kernel does not support it, with a hint about missing
CONFIG_IOMMUFD. We can't do this from initialize as there is no way to
return an error, and we don't want to abort at this step.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Message-ID: <20260319205942.367705-2-pierrick.bouvier@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
backends/iommufd.c

index acfab907c0356bd3c96663505396fc881cb58eee..e1fee16acf2e15ad1e9066aa32a270bb3945b52d 100644 (file)
@@ -82,6 +82,9 @@ static void iommufd_backend_complete(UserCreatable *uc, Error **errp)
         } else {
             cpr_save_fd(name, 0, be->fd);
         }
+    } else if (!g_file_test("/dev/iommu", G_FILE_TEST_EXISTS)) {
+        error_setg(errp, "/dev/iommu does not exist"
+                         " (is your kernel config missing CONFIG_IOMMUFD?)");
     }
 }