@samitouri / QOSamiQemu / commits / 4b2e6505d5

vfio/region: Clarify dma-buf failure messages

The dma-buf failure messages in vfio_region_create_dma_buf() say "PCI BAR IOMMU mappings may fail", which suggests the BAR is broken. In practice, only P2P DMA is affected -- normal passthrough uses the mmap fallback. Reword both messages to mention P2P DMA explicitly and clarify that the mmap fallback is in use. Use warn_report_err_once() at the call site so per-BAR repetition on mdev devices is suppressed. Fixes: dcf1b77e834d ("hw/vfio/region: Create dmabuf for PCI BAR per region") Cc: Nicolin Chen <nicolinc@nvidia.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Cédric Le Goater <clg@redhat.com>

Cédric Le Goater committed Jul 15, 2026 at 10:00 UTC 4b2e6505d59b7b16c6e15a2494942d00648e8510
1 file changed +5 -6
hw/vfio/region.c
+5 -6
@@ -321,13 +321,12 @@ static bool vfio_region_create_dma_buf(VFIORegion *region, Error **errp)
321 ret = vfio_device_get_feature(vbasedev, feature);
322 if (ret < 0) {
323 if (ret == -ENOTTY) {
324 - warn_report_once("VFIO dma-buf not supported in kernel: "
325 - "PCI BAR IOMMU mappings may fail");
324 + warn_report_once("VFIO dma-buf not supported in kernel, "
325 + "using mmap fallback, P2P DMA will not work");
326 return true;
327 }
328 - /* P2P DMA or exposing device memory use cases are not supported. */
329 - error_setg_errno(errp, -ret, "%s: failed to create dma-buf: "
330 - "PCI BAR IOMMU mappings may fail",
328 + error_setg_errno(errp, -ret, "%s: dma-buf unavailable, "
329 + "using mmap fallback, P2P DMA will not work",
330 memory_region_name(region->mem));
331 return false;
332 }
@@ -448,7 +447,7 @@ int vfio_region_mmap(VFIORegion *region)
447 }
448
449 if (!vfio_region_create_dma_buf(region, &local_err)) {
451 - error_report_err(local_err);
450 + warn_report_err_once(local_err);
451 }
452
453 return 0;