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.
Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Tested-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/r/20260421202110.306051-17-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
---
hw/vfio/migration.c | 35 +++++++++++++++++++++++++----------
hw/vfio/trace-events | 2 ++
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index e6e6a0d53d..150e28656e 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,19 @@ 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(vbasedev->name,
+ migration->stopcopy_size, ret);
- return 0;
+ return ret;
}
static int vfio_query_precopy_size(VFIOMigration *migration)
@@ -353,18 +361,25 @@ 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->vbasedev->name,
+ 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..2049159015 100644
--- a/hw/vfio/trace-events
+++ b/hw/vfio/trace-events
@@ -162,6 +162,8 @@ vfio_migration_realize(const char *name) " (%s)"
vfio_migration_set_device_state(const char *name, const char *state) " (%s) state %s"
vfio_migration_set_state(const char *name, const char *new_state, const char *recover_state) " (%s) new state %s, recover state %s"
vfio_migration_state_notifier(const char *name, int state) " (%s) state %d"
+vfio_query_precopy_size(const char *name, uint64_t init_size, uint64_t dirty_size, int ret) " (%s) init %"PRIu64" dirty %"PRIu64" ret %d"
+vfio_query_stop_copy_size(const char *name, uint64_t size, int ret) " (%s) stopcopy size %"PRIu64" ret %d"
vfio_save_block(const char *name, int data_size) " (%s) data_size %d"
vfio_save_block_precopy_empty_hit(const char *name) " (%s)"
vfio_save_cleanup(const char *name) " (%s)"
--
2.53.0