The statistics of bytes transferred conceptually belong to The VFIO live
migration framework, and should not belong to any specific implementation
such In-Band approach, so move it out from vfio_migration_region_save_buffer(),
which makes it easier to add other implementations.

Signed-off-by: Lei Rao <lei....@intel.com>
Reviewed-by: Eddie Dong <eddie.d...@intel.com>
---
 hw/vfio/migration.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 4736af90e7..c114fab3a2 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -257,7 +257,6 @@ static int vfio_migration_save_buffer_local(QEMUFile *f, 
VFIODevice *vbasedev,
         *size = data_size;
     }
 
-    bytes_transferred += data_size;
     return ret;
 }
 
@@ -540,6 +539,7 @@ static int vfio_save_iterate(QEMUFile *f, void *opaque)
                          vbasedev->name, strerror(errno));
             return ret;
         }
+        bytes_transferred += data_size;
     }
 
     qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE);
@@ -592,6 +592,7 @@ static int vfio_save_complete_precopy(QEMUFile *f, void 
*opaque)
                 error_report("%s: Failed to save buffer", vbasedev->name);
                 return ret;
             }
+            bytes_transferred += data_size;
         }
 
         if (data_size == 0) {
-- 
2.32.0


Reply via email to