On 4/21/26 22:21, Peter Xu wrote:
Add two tracepoints for both precopy and stopcopy query ioctls. When at
it, add one warn_report_once() for each of them when it fails.
Signed-off-by: Peter Xu <[email protected]>
Tested-by: Cédric Le Goater <[email protected]>
Thanks,
C.
---
hw/vfio/migration.c | 33 +++++++++++++++++++++++----------
hw/vfio/trace-events | 2 ++
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index e6e6a0d53d..04d9f94edb 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -329,6 +329,7 @@ static int vfio_query_stop_copy_size(VFIODevice *vbasedev)
struct vfio_device_feature_mig_data_size *mig_data_size =
(struct vfio_device_feature_mig_data_size *)feature->data;
VFIOMigration *migration = vbasedev->migration;
+ int ret;
feature->argsz = sizeof(buf);
feature->flags =
@@ -340,12 +341,18 @@ static int vfio_query_stop_copy_size(VFIODevice *vbasedev)
* is reported so downtime limit won't be violated.
*/
migration->stopcopy_size = VFIO_MIG_STOP_COPY_SIZE;
- return -errno;
+ ret = -errno;
+ warn_report_once("VFIO device %s ioctl(VFIO_DEVICE_FEATURE) on "
+ "VFIO_DEVICE_FEATURE_MIG_DATA_SIZE failed (%d)",
+ vbasedev->name, ret);
+ } else {
+ migration->stopcopy_size = mig_data_size->stop_copy_length;
+ ret = 0;
}
- migration->stopcopy_size = mig_data_size->stop_copy_length;
+ trace_vfio_query_stop_copy_size(migration->stopcopy_size, ret);
- return 0;
+ return ret;
}
static int vfio_query_precopy_size(VFIOMigration *migration)
@@ -353,18 +360,24 @@ static int vfio_query_precopy_size(VFIOMigration
*migration)
struct vfio_precopy_info precopy = {
.argsz = sizeof(precopy),
};
-
- migration->precopy_init_size = 0;
- migration->precopy_dirty_size = 0;
+ int ret;
if (ioctl(migration->data_fd, VFIO_MIG_GET_PRECOPY_INFO, &precopy)) {
- return -errno;
+ migration->precopy_init_size = 0;
+ migration->precopy_dirty_size = 0;
+ ret = -errno;
+ warn_report_once("VFIO device %s ioctl(VFIO_MIG_GET_PRECOPY_INFO) "
+ "failed (%d)", migration->vbasedev->name, ret);
+ } else {
+ migration->precopy_init_size = precopy.initial_bytes;
+ migration->precopy_dirty_size = precopy.dirty_bytes;
+ ret = 0;
}
- migration->precopy_init_size = precopy.initial_bytes;
- migration->precopy_dirty_size = precopy.dirty_bytes;
+ trace_vfio_query_precopy_size(migration->precopy_init_size,
+ migration->precopy_dirty_size, ret);
- return 0;
+ return ret;
}
/* Returns the size of saved data on success and -errno on error */
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
index 287df0b8cb..854a7e4b19 100644
--- a/hw/vfio/trace-events
+++ b/hw/vfio/trace-events
@@ -176,6 +176,8 @@ vfio_save_setup(const char *name, uint64_t data_buffer_size)
" (%s) data buffer
vfio_state_pending(const char *name, uint64_t stopcopy_size, uint64_t precopy_init_size, uint64_t precopy_dirty_size,
bool exact) " (%s) stopcopy size %"PRIu64" precopy initial size %"PRIu64" precopy dirty size
%"PRIu64 " exact %d"
vfio_vmstate_change(const char *name, int running, const char *reason, const char
*dev_state) " (%s) running %d reason %s device state %s"
vfio_vmstate_change_prepare(const char *name, int running, const char *reason, const
char *dev_state) " (%s) running %d reason %s device state %s"
+vfio_query_stop_copy_size(uint64_t size, int ret) "stopcopy size %"PRIu64" ret
%d"
+vfio_query_precopy_size(uint64_t init_size, uint64_t dirty_size, int ret) "init %"PRIu64"
dirty %"PRIu64" ret %d"
#iommufd.c