Patchwork [36/41] migration: use qemu_ftell to compute bandwidth

login
register
mail settings
Submitter Paolo Bonzini
Date Feb. 15, 2013, 5:47 p.m.
Message ID <1360950433-17106-37-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/220814/
State New
Headers show

Comments

Paolo Bonzini - Feb. 15, 2013, 5:47 p.m.
Prepare for when s->bytes_xfer will be removed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 migration.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
Juan Quintela - Feb. 22, 2013, 11:33 a.m.
Paolo Bonzini <pbonzini@redhat.com> wrote:
> Prepare for when s->bytes_xfer will be removed.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>
Orit Wasserman - Feb. 22, 2013, 12:12 p.m.
On 02/15/2013 07:47 PM, Paolo Bonzini wrote:
> Prepare for when s->bytes_xfer will be removed.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  migration.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/migration.c b/migration.c
> index 68d47cd..d636c59 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -575,6 +575,7 @@ static void *migration_thread(void *opaque)
>  {
>      MigrationState *s = opaque;
>      int64_t initial_time = qemu_get_clock_ms(rt_clock);
> +    int64_t initial_bytes = 0;
>      int64_t max_size = 0;
>      int64_t start_time = initial_time;
>      bool old_vm_running = false;
> @@ -613,7 +614,7 @@ static void *migration_thread(void *opaque)
>  	    break;
>          }
>          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;
>              double bandwidth = transferred_bytes / time_spent;
>              max_size = bandwidth * migrate_max_downtime() / 1000000;
> @@ -624,6 +625,7 @@ static void *migration_thread(void *opaque)
>  
>              s->bytes_xfer = 0;
>              initial_time = current_time;
> +            initial_bytes = qemu_ftell(s->file);
>          }
>          if (qemu_file_rate_limit(s->file)) {
>              /* usleep expects microseconds */
> 
Reviewed-by: Orit Wasserman <owasserm@redhat.com>

Patch

diff --git a/migration.c b/migration.c
index 68d47cd..d636c59 100644
--- a/migration.c
+++ b/migration.c
@@ -575,6 +575,7 @@  static void *migration_thread(void *opaque)
 {
     MigrationState *s = opaque;
     int64_t initial_time = qemu_get_clock_ms(rt_clock);
+    int64_t initial_bytes = 0;
     int64_t max_size = 0;
     int64_t start_time = initial_time;
     bool old_vm_running = false;
@@ -613,7 +614,7 @@  static void *migration_thread(void *opaque)
 	    break;
         }
         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;
             double bandwidth = transferred_bytes / time_spent;
             max_size = bandwidth * migrate_max_downtime() / 1000000;
@@ -624,6 +625,7 @@  static void *migration_thread(void *opaque)
 
             s->bytes_xfer = 0;
             initial_time = current_time;
+            initial_bytes = qemu_ftell(s->file);
         }
         if (qemu_file_rate_limit(s->file)) {
             /* usleep expects microseconds */