aboutsummaryrefslogtreecommitdiff
path: root/migration/migration.c
diff options
context:
space:
mode:
Diffstat (limited to 'migration/migration.c')
-rw-r--r--migration/migration.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/migration/migration.c b/migration/migration.c
index e1eaa97df4..94d71f8b24 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -518,11 +518,12 @@ void migration_ioc_process_incoming(QIOChannel *ioc)
*/
bool migration_has_all_channels(void)
{
+ MigrationIncomingState *mis = migration_incoming_get_current();
bool all_channels;
all_channels = multifd_recv_all_channels_created();
- return all_channels;
+ return all_channels && mis->from_src_file != NULL;
}
/*
@@ -708,6 +709,7 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s)
info->ram->dirty_sync_count = ram_counters.dirty_sync_count;
info->ram->postcopy_requests = ram_counters.postcopy_requests;
info->ram->page_size = qemu_target_page_size();
+ info->ram->multifd_bytes = ram_counters.multifd_bytes;
if (migrate_use_xbzrle()) {
info->has_xbzrle_cache = true;
@@ -2704,10 +2706,17 @@ static MigThrError migration_detect_error(MigrationState *s)
}
}
+/* How many bytes have we transferred since the beggining of the migration */
+static uint64_t migration_total_bytes(MigrationState *s)
+{
+ return qemu_ftell(s->to_dst_file) + ram_counters.multifd_bytes;
+}
+
static void migration_calculate_complete(MigrationState *s)
{
- uint64_t bytes = qemu_ftell(s->to_dst_file);
+ uint64_t bytes = migration_total_bytes(s);
int64_t end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
+ int64_t transfer_time;
s->total_time = end_time - s->start_time;
if (!s->downtime) {
@@ -2718,8 +2727,9 @@ static void migration_calculate_complete(MigrationState *s)
s->downtime = end_time - s->downtime_start;
}
- if (s->total_time) {
- s->mbps = ((double) bytes * 8.0) / s->total_time / 1000;
+ transfer_time = s->total_time - s->setup_time;
+ if (transfer_time) {
+ s->mbps = ((double) bytes * 8.0) / transfer_time / 1000;
}
}
@@ -2727,13 +2737,15 @@ static void migration_update_counters(MigrationState *s,
int64_t current_time)
{
uint64_t transferred, time_spent;
+ uint64_t current_bytes; /* bytes transferred since the beginning */
double bandwidth;
if (current_time < s->iteration_start_time + BUFFER_DELAY) {
return;
}
- transferred = qemu_ftell(s->to_dst_file) - s->iteration_initial_bytes;
+ current_bytes = migration_total_bytes(s);
+ transferred = current_bytes - s->iteration_initial_bytes;
time_spent = current_time - s->iteration_start_time;
bandwidth = (double)transferred / time_spent;
s->threshold_size = bandwidth * s->parameters.downtime_limit;
@@ -2752,7 +2764,7 @@ static void migration_update_counters(MigrationState *s,
qemu_file_reset_rate_limit(s->to_dst_file);
s->iteration_start_time = current_time;
- s->iteration_initial_bytes = qemu_ftell(s->to_dst_file);
+ s->iteration_initial_bytes = current_bytes;
trace_migrate_transferred(transferred, time_spent,
bandwidth, s->threshold_size);