@samitouri / QOSamiQemu / commits / 7d8814d142

vfio/migration: Add tracepoints for precopy/stopcopy query ioctls

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>

Peter Xu committed Apr 21, 2026 at 16:21 UTC 7d8814d142a8be74f4190c0d6829816fefa1a880
2 files changed +27 -10
hw/vfio/migration.c
+25 -10
@@ -329,6 +329,7 @@ static int vfio_query_stop_copy_size(VFIODevice *vbasedev)
329 struct vfio_device_feature_mig_data_size *mig_data_size =
330 (struct vfio_device_feature_mig_data_size *)feature->data;
331 VFIOMigration *migration = vbasedev->migration;
332 + int ret;
333
334 feature->argsz = sizeof(buf);
335 feature->flags =
@@ -340,12 +341,19 @@ static int vfio_query_stop_copy_size(VFIODevice *vbasedev)
341 * is reported so downtime limit won't be violated.
342 */
343 migration->stopcopy_size = VFIO_MIG_STOP_COPY_SIZE;
343 - return -errno;
344 + ret = -errno;
345 + warn_report_once("VFIO device %s ioctl(VFIO_DEVICE_FEATURE) on "
346 + "VFIO_DEVICE_FEATURE_MIG_DATA_SIZE failed (%d)",
347 + vbasedev->name, ret);
348 + } else {
349 + migration->stopcopy_size = mig_data_size->stop_copy_length;
350 + ret = 0;
351 }
352
346 - migration->stopcopy_size = mig_data_size->stop_copy_length;
353 + trace_vfio_query_stop_copy_size(vbasedev->name,
354 + migration->stopcopy_size, ret);
355
348 - return 0;
356 + return ret;
357 }
358
359 static int vfio_query_precopy_size(VFIOMigration *migration)
@@ -353,18 +361,25 @@ static int vfio_query_precopy_size(VFIOMigration *migration)
361 struct vfio_precopy_info precopy = {
362 .argsz = sizeof(precopy),
363 };
356 -
357 - migration->precopy_init_size = 0;
358 - migration->precopy_dirty_size = 0;
364 + int ret;
365
366 if (ioctl(migration->data_fd, VFIO_MIG_GET_PRECOPY_INFO, &precopy)) {
361 - return -errno;
367 + migration->precopy_init_size = 0;
368 + migration->precopy_dirty_size = 0;
369 + ret = -errno;
370 + warn_report_once("VFIO device %s ioctl(VFIO_MIG_GET_PRECOPY_INFO) "
371 + "failed (%d)", migration->vbasedev->name, ret);
372 + } else {
373 + migration->precopy_init_size = precopy.initial_bytes;
374 + migration->precopy_dirty_size = precopy.dirty_bytes;
375 + ret = 0;
376 }
377
364 - migration->precopy_init_size = precopy.initial_bytes;
365 - migration->precopy_dirty_size = precopy.dirty_bytes;
378 + trace_vfio_query_precopy_size(migration->vbasedev->name,
379 + migration->precopy_init_size,
380 + migration->precopy_dirty_size, ret);
381
367 - return 0;
382 + return ret;
383 }
384
385 /* Returns the size of saved data on success and -errno on error */
hw/vfio/trace-events
+2
@@ -162,6 +162,8 @@ vfio_migration_realize(const char *name) " (%s)"
162 vfio_migration_set_device_state(const char *name, const char *state) " (%s) state %s"
163 vfio_migration_set_state(const char *name, const char *new_state, const char *recover_state) " (%s) new state %s, recover state %s"
164 vfio_migration_state_notifier(const char *name, int state) " (%s) state %d"
165 +vfio_query_precopy_size(const char *name, uint64_t init_size, uint64_t dirty_size, int ret) " (%s) init %"PRIu64" dirty %"PRIu64" ret %d"
166 +vfio_query_stop_copy_size(const char *name, uint64_t size, int ret) " (%s) stopcopy size %"PRIu64" ret %d"
167 vfio_save_block(const char *name, int data_size) " (%s) data_size %d"
168 vfio_save_block_precopy_empty_hit(const char *name) " (%s)"
169 vfio_save_cleanup(const char *name) " (%s)"