util/vfio-helpers: Pass Error handle to qemu_vfio_dma_map()

Currently qemu_vfio_dma_map() displays errors on stderr.
When using management interface, this information is simply
lost. Pass qemu_vfio_dma_map() an Error** handle so it can
propagate the error to callers.

Reviewed-by: Fam Zheng <fam@euphon.net>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20210902070025.197072-7-philmd@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2021-09-02 09:00:20 +02:00 committed by Stefan Hajnoczi
parent 526c37c19d
commit 521b97cd4e
3 changed files with 18 additions and 16 deletions

View file

@ -463,13 +463,15 @@ static void qemu_vfio_ram_block_added(RAMBlockNotifier *n, void *host,
size_t size, size_t max_size)
{
QEMUVFIOState *s = container_of(n, QEMUVFIOState, ram_notifier);
Error *local_err = NULL;
int ret;
trace_qemu_vfio_ram_block_added(s, host, max_size);
ret = qemu_vfio_dma_map(s, host, max_size, false, NULL);
ret = qemu_vfio_dma_map(s, host, max_size, false, NULL, &local_err);
if (ret) {
error_report("qemu_vfio_dma_map(%p, %zu) failed: %s", host, max_size,
strerror(-ret));
error_reportf_err(local_err,
"qemu_vfio_dma_map(%p, %zu) failed: ",
host, max_size);
}
}
@ -725,7 +727,7 @@ qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size, uint64_t *iova)
* mapping status within this area is not allowed).
*/
int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size,
bool temporary, uint64_t *iova)
bool temporary, uint64_t *iova, Error **errp)
{
int ret = 0;
int index;