[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 19/26] vfio: Add Error** argument to vfio_devices_dma_logging_
From: |
Cédric Le Goater |
Subject: |
[PATCH v3 19/26] vfio: Add Error** argument to vfio_devices_dma_logging_stop() |
Date: |
Mon, 4 Mar 2024 13:28:37 +0100 |
This improves error reporting in the log_global_stop() VFIO handler.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
Changes in v3:
- Use error_setg_errno() in vfio_devices_dma_logging_stop()
hw/vfio/common.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index
70e7c288f5f61f850fc9bbd204ecbe43c859f968..8fa232538d482f094643e0f1601b8ebe25fe077f
100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -938,12 +938,14 @@ static void vfio_dirty_tracking_init(VFIOContainerBase
*bcontainer,
memory_listener_unregister(&dirty.listener);
}
-static void vfio_devices_dma_logging_stop(VFIOContainerBase *bcontainer)
+static int vfio_devices_dma_logging_stop(VFIOContainerBase *bcontainer,
+ Error **errp)
{
uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature),
sizeof(uint64_t))] = {};
struct vfio_device_feature *feature = (struct vfio_device_feature *)buf;
VFIODevice *vbasedev;
+ int ret = 0;
feature->argsz = sizeof(buf);
feature->flags = VFIO_DEVICE_FEATURE_SET |
@@ -955,11 +957,17 @@ static void
vfio_devices_dma_logging_stop(VFIOContainerBase *bcontainer)
}
if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) {
- warn_report("%s: Failed to stop DMA logging, err %d (%s)",
- vbasedev->name, -errno, strerror(errno));
+ /* Keep first error */
+ if (!ret) {
+ ret = -errno;
+ error_setg_errno(errp, errno, "%s: Failed to stop DMA logging",
+ vbasedev->name);
+ }
}
vbasedev->dirty_tracking = false;
}
+
+ return ret;
}
static struct vfio_device_feature *
@@ -1068,7 +1076,8 @@ static int
vfio_devices_dma_logging_start(VFIOContainerBase *bcontainer,
out:
if (ret) {
- vfio_devices_dma_logging_stop(bcontainer);
+ /* Ignore the potential errors when doing rollback */
+ vfio_devices_dma_logging_stop(bcontainer, NULL);
}
vfio_device_feature_dma_logging_start_destroy(feature);
@@ -1105,7 +1114,7 @@ static bool vfio_listener_log_global_stop(MemoryListener
*listener,
int ret = 0;
if (vfio_devices_all_device_dirty_tracking(bcontainer)) {
- vfio_devices_dma_logging_stop(bcontainer);
+ ret = vfio_devices_dma_logging_stop(bcontainer, errp);
} else {
ret = vfio_container_set_dirty_page_tracking(bcontainer, false, errp);
}
--
2.44.0
- [PATCH v3 10/26] migration: Move cleanup after after error reporting in qemu_savevm_state_setup(), (continued)
- [PATCH v3 10/26] migration: Move cleanup after after error reporting in qemu_savevm_state_setup(), Cédric Le Goater, 2024/03/04
- [PATCH v3 13/26] migration: Add Error** argument to .load_setup() handler, Cédric Le Goater, 2024/03/04
- [PATCH v3 14/26] memory: Add Error** argument to .log_global*() handlers, Cédric Le Goater, 2024/03/04
- [PATCH v3 12/26] migration: Add Error** argument to .save_setup() handler, Cédric Le Goater, 2024/03/04
- [PATCH v3 17/26] vfio: Add Error** argument to .set_dirty_page_tracking() handler, Cédric Le Goater, 2024/03/04
- [PATCH v3 19/26] vfio: Add Error** argument to vfio_devices_dma_logging_stop(),
Cédric Le Goater <=
- [PATCH v3 11/26] migration: Add Error** argument to qemu_savevm_state_setup(), Cédric Le Goater, 2024/03/04
- [PATCH v3 15/26] memory: Add Error** argument to the global_dirty_log routines, Cédric Le Goater, 2024/03/04
- [PATCH v3 16/26] migration: Modify ram_init_bitmaps() to report dirty tracking errors, Cédric Le Goater, 2024/03/04
- [PATCH v3 22/26] vfio: Reverse test on vfio_get_dirty_bitmap(), Cédric Le Goater, 2024/03/04
- [PATCH v3 25/26] vfio: Also trace event failures in vfio_save_complete_precopy(), Cédric Le Goater, 2024/03/04
- [PATCH v3 26/26] vfio: Extend vfio_set_migration_error() with Error* argument, Cédric Le Goater, 2024/03/04
- [PATCH v3 20/26] vfio: Use new Error** argument in vfio_save_setup(), Cédric Le Goater, 2024/03/04
- [PATCH v3 18/26] vfio: Add Error** argument to vfio_devices_dma_logging_start(), Cédric Le Goater, 2024/03/04
- [PATCH v3 24/26] vfio: Add Error** argument to .get_dirty_bitmap() handler, Cédric Le Goater, 2024/03/04