Skip to content

Commit

Permalink
migration: use qemu_ftell to compute bandwidth
Browse files Browse the repository at this point in the history
Prepare for when s->bytes_xfer will be removed.

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
  • Loading branch information
bonzini authored and Juan Quintela committed Mar 11, 2013
1 parent e6a1cf2 commit be7172e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion migration.c
Expand Up @@ -589,6 +589,7 @@ static void *migration_thread(void *opaque)
MigrationState *s = opaque;
int64_t initial_time = qemu_get_clock_ms(rt_clock);
int64_t sleep_time = 0;
int64_t initial_bytes = 0;
int64_t max_size = 0;
int64_t start_time = initial_time;
bool old_vm_running = false;
Expand Down Expand Up @@ -629,7 +630,7 @@ static void *migration_thread(void *opaque)
}
current_time = qemu_get_clock_ms(rt_clock);
if (current_time >= initial_time + BUFFER_DELAY) {
uint64_t transferred_bytes = s->bytes_xfer;
uint64_t transferred_bytes = qemu_ftell(s->file) - initial_bytes;
uint64_t time_spent = current_time - initial_time - sleep_time;
double bandwidth = transferred_bytes / time_spent;
max_size = bandwidth * migrate_max_downtime() / 1000000;
Expand All @@ -646,6 +647,7 @@ static void *migration_thread(void *opaque)
s->bytes_xfer = 0;
sleep_time = 0;
initial_time = current_time;
initial_bytes = qemu_ftell(s->file);
}
if (qemu_file_rate_limit(s->file)) {
/* usleep expects microseconds */
Expand Down

0 comments on commit be7172e

Please sign in to comment.