Patchwork [04/41] migration: print total downtime for final phase of migration

login
register
mail settings
Submitter Juan Quintela
Date Sept. 21, 2012, 8:46 a.m.
Message ID <1348217255-22441-5-git-send-email-quintela@redhat.com>
Download mbox | patch
Permalink /patch/185656/
State New
Headers show

Comments

Juan Quintela - Sept. 21, 2012, 8:46 a.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hmp.c            | 4 ++++
 migration.c      | 6 +++++-
 migration.h      | 1 +
 qapi-schema.json | 7 ++++++-
 qmp-commands.hx  | 3 +++
 5 files changed, 19 insertions(+), 2 deletions(-)
Paolo Bonzini - Sept. 21, 2012, 12:19 p.m.
Il 21/09/2012 10:46, Juan Quintela ha scritto:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  hmp.c            | 4 ++++
>  migration.c      | 6 +++++-
>  migration.h      | 1 +
>  qapi-schema.json | 7 ++++++-
>  qmp-commands.hx  | 3 +++
>  5 files changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/hmp.c b/hmp.c
> index ba6fbd3..40b0c05 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -152,6 +152,10 @@ void hmp_info_migrate(Monitor *mon)
>          monitor_printf(mon, "Migration status: %s\n", info->status);
>          monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n",
>                         info->total_time);
> +        if (info->has_downtime) {
> +            monitor_printf(mon, "downtime: %" PRIu64 " milliseconds\n",
> +                           info->downtime);
> +        }
>      }
> 
>      if (info->has_ram) {
> diff --git a/migration.c b/migration.c
> index 1e3f791..c1655b3 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -195,6 +195,8 @@ MigrationInfo *qmp_query_migrate(Error **errp)
>          info->has_status = true;
>          info->status = g_strdup("completed");
>          info->total_time = s->total_time;
> +        info->has_downtime = true;
> +        info->downtime = s->downtime;
> 
>          info->has_ram = true;
>          info->ram = g_malloc0(sizeof(*info->ram));
> @@ -327,9 +329,10 @@ static void migrate_fd_put_ready(void *opaque)
>          migrate_fd_error(s);
>      } else if (ret == 1) {
>          int old_vm_running = runstate_is_running();
> -        int64_t end_time;
> +        int64_t start_time, end_time;
> 
>          DPRINTF("done iterating\n");
> +        start_time = qemu_get_clock_ms(rt_clock);
>          qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
>          vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
> 
> @@ -340,6 +343,7 @@ static void migrate_fd_put_ready(void *opaque)
>          }
>          end_time = qemu_get_clock_ms(rt_clock);
>          s->total_time = end_time - s->total_time;
> +        s->downtime = end_time - start_time;
>          if (s->state != MIG_STATE_COMPLETED) {
>              if (old_vm_running) {
>                  vm_start();
> diff --git a/migration.h b/migration.h
> index a9852fc..3462917 100644
> --- a/migration.h
> +++ b/migration.h
> @@ -40,6 +40,7 @@ struct MigrationState
>      void *opaque;
>      MigrationParams params;
>      int64_t total_time;
> +    int64_t downtime;
>      bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
>      int64_t xbzrle_cache_size;
>  };
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 14e4419..b5a4360 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -413,13 +413,18 @@
>  #        If migration has ended, it returns the total migration
>  #        time. (since 1.2)
>  #
> +# @downtime: #optional only present when migration finishes correctly
> +#        total downtime in milliseconds for the guest.
> +#        (since 1.3)
> +#
>  # Since: 0.14.0
>  ##
>  { 'type': 'MigrationInfo',
>    'data': {'*status': 'str', '*ram': 'MigrationStats',
>             '*disk': 'MigrationStats',
>             '*xbzrle-cache': 'XBZRLECacheStats',
> -           '*total-time': 'int'} }
> +           '*total-time': 'int',
> +           '*downtime': 'int'} }
> 
>  ##
>  # @query-migrate
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index 6e21ddb..37be613 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -2267,6 +2267,8 @@ The main json-object contains the following:
>  - "total-time": total amount of ms since migration started.  If
>                  migration has ended, it returns the total migration
>  		 time (json-int)
> +- "downtime": only present when migration has finished correctly
> +                total amount in ms for downtime that happened (json-int)

