[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 05/20] vfio/common: Fix wrong %m usages
From: |
Avihai Horon |
Subject: |
[PATCH v2 05/20] vfio/common: Fix wrong %m usages |
Date: |
Wed, 22 Feb 2023 19:49:00 +0200 |
There are several places where the %m conversion is used if one of
vfio_dma_map(), vfio_dma_unmap() or vfio_get_dirty_bitmap() fail.
The %m usage in these places is wrong since %m relies on errno value while
the above functions don't report errors via errno.
Fix it by using strerror() with the returned value instead.
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/common.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 27db71427e..930eda40a1 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -705,17 +705,17 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n,
IOMMUTLBEntry *iotlb)
read_only);
if (ret) {
error_report("vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
- "0x%"HWADDR_PRIx", %p) = %d (%m)",
+ "0x%"HWADDR_PRIx", %p) = %d (%s)",
container, iova,
- iotlb->addr_mask + 1, vaddr, ret);
+ iotlb->addr_mask + 1, vaddr, ret, strerror(-ret));
}
} else {
ret = vfio_dma_unmap(container, iova, iotlb->addr_mask + 1, iotlb);
if (ret) {
error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
- "0x%"HWADDR_PRIx") = %d (%m)",
+ "0x%"HWADDR_PRIx") = %d (%s)",
container, iova,
- iotlb->addr_mask + 1, ret);
+ iotlb->addr_mask + 1, ret, strerror(-ret));
}
}
out:
@@ -1097,8 +1097,9 @@ static void vfio_listener_region_add(MemoryListener
*listener,
vaddr, section->readonly);
if (ret) {
error_setg(&err, "vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
- "0x%"HWADDR_PRIx", %p) = %d (%m)",
- container, iova, int128_get64(llsize), vaddr, ret);
+ "0x%"HWADDR_PRIx", %p) = %d (%s)",
+ container, iova, int128_get64(llsize), vaddr, ret,
+ strerror(-ret));
if (memory_region_is_ram_device(section->mr)) {
/* Allow unexpected mappings not to be fatal for RAM devices */
error_report_err(err);
@@ -1230,16 +1231,18 @@ static void vfio_listener_region_del(MemoryListener
*listener,
ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
if (ret) {
error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
- "0x%"HWADDR_PRIx") = %d (%m)",
- container, iova, int128_get64(llsize), ret);
+ "0x%"HWADDR_PRIx") = %d (%s)",
+ container, iova, int128_get64(llsize), ret,
+ strerror(-ret));
}
iova += int128_get64(llsize);
}
ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
if (ret) {
error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
- "0x%"HWADDR_PRIx") = %d (%m)",
- container, iova, int128_get64(llsize), ret);
+ "0x%"HWADDR_PRIx") = %d (%s)",
+ container, iova, int128_get64(llsize), ret,
+ strerror(-ret));
}
}
@@ -1386,9 +1389,9 @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier *n,
IOMMUTLBEntry *iotlb)
translated_addr);
if (ret) {
error_report("vfio_iommu_map_dirty_notify(%p, 0x%"HWADDR_PRIx", "
- "0x%"HWADDR_PRIx") = %d (%m)",
- container, iova,
- iotlb->addr_mask + 1, ret);
+ "0x%"HWADDR_PRIx") = %d (%s)",
+ container, iova, iotlb->addr_mask + 1, ret,
+ strerror(-ret));
}
}
rcu_read_unlock();
--
2.26.3
- [PATCH v2 00/20] vfio: Add migration pre-copy support and device dirty tracking, Avihai Horon, 2023/02/22
- [PATCH v2 01/20] migration: Pass threshold_size to .state_pending_{estimate, exact}(), Avihai Horon, 2023/02/22
- [PATCH v2 02/20] vfio/migration: Refactor vfio_save_block() to return saved data size, Avihai Horon, 2023/02/22
- [PATCH v2 04/20] vfio/common: Fix error reporting in vfio_get_dirty_bitmap(), Avihai Horon, 2023/02/22
- [PATCH v2 07/20] vfio/common: Add VFIOBitmap and (de)alloc functions, Avihai Horon, 2023/02/22
- [PATCH v2 09/20] util: Extend iova_tree_foreach() to take data argument, Avihai Horon, 2023/02/22
- [PATCH v2 05/20] vfio/common: Fix wrong %m usages,
Avihai Horon <=
- [PATCH v2 06/20] vfio/common: Abort migration if dirty log start/stop/sync fails, Avihai Horon, 2023/02/22
- [PATCH v2 03/20] vfio/migration: Add VFIO migration pre-copy support, Avihai Horon, 2023/02/22
- Re: [PATCH v2 03/20] vfio/migration: Add VFIO migration pre-copy support, Alex Williamson, 2023/02/22
- Re: [PATCH v2 03/20] vfio/migration: Add VFIO migration pre-copy support, Avihai Horon, 2023/02/23
- Re: [PATCH v2 03/20] vfio/migration: Add VFIO migration pre-copy support, Alex Williamson, 2023/02/23
- Re: [PATCH v2 03/20] vfio/migration: Add VFIO migration pre-copy support, Avihai Horon, 2023/02/26
- Re: [PATCH v2 03/20] vfio/migration: Add VFIO migration pre-copy support, Alex Williamson, 2023/02/27
- Re: [PATCH v2 03/20] vfio/migration: Add VFIO migration pre-copy support, Jason Gunthorpe, 2023/02/27
- Re: [PATCH v2 03/20] vfio/migration: Add VFIO migration pre-copy support, Alex Williamson, 2023/02/27
[PATCH v2 08/20] util: Add iova_tree_nnodes(), Avihai Horon, 2023/02/22