Skip to content

Commit

Permalink
Report stringified errno in VFIO related errors
Browse files Browse the repository at this point in the history
In a few places we report errno formatted as a negative integer.
This is not as user friendly as it can be. Use strerror() and/or
error_setg_errno() instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Message-Id: <4949c3ecf1a32189b8a4b5eb4b0fd04c1122501d.1581674006.git.mprivozn@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
  • Loading branch information
zippy2 authored and vivier committed Feb 18, 2020
1 parent 4065bb2 commit b09d51c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions hw/vfio/common.c
Expand Up @@ -319,7 +319,7 @@ static int vfio_dma_unmap(VFIOContainer *container,
unmap.size -= 1ULL << ctz64(container->pgsizes);
continue;
}
error_report("VFIO_UNMAP_DMA: %d", -errno);
error_report("VFIO_UNMAP_DMA failed: %s", strerror(errno));
return -errno;
}

Expand Down Expand Up @@ -352,7 +352,7 @@ static int vfio_dma_map(VFIOContainer *container, hwaddr iova,
return 0;
}

error_report("VFIO_MAP_DMA: %d", -errno);
error_report("VFIO_MAP_DMA failed: %s", strerror(errno));
return -errno;
}

Expand Down
6 changes: 3 additions & 3 deletions util/vfio-helpers.c
Expand Up @@ -545,7 +545,7 @@ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void *host, size_t size,
trace_qemu_vfio_do_mapping(s, host, size, iova);

if (ioctl(s->container, VFIO_IOMMU_MAP_DMA, &dma_map)) {
error_report("VFIO_MAP_DMA: %d", -errno);
error_report("VFIO_MAP_DMA failed: %s", strerror(errno));
return -errno;
}
return 0;
Expand All @@ -570,7 +570,7 @@ static void qemu_vfio_undo_mapping(QEMUVFIOState *s, IOVAMapping *mapping,
assert(QEMU_IS_ALIGNED(mapping->size, qemu_real_host_page_size));
assert(index >= 0 && index < s->nr_mappings);
if (ioctl(s->container, VFIO_IOMMU_UNMAP_DMA, &unmap)) {
error_setg(errp, "VFIO_UNMAP_DMA failed: %d", -errno);
error_setg_errno(errp, errno, "VFIO_UNMAP_DMA failed");
}
memmove(mapping, &s->mappings[index + 1],
sizeof(s->mappings[0]) * (s->nr_mappings - index - 1));
Expand Down Expand Up @@ -669,7 +669,7 @@ int qemu_vfio_dma_reset_temporary(QEMUVFIOState *s)
trace_qemu_vfio_dma_reset_temporary(s);
qemu_mutex_lock(&s->lock);
if (ioctl(s->container, VFIO_IOMMU_UNMAP_DMA, &unmap)) {
error_report("VFIO_UNMAP_DMA: %d", -errno);
error_report("VFIO_UNMAP_DMA failed: %s", strerror(errno));
qemu_mutex_unlock(&s->lock);
return -errno;
}
Expand Down

0 comments on commit b09d51c

Please sign in to comment.