Indeed it's only present if

         info->status = g_strdup("completed");

>  - "ram": only present if "status" is "active", it is a json-object with the
>    following RAM information (in bytes):
>           - "transferred": amount transferred (json-int)
> @@ -2304,6 +2306,7 @@ Examples:
>            "remaining":123,
>            "total":246,
>            "total-time":12345,
> +          "downtime":12345,
>            "duplicate":123,
>            "normal":123,
>            "normal-bytes":123456
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo
Orit Wasserman - Sept. 25, 2012, 8:18 a.m.
On 09/21/2012 11:46 AM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  hmp.c            | 4 ++++
>  migration.c      | 6 +++++-
>  migration.h      | 1 +
>  qapi-schema.json | 7 ++++++-
>  qmp-commands.hx  | 3 +++
>  5 files changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/hmp.c b/hmp.c
> index ba6fbd3..40b0c05 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -152,6 +152,10 @@ void hmp_info_migrate(Monitor *mon)
>          monitor_printf(mon, "Migration status: %s\n", info->status);
>          monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n",
>                         info->total_time);
> +        if (info->has_downtime) {
> +            monitor_printf(mon, "downtime: %" PRIu64 " milliseconds\n",
> +                           info->downtime);
> +        }
>      }
> 
>      if (info->has_ram) {
> diff --git a/migration.c b/migration.c
> index 1e3f791..c1655b3 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -195,6 +195,8 @@ MigrationInfo *qmp_query_migrate(Error **errp)
>          info->has_status = true;
>          info->status = g_strdup("completed");
>          info->total_time = s->total_time;
> +        info->has_downtime = true;
> +        info->downtime = s->downtime;
> 
>          info->has_ram = true;
>          info->ram = g_malloc0(sizeof(*info->ram));
> @@ -327,9 +329,10 @@ static void migrate_fd_put_ready(void *opaque)
>          migrate_fd_error(s);
>      } else if (ret == 1) {
>          int old_vm_running = runstate_is_running();
> -        int64_t end_time;
> +        int64_t start_time, end_time;
> 
>          DPRINTF("done iterating\n");
> +        start_time = qemu_get_clock_ms(rt_clock);
>          qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
>          vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
> 
> @@ -340,6 +343,7 @@ static void migrate_fd_put_ready(void *opaque)
>          }
>          end_time = qemu_get_clock_ms(rt_clock);
>          s->total_time = end_time - s->total_time;
> +        s->downtime = end_time - start_time;
>          if (s->state != MIG_STATE_COMPLETED) {
>              if (old_vm_running) {
>                  vm_start();
> diff --git a/migration.h b/migration.h
> index a9852fc..3462917 100644
> --- a/migration.h
> +++ b/migration.h
> @@ -40,6 +40,7 @@ struct MigrationState
>      void *opaque;
>      MigrationParams params;
>      int64_t total_time;
> +    int64_t downtime;
>      bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
>      int64_t xbzrle_cache_size;
>  };
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 14e4419..b5a4360 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -413,13 +413,18 @@
>  #        If migration has ended, it returns the total migration
>  #        time. (since 1.2)
>  #
> +# @downtime: #optional only present when migration finishes correctly
> +#        total downtime in milliseconds for the guest.
> +#        (since 1.3)
> +#
>  # Since: 0.14.0
>  ##
>  { 'type': 'MigrationInfo',
>    'data': {'*status': 'str', '*ram': 'MigrationStats',
>             '*disk': 'MigrationStats',
>             '*xbzrle-cache': 'XBZRLECacheStats',
> -           '*total-time': 'int'} }
> +           '*total-time': 'int',
> +           '*downtime': 'int'} }
> 
>  ##
>  # @query-migrate
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index 6e21ddb..37be613 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -2267,6 +2267,8 @@ The main json-object contains the following:
>  - "total-time": total amount of ms since migration started.  If
>                  migration has ended, it returns the total migration
>  		 time (json-int)
> +- "downtime": only present when migration has finished correctly
> +                total amount in ms for downtime that happened (json-int)
>  - "ram": only present if "status" is "active", it is a json-object with the
>    following RAM information (in bytes):
>           - "transferred": amount transferred (json-int)
> @@ -2304,6 +2306,7 @@ Examples:
>            "remaining":123,
>            "total":246,
>            "total-time":12345,
> +          "downtime":12345,
>            "duplicate":123,
>            "normal":123,
>            "normal-bytes":123456
> 

Reviewed-by: Orit Wasserman <owasserm@redhat.com>

Patch

diff --git a/hmp.c b/hmp.c
index ba6fbd3..40b0c05 100644
--- a/hmp.c
+++ b/hmp.c
@@ -152,6 +152,10 @@  void hmp_info_migrate(Monitor *mon)
         monitor_printf(mon, "Migration status: %s\n", info->status);
         monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n",
                        info->total_time);
+        if (info->has_downtime) {
+            monitor_printf(mon, "downtime: %" PRIu64 " milliseconds\n",
+                           info->downtime);
+        }
     }

     if (info->has_ram) {
diff --git a/migration.c b/migration.c
index 1e3f791..c1655b3 100644
--- a/migration.c
+++ b/migration.c
@@ -195,6 +195,8 @@  MigrationInfo *qmp_query_migrate(Error **errp)
         info->has_status = true;
         info->status = g_strdup("completed");
         info->total_time = s->total_time;
+        info->has_downtime = true;
+        info->downtime = s->downtime;

         info->has_ram = true;
         info->ram = g_malloc0(sizeof(*info->ram));
@@ -327,9 +329,10 @@  static void migrate_fd_put_ready(void *opaque)
         migrate_fd_error(s);
     } else if (ret == 1) {
         int old_vm_running = runstate_is_running();
-        int64_t end_time;
+        int64_t start_time, end_time;

         DPRINTF("done iterating\n");
+        start_time = qemu_get_clock_ms(rt_clock);
         qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
         vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);

@@ -340,6 +343,7 @@  static void migrate_fd_put_ready(void *opaque)
         }
         end_time = qemu_get_clock_ms(rt_clock);
         s->total_time = end_time - s->total_time;
+        s->downtime = end_time - start_time;
         if (s->state != MIG_STATE_COMPLETED) {
             if (old_vm_running) {
                 vm_start();
diff --git a/migration.h b/migration.h
index a9852fc..3462917 100644
--- a/migration.h
+++ b/migration.h
@@ -40,6 +40,7 @@  struct MigrationState
     void *opaque;
     MigrationParams params;
     int64_t total_time;
+    int64_t downtime;
     bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
     int64_t xbzrle_cache_size;
 };
diff --git a/qapi-schema.json b/qapi-schema.json
index 14e4419..b5a4360 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -413,13 +413,18 @@ 
 #        If migration has ended, it returns the total migration
 #        time. (since 1.2)
 #
+# @downtime: #optional only present when migration finishes correctly
+#        total downtime in milliseconds for the guest.
+#        (since 1.3)
+#
 # Since: 0.14.0
 ##
 { 'type': 'MigrationInfo',
   'data': {'*status': 'str', '*ram': 'MigrationStats',
            '*disk': 'MigrationStats',
            '*xbzrle-cache': 'XBZRLECacheStats',
-           '*total-time': 'int'} }
+           '*total-time': 'int',
+           '*downtime': 'int'} }

 ##
 # @query-migrate
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 6e21ddb..37be613 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2267,6 +2267,8 @@  The main json-object contains the following:
 - "total-time": total amount of ms since migration started.  If
                 migration has ended, it returns the total migration
 		 time (json-int)
+- "downtime": only present when migration has finished correctly
+                total amount in ms for downtime that happened (json-int)
 - "ram": only present if "status" is "active", it is a json-object with the
   following RAM information (in bytes):
          - "transferred": amount transferred (json-int)
@@ -2304,6 +2306,7 @@  Examples:
           "remaining":123,
           "total":246,
           "total-time":12345,
+          "downtime":12345,
           "duplicate":123,
           "normal":123,
           "normal-bytes":123456