aboutsummaryrefslogtreecommitdiff
path: root/migration
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2023-05-15 21:56:59 +0200
committerJuan Quintela <quintela@redhat.com>2023-05-18 18:40:51 +0200
commit99319e2dafaf2ad05412c8f119efcdf24a3baf04 (patch)
treea725260b649ad4747c734487051dc99d5cc7abec /migration
parente1fde0e038bafd0bd05db7d43305b9b2f03c0683 (diff)
migration: Move migration_total_bytes() to migration-stats.c
Once there rename it to migration_transferred_bytes() and pass a QEMUFile instead of a migration object. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Cédric Le Goater <clg@kaod.org> Message-Id: <20230515195709.63843-7-quintela@redhat.com>
Diffstat (limited to 'migration')
-rw-r--r--migration/migration-stats.c5
-rw-r--r--migration/migration-stats.h11
-rw-r--r--migration/migration.c13
3 files changed, 19 insertions, 10 deletions
diff --git a/migration/migration-stats.c b/migration/migration-stats.c
index 0890220ba5..39e98d6fa9 100644
--- a/migration/migration-stats.c
+++ b/migration/migration-stats.c
@@ -59,3 +59,8 @@ void migration_rate_account(uint64_t len)
{
stat64_add(&mig_stats.rate_limit_used, len);
}
+
+uint64_t migration_transferred_bytes(QEMUFile *f)
+{
+ return qemu_file_transferred(f) + stat64_get(&mig_stats.multifd_bytes);
+}
diff --git a/migration/migration-stats.h b/migration/migration-stats.h
index 7b64dc7cc2..827ea80c9b 100644
--- a/migration/migration-stats.h
+++ b/migration/migration-stats.h
@@ -133,4 +133,15 @@ void migration_rate_reset(void);
* @new_rate: new maximum amount
*/
void migration_rate_set(uint64_t new_rate);
+
+/**
+ * migration_transferred_bytes: Return number of bytes transferred
+ *
+ * @f: QEMUFile used for main migration channel
+ *
+ * Returns how many bytes have we transferred since the beginning of
+ * the migration. It accounts for bytes sent through any migration
+ * channel, multifd, qemu_file, rdma, ....
+ */
+uint64_t migration_transferred_bytes(QEMUFile *f);
#endif
diff --git a/migration/migration.c b/migration/migration.c
index fc8974e274..952100c8d7 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2625,16 +2625,9 @@ static MigThrError migration_detect_error(MigrationState *s)
}
}
-/* How many bytes have we transferred since the beginning of the migration */
-static uint64_t migration_total_bytes(MigrationState *s)
-{
- return qemu_file_transferred(s->to_dst_file) +
- stat64_get(&mig_stats.multifd_bytes);
-}
-
static void migration_calculate_complete(MigrationState *s)
{
- uint64_t bytes = migration_total_bytes(s);
+ uint64_t bytes = migration_transferred_bytes(s->to_dst_file);
int64_t end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
int64_t transfer_time;
@@ -2660,7 +2653,7 @@ static void update_iteration_initial_status(MigrationState *s)
* wrong speed calculation.
*/
s->iteration_start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
- s->iteration_initial_bytes = migration_total_bytes(s);
+ s->iteration_initial_bytes = migration_transferred_bytes(s->to_dst_file);
s->iteration_initial_pages = ram_get_total_transferred_pages();
}
@@ -2675,7 +2668,7 @@ static void migration_update_counters(MigrationState *s,
return;
}
- current_bytes = migration_total_bytes(s);
+ current_bytes = migration_transferred_bytes(s->to_dst_file);
transferred = current_bytes - s->iteration_initial_bytes;
time_spent = current_time - s->iteration_start_time;
bandwidth = (double)transferred / time_spent;