>-----Original Message----- >From: Cédric Le Goater <[email protected]> >Subject: Re: [PATCH 1/2] backends/iommufd.c: report error when /dev/iommu is >not available > >On 3/18/26 08:36, Duan, Zhenzhong wrote: >> >> >>> -----Original Message----- >>> From: Pierrick Bouvier <[email protected]> >>> Subject: [PATCH 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 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?)"); >> >> If hot add an iommufd object with object_add QMP, may this kill QEMU >instance? > >yes. > > >Unfortunately, backends are Objects. So we don't have a realize >handler and a 'Error **' parameter :/
Maybe do it in iommufd_backend_complete()? Thanks Zhenzhong
