* [PATCH v2 0/2] iommufd: give hints to user about kernel support
@ 2026-03-18 18:06 Pierrick Bouvier
2026-03-18 18:06 ` [PATCH v2 1/2] backends/iommufd.c: report error when /dev/iommu is not available Pierrick Bouvier
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Pierrick Bouvier @ 2026-03-18 18:06 UTC (permalink / raw)
To: qemu-devel
Cc: Cédric Le Goater, Yi Liu, Eric Auger, Zhenzhong Duan,
Alex Williamson, philmd, Pierrick Bouvier
Using iommufd requires two different kernel config:
CONFIG_IOMMUFD and CONFIG_VFIO_DEVICE_CDEV
https://docs.kernel.org/driver-api/vfio.html#vfio-device-cdev
It can be complex to identify what is missing when trying to use it. This series
gives hints to user about it.
Suggested on:
https://lore.kernel.org/qemu-devel/0cc139d6-9289-44a0-9122-d701426dae0c@linaro.org/
Tested using a cross compiled QEMU and a custom kernel + debian rootfs [1].
[1] https://github.com/p-b-o/qemu-linux-stack/tree/device_passthrough
v2
--
- Move /dev/iommu to iommufd_backend_complete, so we can report the error
instead of aborting.
Pierrick Bouvier (2):
backends/iommufd.c: report error when /dev/iommu is not available
hw/vfio/iommufd.c: report hint to user when vfio-dev/vfio*/dev is
missing
backends/iommufd.c | 6 ++++++
hw/vfio/iommufd.c | 5 ++++-
2 files changed, 10 insertions(+), 1 deletion(-)
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] backends/iommufd.c: report error when /dev/iommu is not available
2026-03-18 18:06 [PATCH v2 0/2] iommufd: give hints to user about kernel support Pierrick Bouvier
@ 2026-03-18 18:06 ` Pierrick Bouvier
2026-03-19 6:52 ` Cédric Le Goater
2026-03-19 8:35 ` Duan, Zhenzhong
2026-03-18 18:06 ` [PATCH v2 2/2] hw/vfio/iommufd.c: report hint to user when vfio-dev/vfio*/dev is missing Pierrick Bouvier
2026-03-19 21:02 ` [PATCH v2 0/2] iommufd: give hints to user about kernel support Pierrick Bouvier
2 siblings, 2 replies; 7+ messages in thread
From: Pierrick Bouvier @ 2026-03-18 18:06 UTC (permalink / raw)
To: qemu-devel
Cc: Cédric Le Goater, Yi Liu, Eric Auger, Zhenzhong Duan,
Alex Williamson, philmd, Pierrick Bouvier
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>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
backends/iommufd.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/backends/iommufd.c b/backends/iommufd.c
index acfab907c03..2c3ca23ca0f 100644
--- a/backends/iommufd.c
+++ b/backends/iommufd.c
@@ -72,6 +72,12 @@ static bool iommufd_backend_can_be_deleted(UserCreatable *uc)
static void iommufd_backend_complete(UserCreatable *uc, Error **errp)
{
+ 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?)");
+ return;
+ }
+
IOMMUFDBackend *be = IOMMUFD_BACKEND(uc);
const char *name = iommufd_fd_name(be);
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] hw/vfio/iommufd.c: report hint to user when vfio-dev/vfio*/dev is missing
2026-03-18 18:06 [PATCH v2 0/2] iommufd: give hints to user about kernel support Pierrick Bouvier
2026-03-18 18:06 ` [PATCH v2 1/2] backends/iommufd.c: report error when /dev/iommu is not available Pierrick Bouvier
@ 2026-03-18 18:06 ` Pierrick Bouvier
2026-03-19 21:02 ` [PATCH v2 0/2] iommufd: give hints to user about kernel support Pierrick Bouvier
2 siblings, 0 replies; 7+ messages in thread
From: Pierrick Bouvier @ 2026-03-18 18:06 UTC (permalink / raw)
To: qemu-devel
Cc: Cédric Le Goater, Yi Liu, Eric Auger, Zhenzhong Duan,
Alex Williamson, philmd, Pierrick Bouvier
Give a hint about missing kernel config CONFIG_VFIO_DEVICE_CDEV.
Reviewed-by: Yi Liu <yi.l.liu@intel.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
hw/vfio/iommufd.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index 131612eb836..3e33dfbb356 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -274,7 +274,10 @@ static int iommufd_cdev_getfd(const char *sysfs_path, Error **errp)
}
if (!g_file_get_contents(vfio_dev_path, &contents, &length, NULL)) {
- error_setg(errp, "failed to load \"%s\"", vfio_dev_path);
+ error_setg(errp,
+ "failed to load \"%s\""
+ " (is your kernel config missing CONFIG_VFIO_DEVICE_CDEV?)",
+ vfio_dev_path);
goto out_close_dir;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] backends/iommufd.c: report error when /dev/iommu is not available
2026-03-18 18:06 ` [PATCH v2 1/2] backends/iommufd.c: report error when /dev/iommu is not available Pierrick Bouvier
@ 2026-03-19 6:52 ` Cédric Le Goater
2026-03-19 8:35 ` Duan, Zhenzhong
1 sibling, 0 replies; 7+ messages in thread
From: Cédric Le Goater @ 2026-03-19 6:52 UTC (permalink / raw)
To: Pierrick Bouvier, qemu-devel
Cc: Yi Liu, Eric Auger, Zhenzhong Duan, Alex Williamson, philmd
On 3/18/26 19:06, Pierrick Bouvier wrote:
> 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>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
> backends/iommufd.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/backends/iommufd.c b/backends/iommufd.c
> index acfab907c03..2c3ca23ca0f 100644
> --- a/backends/iommufd.c
> +++ b/backends/iommufd.c
> @@ -72,6 +72,12 @@ static bool iommufd_backend_can_be_deleted(UserCreatable *uc)
>
> static void iommufd_backend_complete(UserCreatable *uc, Error **errp)
> {
> + 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?)");
> + return;
> + }
> +
> IOMMUFDBackend *be = IOMMUFD_BACKEND(uc);
> const char *name = iommufd_fd_name(be);
>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Thanks,
C.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH v2 1/2] backends/iommufd.c: report error when /dev/iommu is not available
2026-03-18 18:06 ` [PATCH v2 1/2] backends/iommufd.c: report error when /dev/iommu is not available Pierrick Bouvier
2026-03-19 6:52 ` Cédric Le Goater
@ 2026-03-19 8:35 ` Duan, Zhenzhong
2026-03-19 20:57 ` Pierrick Bouvier
1 sibling, 1 reply; 7+ messages in thread
From: Duan, Zhenzhong @ 2026-03-19 8:35 UTC (permalink / raw)
To: Pierrick Bouvier, qemu-devel@nongnu.org
Cc: Cédric Le Goater, Liu, Yi L, Eric Auger, Alex Williamson,
philmd@linaro.org
>-----Original Message-----
>From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>Subject: [PATCH v2 1/2] backends/iommufd.c: report error when /dev/iommu is
>not available
>
>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>
>Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>---
> backends/iommufd.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
>diff --git a/backends/iommufd.c b/backends/iommufd.c
>index acfab907c03..2c3ca23ca0f 100644
>--- a/backends/iommufd.c
>+++ b/backends/iommufd.c
>@@ -72,6 +72,12 @@ static bool
>iommufd_backend_can_be_deleted(UserCreatable *uc)
>
> static void iommufd_backend_complete(UserCreatable *uc, Error **errp)
> {
>+ 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?)");
>+ return;
>+ }
>+
> IOMMUFDBackend *be = IOMMUFD_BACKEND(uc);
> const char *name = iommufd_fd_name(be);
I think more accurately it could be:
@@ -82,7 +82,12 @@ 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?)");
+ return;
}
+
}
Thanks
Zhenzhong
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] backends/iommufd.c: report error when /dev/iommu is not available
2026-03-19 8:35 ` Duan, Zhenzhong
@ 2026-03-19 20:57 ` Pierrick Bouvier
0 siblings, 0 replies; 7+ messages in thread
From: Pierrick Bouvier @ 2026-03-19 20:57 UTC (permalink / raw)
To: Duan, Zhenzhong, qemu-devel@nongnu.org
Cc: Cédric Le Goater, Liu, Yi L, Eric Auger, Alex Williamson,
philmd@linaro.org
On 3/19/26 1:35 AM, Duan, Zhenzhong wrote:
>
>
>> -----Original Message-----
>> From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> Subject: [PATCH v2 1/2] backends/iommufd.c: report error when /dev/iommu is
>> not available
>>
>> 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>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>> backends/iommufd.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/backends/iommufd.c b/backends/iommufd.c
>> index acfab907c03..2c3ca23ca0f 100644
>> --- a/backends/iommufd.c
>> +++ b/backends/iommufd.c
>> @@ -72,6 +72,12 @@ static bool
>> iommufd_backend_can_be_deleted(UserCreatable *uc)
>>
>> static void iommufd_backend_complete(UserCreatable *uc, Error **errp)
>> {
>> + 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?)");
>> + return;
>> + }
>> +
>> IOMMUFDBackend *be = IOMMUFD_BACKEND(uc);
>> const char *name = iommufd_fd_name(be);
>
> I think more accurately it could be:
>
> @@ -82,7 +82,12 @@ 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?)");
> + return;
> }
> +
> }
>
> Thanks
> Zhenzhong
Good for me, will send v3.
Regards,
Pierrick
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] iommufd: give hints to user about kernel support
2026-03-18 18:06 [PATCH v2 0/2] iommufd: give hints to user about kernel support Pierrick Bouvier
2026-03-18 18:06 ` [PATCH v2 1/2] backends/iommufd.c: report error when /dev/iommu is not available Pierrick Bouvier
2026-03-18 18:06 ` [PATCH v2 2/2] hw/vfio/iommufd.c: report hint to user when vfio-dev/vfio*/dev is missing Pierrick Bouvier
@ 2026-03-19 21:02 ` Pierrick Bouvier
2 siblings, 0 replies; 7+ messages in thread
From: Pierrick Bouvier @ 2026-03-19 21:02 UTC (permalink / raw)
To: qemu-devel
Cc: Cédric Le Goater, Yi Liu, Eric Auger, Zhenzhong Duan,
Alex Williamson, philmd
On 3/18/26 11:06 AM, Pierrick Bouvier wrote:
> Using iommufd requires two different kernel config:
> CONFIG_IOMMUFD and CONFIG_VFIO_DEVICE_CDEV
> https://docs.kernel.org/driver-api/vfio.html#vfio-device-cdev
>
> It can be complex to identify what is missing when trying to use it. This series
> gives hints to user about it.
>
> Suggested on:
> https://lore.kernel.org/qemu-devel/0cc139d6-9289-44a0-9122-d701426dae0c@linaro.org/
>
> Tested using a cross compiled QEMU and a custom kernel + debian rootfs [1].
>
> [1] https://github.com/p-b-o/qemu-linux-stack/tree/device_passthrough
>
> v2
> --
>
> - Move /dev/iommu to iommufd_backend_complete, so we can report the error
> instead of aborting.
>
> Pierrick Bouvier (2):
> backends/iommufd.c: report error when /dev/iommu is not available
> hw/vfio/iommufd.c: report hint to user when vfio-dev/vfio*/dev is
> missing
>
> backends/iommufd.c | 6 ++++++
> hw/vfio/iommufd.c | 5 ++++-
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
sent v3:
https://lore.kernel.org/qemu-devel/20260319205942.367705-1-pierrick.bouvier@linaro.org/T/#t
Regards,
Pierrick
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-19 21:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-18 18:06 [PATCH v2 0/2] iommufd: give hints to user about kernel support Pierrick Bouvier
2026-03-18 18:06 ` [PATCH v2 1/2] backends/iommufd.c: report error when /dev/iommu is not available Pierrick Bouvier
2026-03-19 6:52 ` Cédric Le Goater
2026-03-19 8:35 ` Duan, Zhenzhong
2026-03-19 20:57 ` Pierrick Bouvier
2026-03-18 18:06 ` [PATCH v2 2/2] hw/vfio/iommufd.c: report hint to user when vfio-dev/vfio*/dev is missing Pierrick Bouvier
2026-03-19 21:02 ` [PATCH v2 0/2] iommufd: give hints to user about kernel support Pierrick Bouvier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox