All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/8] Migration stats
@ 2012-08-18 11:17 Juan Quintela
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 1/8] buffered_file: g_realloc() can't fail Juan Quintela
                   ` (7 more replies)
  0 siblings, 8 replies; 23+ messages in thread
From: Juan Quintela @ 2012-08-18 11:17 UTC (permalink / raw)
  To: qemu-devel

Hi

v2:
- rebase on top of master
- apply all review comments for Eric & Luiz (1st time writting Eric correctly)
- dropped dirty_pages_rate: requires migration bitmap changes
- add examples were missing
- get feedback from several people that they were useful
- Intregrated migration bitmap sync, otherwise, we are transferring
  unmapped pages twice
- once there, minimal g_realloc() not needed NULL test

Please comment

v1:

This modifies the output of info migrate/qmp_query_migrate to add the
stats that I got request for.

- It moves total time to MigrationInfo instead of ram (luiz suggestion)
- Prints the real downtime that we have had

  really, it prints the total downtime of the complete phase, but the
  downtime also includes the last ram_iterate phase.  Working on
  fixing that one.

- Prints the expected downtime of the last time that w
e synchronized
  the dirty bitmap with kvm.  So we have one idea of what downtime
  value we need for migration to converge.

- Prints the dirty_pages_rate, that is the number of pages that we
  have written in the last second.  This one prints always zero.  To
  fill it, I need the dirty bitmap changes on the migration_thread
  series.

The following changes since commit 731dc9ecd4f2c3041538f7eb2d10eee0cb82da1b:

  Update version to 1.2.0-rc0 (2012-08-16 13:56:34 -0500)

are available in the git repository at:

  ssh://repo.or.cz/srv/git/qemu/quintela.git migration-next-20120819

for you to fetch changes up to 0fad89c1f4e6d4e48ab786acc3aa18e171b0fab2:

  migration: print expected downtime in info migrate (2012-08-18 12:40:36 +0200)

(Yes, I don't know in what day I live and put 19 instead of 18th.  It
is not that the patches are coming from the future O:-)

Juan Quintela (8):
  buffered_file: g_realloc() can't fail
  fix migration sync
  migration: move total_time from ram stats to migration info
  migration: store end_time in a local variable
  migration: print total downtime for final phase of migration
  migration: rename expected_time to expected_downtime
  migration: export migrate_get_current()
  migration: print expected downtime in info migrate

 arch_init.c      | 20 ++++++++++++--------
 buffered_file.c  | 10 +---------
 hmp.c            | 12 ++++++++++--
 migration.c      | 18 +++++++++++++-----
 migration.h      |  3 +++
 qapi-schema.json | 24 +++++++++++++++++-------
 qmp-commands.hx  | 15 ++++++++++++---
 7 files changed, 68 insertions(+), 34 deletions(-)

-- 
1.7.11.2

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Qemu-devel] [PATCH 1/8] buffered_file: g_realloc() can't fail
  2012-08-18 11:17 [Qemu-devel] [PATCH v2 0/8] Migration stats Juan Quintela
@ 2012-08-18 11:17 ` Juan Quintela
  2012-08-21 10:40   ` Orit Wasserman
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 2/8] fix migration sync Juan Quintela
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Juan Quintela @ 2012-08-18 11:17 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 buffered_file.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/buffered_file.c b/buffered_file.c
index f170aa0..4148abb 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -50,20 +50,12 @@ static void buffered_append(QEMUFileBuffered *s,
                             const uint8_t *buf, size_t size)
 {
     if (size > (s->buffer_capacity - s->buffer_size)) {
-        void *tmp;
-
         DPRINTF("increasing buffer capacity from %zu by %zu\n",
                 s->buffer_capacity, size + 1024);

         s->buffer_capacity += size + 1024;

-        tmp = g_realloc(s->buffer, s->buffer_capacity);
-        if (tmp == NULL) {
-            fprintf(stderr, "qemu file buffer expansion failed\n");
-            exit(1);
-        }
-
-        s->buffer = tmp;
+        s->buffer = g_realloc(s->buffer, s->buffer_capacity);
     }

     memcpy(s->buffer + s->buffer_size, buf, size);
-- 
1.7.11.2

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Qemu-devel] [PATCH 2/8] fix migration sync
  2012-08-18 11:17 [Qemu-devel] [PATCH v2 0/8] Migration stats Juan Quintela
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 1/8] buffered_file: g_realloc() can't fail Juan Quintela
@ 2012-08-18 11:17 ` Juan Quintela
  2012-08-21 10:52   ` Orit Wasserman
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 3/8] migration: move total_time from ram stats to migration info Juan Quintela
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Juan Quintela @ 2012-08-18 11:17 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 arch_init.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch_init.c b/arch_init.c
index 9b46bfc..0a9ca85 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -488,6 +488,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
     ram_addr_t addr;
     RAMBlock *block;

+    memory_global_sync_dirty_bitmap(get_system_memory());
     bytes_transferred = 0;
     last_block = NULL;
     last_offset = 0;
-- 
1.7.11.2

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Qemu-devel] [PATCH 3/8] migration: move total_time from ram stats to migration info
  2012-08-18 11:17 [Qemu-devel] [PATCH v2 0/8] Migration stats Juan Quintela
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 1/8] buffered_file: g_realloc() can't fail Juan Quintela
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 2/8] fix migration sync Juan Quintela
@ 2012-08-18 11:17 ` Juan Quintela
  2012-08-18 13:02   ` [Qemu-devel] For 1.2: " Eric Blake
  2012-08-21 10:53   ` [Qemu-devel] " Orit Wasserman
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 4/8] migration: store end_time in a local variable Juan Quintela
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 23+ messages in thread
From: Juan Quintela @ 2012-08-18 11:17 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hmp.c            |  4 ++--
 migration.c      |  6 +++---
 qapi-schema.json | 14 +++++++-------
 qmp-commands.hx  |  6 +++---
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/hmp.c b/hmp.c
index a9d5675..81c8acb 100644
--- a/hmp.c
+++ b/hmp.c
@@ -149,6 +149,8 @@ void hmp_info_migrate(Monitor *mon)

     if (info->has_status) {
         monitor_printf(mon, "Migration status: %s\n", info->status);
+        monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n",
+                       info->total_time);
     }

     if (info->has_ram) {
@@ -158,8 +160,6 @@ void hmp_info_migrate(Monitor *mon)
                        info->ram->remaining >> 10);
         monitor_printf(mon, "total ram: %" PRIu64 " kbytes\n",
                        info->ram->total >> 10);
-        monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n",
-                       info->ram->total_time);
         monitor_printf(mon, "duplicate: %" PRIu64 " pages\n",
                        info->ram->duplicate);
         monitor_printf(mon, "normal: %" PRIu64 " pages\n",
diff --git a/migration.c b/migration.c
index 653a3c1..8e4c508 100644
--- a/migration.c
+++ b/migration.c
@@ -166,14 +166,14 @@ MigrationInfo *qmp_query_migrate(Error **errp)
     case MIG_STATE_ACTIVE:
         info->has_status = true;
         info->status = g_strdup("active");
+        info->total_time = qemu_get_clock_ms(rt_clock)
+            - s->total_time;

         info->has_ram = true;
         info->ram = g_malloc0(sizeof(*info->ram));
         info->ram->transferred = ram_bytes_transferred();
         info->ram->remaining = ram_bytes_remaining();
         info->ram->total = ram_bytes_total();
-        info->ram->total_time = qemu_get_clock_ms(rt_clock)
-            - s->total_time;
         info->ram->duplicate = dup_mig_pages_transferred();
         info->ram->normal = norm_mig_pages_transferred();
         info->ram->normal_bytes = norm_mig_bytes_transferred();
@@ -193,13 +193,13 @@ MigrationInfo *qmp_query_migrate(Error **errp)

         info->has_status = true;
         info->status = g_strdup("completed");
+        info->total_time = s->total_time;

         info->has_ram = true;
         info->ram = g_malloc0(sizeof(*info->ram));
         info->ram->transferred = ram_bytes_transferred();
         info->ram->remaining = 0;
         info->ram->total = ram_bytes_total();
-        info->ram->total_time = s->total_time;
         info->ram->duplicate = dup_mig_pages_transferred();
         info->ram->normal = norm_mig_pages_transferred();
         info->ram->normal_bytes = norm_mig_bytes_transferred();
diff --git a/qapi-schema.json b/qapi-schema.json
index 3d2b2d1..f83cf22 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -290,10 +290,6 @@
 #
 # @total: total amount of bytes involved in the migration process
 #
-# @total-time: total amount of ms since migration started.  If
-#        migration has ended, it returns the total migration
-#        time. (since 1.2)
-#
 # @duplicate: number of duplicate pages (since 1.2)
 #
 # @normal : number of normal pages (since 1.2)
@@ -304,8 +300,7 @@
 ##
 { 'type': 'MigrationStats',
   'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' ,
-           'total-time': 'int', 'duplicate': 'int', 'normal': 'int',
-           'normal-bytes': 'int' } }
+           'duplicate': 'int', 'normal': 'int', 'normal-bytes': 'int' } }

 ##
 # @XBZRLECacheStats
@@ -350,12 +345,17 @@
 #                migration statistics, only returned if XBZRLE feature is on and
 #                status is 'active' or 'completed' (since 1.2)
 #
+# @total-time: total amount of milliseconds since migration started.
+#        If migration has ended, it returns the total migration
+#        time. (since 1.2)
+#
 # Since: 0.14.0
 ##
 { 'type': 'MigrationInfo',
   'data': {'*status': 'str', '*ram': 'MigrationStats',
            '*disk': 'MigrationStats',
-           '*xbzrle-cache': 'XBZRLECacheStats'} }
+           '*xbzrle-cache': 'XBZRLECacheStats',
+           'total-time': 'int'} }

 ##
 # @query-migrate
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 2ce4ce6..8671bf3 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2239,14 +2239,14 @@ The main json-object contains the following:

 - "status": migration status (json-string)
      - Possible values: "active", "completed", "failed", "cancelled"
+- "total-time": total amount of ms since migration started.  If
+                migration has ended, it returns the total migration
+		 time (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)
          - "remaining": amount remaining (json-int)
          - "total": total (json-int)
-         - "total-time": total amount of ms since migration started.  If
-                         migration has ended, it returns the total migration time
-                         (json-int)
          - "duplicate": number of duplicated pages (json-int)
          - "normal" : number of normal pages transferred (json-int)
          - "normal-bytes" : number of normal bytes transferred (json-int)
-- 
1.7.11.2

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Qemu-devel] [PATCH 4/8] migration: store end_time in a local variable
  2012-08-18 11:17 [Qemu-devel] [PATCH v2 0/8] Migration stats Juan Quintela
                   ` (2 preceding siblings ...)
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 3/8] migration: move total_time from ram stats to migration info Juan Quintela
@ 2012-08-18 11:17 ` Juan Quintela
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 5/8] migration: print total downtime for final phase of migration Juan Quintela
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: Juan Quintela @ 2012-08-18 11:17 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/migration.c b/migration.c
index 8e4c508..159728d 100644
--- a/migration.c
+++ b/migration.c
@@ -326,6 +326,7 @@ 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;

         DPRINTF("done iterating\n");
         qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
@@ -336,7 +337,8 @@ static void migrate_fd_put_ready(void *opaque)
         } else {
             migrate_fd_completed(s);
         }
-        s->total_time = qemu_get_clock_ms(rt_clock) - s->total_time;
+        end_time = qemu_get_clock_ms(rt_clock);
+        s->total_time = end_time - s->total_time;
         if (s->state != MIG_STATE_COMPLETED) {
             if (old_vm_running) {
                 vm_start();
-- 
1.7.11.2

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Qemu-devel] [PATCH 5/8] migration: print total downtime for final phase of migration
  2012-08-18 11:17 [Qemu-devel] [PATCH v2 0/8] Migration stats Juan Quintela
                   ` (3 preceding siblings ...)
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 4/8] migration: store end_time in a local variable Juan Quintela
@ 2012-08-18 11:17 ` Juan Quintela
  2012-08-18 13:04   ` Eric Blake
  2012-08-21 10:57   ` Orit Wasserman
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 6/8] migration: rename expected_time to expected_downtime Juan Quintela
                   ` (2 subsequent siblings)
  7 siblings, 2 replies; 23+ messages in thread
From: Juan Quintela @ 2012-08-18 11:17 UTC (permalink / raw)
  To: qemu-devel

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 81c8acb..8f24d9d 100644
--- a/hmp.c
+++ b/hmp.c
@@ -151,6 +151,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 159728d..49cd336 100644
--- a/migration.c
+++ b/migration.c
@@ -194,6 +194,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));
@@ -326,9 +328,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);

@@ -339,6 +342,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 f83cf22..29f601a 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -349,13 +349,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.2)
+#
 # 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 8671bf3..b5ca99f 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2242,6 +2242,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)
@@ -2279,6 +2281,7 @@ Examples:
           "remaining":123,
           "total":246,
           "total-time":12345,
+          "expected-downtime":12345,
           "duplicate":123,
           "normal":123,
           "normal-bytes":123456
-- 
1.7.11.2

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Qemu-devel] [PATCH 6/8] migration: rename expected_time to expected_downtime
  2012-08-18 11:17 [Qemu-devel] [PATCH v2 0/8] Migration stats Juan Quintela
                   ` (4 preceding siblings ...)
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 5/8] migration: print total downtime for final phase of migration Juan Quintela
@ 2012-08-18 11:17 ` Juan Quintela
  2012-08-21 10:57   ` Orit Wasserman
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 7/8] migration: export migrate_get_current() Juan Quintela
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 8/8] migration: print expected downtime in info migrate Juan Quintela
  7 siblings, 1 reply; 23+ messages in thread
From: Juan Quintela @ 2012-08-18 11:17 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 arch_init.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index 0a9ca85..7eb6e86 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -538,7 +538,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
     double bwidth = 0;
     int ret;
     int i;
-    uint64_t expected_time;
+    uint64_t expected_downtime;

     bytes_transferred_last = bytes_transferred;
     bwidth = qemu_get_clock_ns(rt_clock);
@@ -577,24 +577,25 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
     bwidth = qemu_get_clock_ns(rt_clock) - bwidth;
     bwidth = (bytes_transferred - bytes_transferred_last) / bwidth;

-    /* if we haven't transferred anything this round, force expected_time to a
-     * a very high value, but without crashing */
+    /* if we haven't transferred anything this round, force
+     * expected_downtime to a very high value, but without
+     * crashing */
     if (bwidth == 0) {
         bwidth = 0.000001;
     }

     qemu_put_be64(f, RAM_SAVE_FLAG_EOS);

-    expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
+    expected_downtime = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;

     DPRINTF("ram_save_live: expected(" PRIu64 ") <= max(" PRIu64 ")?\n",
-            expected_time, migrate_max_downtime());
+            expected_downtime, migrate_max_downtime());

-    if (expected_time <= migrate_max_downtime()) {
+    if (expected_downtime <= migrate_max_downtime()) {
         memory_global_sync_dirty_bitmap(get_system_memory());
-        expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
+        expected_downtime = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;

-        return expected_time <= migrate_max_downtime();
+        return expected_downtime <= migrate_max_downtime();
     }
     return 0;
 }
-- 
1.7.11.2

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Qemu-devel] [PATCH 7/8] migration: export migrate_get_current()
  2012-08-18 11:17 [Qemu-devel] [PATCH v2 0/8] Migration stats Juan Quintela
                   ` (5 preceding siblings ...)
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 6/8] migration: rename expected_time to expected_downtime Juan Quintela
@ 2012-08-18 11:17 ` Juan Quintela
  2012-08-21 10:58   ` Orit Wasserman
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 8/8] migration: print expected downtime in info migrate Juan Quintela
  7 siblings, 1 reply; 23+ messages in thread
From: Juan Quintela @ 2012-08-18 11:17 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration.c | 2 +-
 migration.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/migration.c b/migration.c
index 49cd336..186bcf2 100644
--- a/migration.c
+++ b/migration.c
@@ -53,7 +53,7 @@ static NotifierList migration_state_notifiers =
    migrations at once.  For now we don't need to add
    dynamic creation of migration */

-static MigrationState *migrate_get_current(void)
+MigrationState *migrate_get_current(void)
 {
     static MigrationState current_migration = {
         .state = MIG_STATE_SETUP,
diff --git a/migration.h b/migration.h
index 3462917..dabc333 100644
--- a/migration.h
+++ b/migration.h
@@ -81,6 +81,7 @@ void remove_migration_state_change_notifier(Notifier *notify);
 bool migration_is_active(MigrationState *);
 bool migration_has_finished(MigrationState *);
 bool migration_has_failed(MigrationState *);
+MigrationState *migrate_get_current(void);

 uint64_t ram_bytes_remaining(void);
 uint64_t ram_bytes_transferred(void);
-- 
1.7.11.2

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Qemu-devel] [PATCH 8/8] migration: print expected downtime in info migrate
  2012-08-18 11:17 [Qemu-devel] [PATCH v2 0/8] Migration stats Juan Quintela
                   ` (6 preceding siblings ...)
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 7/8] migration: export migrate_get_current() Juan Quintela
@ 2012-08-18 11:17 ` Juan Quintela
  2012-08-18 13:05   ` Eric Blake
  7 siblings, 1 reply; 23+ messages in thread
From: Juan Quintela @ 2012-08-18 11:17 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 arch_init.c      | 2 ++
 hmp.c            | 4 ++++
 migration.c      | 2 ++
 migration.h      | 1 +
 qapi-schema.json | 5 +++++
 qmp-commands.hx  | 6 ++++++
 6 files changed, 20 insertions(+)

diff --git a/arch_init.c b/arch_init.c
index 7eb6e86..3ddfff9 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -539,6 +539,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
     int ret;
     int i;
     uint64_t expected_downtime;
+    MigrationState *s = migrate_get_current();

     bytes_transferred_last = bytes_transferred;
     bwidth = qemu_get_clock_ns(rt_clock);
@@ -594,6 +595,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
     if (expected_downtime <= migrate_max_downtime()) {
         memory_global_sync_dirty_bitmap(get_system_memory());
         expected_downtime = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
+        s->expected_downtime = expected_downtime / 1000000; /* ns -> ms */

         return expected_downtime <= migrate_max_downtime();
     }
diff --git a/hmp.c b/hmp.c
index 8f24d9d..dfa4fb0 100644
--- a/hmp.c
+++ b/hmp.c
@@ -151,6 +151,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_expected_downtime) {
+            monitor_printf(mon, "expected downtime: %" PRIu64 " milliseconds\n",
+                           info->expected_downtime);
+        }
         if (info->has_downtime) {
             monitor_printf(mon, "downtime: %" PRIu64 " milliseconds\n",
                            info->downtime);
diff --git a/migration.c b/migration.c
index 186bcf2..fd069f2 100644
--- a/migration.c
+++ b/migration.c
@@ -168,6 +168,8 @@ MigrationInfo *qmp_query_migrate(Error **errp)
         info->status = g_strdup("active");
         info->total_time = qemu_get_clock_ms(rt_clock)
             - s->total_time;
+        info->has_expected_downtime = true;
+        info->expected_downtime = s->expected_downtime;

         info->has_ram = true;
         info->ram = g_malloc0(sizeof(*info->ram));
diff --git a/migration.h b/migration.h
index dabc333..552200c 100644
--- a/migration.h
+++ b/migration.h
@@ -41,6 +41,7 @@ struct MigrationState
     MigrationParams params;
     int64_t total_time;
     int64_t downtime;
+    int64_t expected_downtime;
     bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
     int64_t xbzrle_cache_size;
 };
diff --git a/qapi-schema.json b/qapi-schema.json
index 29f601a..fcdabdc 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -353,6 +353,10 @@
 #        total downtime in milliseconds for the guest.
 #        (since 1.2)
 #
+# @expected-downtime: #optional only present while migration is active
+#        expected downtime in milliseconds for the guest in last walk
+#        of the dirty bitmap. (since 1.2)
+#
 # Since: 0.14.0
 ##
 { 'type': 'MigrationInfo',
@@ -360,6 +364,7 @@
            '*disk': 'MigrationStats',
            '*xbzrle-cache': 'XBZRLECacheStats',
            'total-time': 'int',
+           '*expected-downtime': 'int',
            '*downtime': 'int'} }

 ##
diff --git a/qmp-commands.hx b/qmp-commands.hx
index b5ca99f..2b85802 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2244,6 +2244,9 @@ The main json-object contains the following:
 		 time (json-int)
 - "downtime": only present when migration has finished correctly
                 total amount in ms for downtime that happened (json-int)
+- "expected-downtime": only present while migration is active
+                total amount in ms for downtime that was calculated on
+		the last bitmap round (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)
@@ -2305,6 +2308,7 @@ Examples:
             "remaining":123,
             "total":246,
             "total-time":12345,
+	    "expected-downtime":12345,
             "duplicate":123,
             "normal":123,
             "normal-bytes":123456
@@ -2323,6 +2327,7 @@ Examples:
             "remaining":1053304,
             "transferred":3720,
             "total-time":12345,
+	    "expected-downtime":12345,
             "duplicate":123,
             "normal":123,
             "normal-bytes":123456
@@ -2347,6 +2352,7 @@ Examples:
             "remaining":1053304,
             "transferred":3720,
             "total-time":12345,
+	    "expected-downtime":12345,
             "duplicate":10,
             "normal":3333,
             "normal-bytes":3412992
-- 
1.7.11.2

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [Qemu-devel] For 1.2: Re: [PATCH 3/8] migration: move total_time from ram stats to migration info
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 3/8] migration: move total_time from ram stats to migration info Juan Quintela
@ 2012-08-18 13:02   ` Eric Blake
  2012-08-21 14:42     ` Luiz Capitulino
  2012-08-22 13:22     ` Anthony Liguori
  2012-08-21 10:53   ` [Qemu-devel] " Orit Wasserman
  1 sibling, 2 replies; 23+ messages in thread
From: Eric Blake @ 2012-08-18 13:02 UTC (permalink / raw)
  To: Juan Quintela; +Cc: Anthony Liguori, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2108 bytes --]

On 08/18/2012 05:17 AM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  hmp.c            |  4 ++--
>  migration.c      |  6 +++---
>  qapi-schema.json | 14 +++++++-------
>  qmp-commands.hx  |  6 +++---
>  4 files changed, 15 insertions(+), 15 deletions(-)
> 

> +++ b/qapi-schema.json
> @@ -290,10 +290,6 @@
>  #
>  # @total: total amount of bytes involved in the migration process
>  #
> -# @total-time: total amount of ms since migration started.  If
> -#        migration has ended, it returns the total migration
> -#        time. (since 1.2)
> -#
>  # @duplicate: number of duplicate pages (since 1.2)
>  #
>  # @normal : number of normal pages (since 1.2)
> @@ -304,8 +300,7 @@
>  ##
>  { 'type': 'MigrationStats',
>    'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' ,
> -           'total-time': 'int', 'duplicate': 'int', 'normal': 'int',
> -           'normal-bytes': 'int' } }
> +           'duplicate': 'int', 'normal': 'int', 'normal-bytes': 'int' } }
> 
>  ##
>  # @XBZRLECacheStats
> @@ -350,12 +345,17 @@
>  #                migration statistics, only returned if XBZRLE feature is on and
>  #                status is 'active' or 'completed' (since 1.2)
>  #
> +# @total-time: total amount of milliseconds since migration started.
> +#        If migration has ended, it returns the total migration
> +#        time. (since 1.2)
> +#
>  # Since: 0.14.0
>  ##
>  { 'type': 'MigrationInfo',
>    'data': {'*status': 'str', '*ram': 'MigrationStats',
>             '*disk': 'MigrationStats',
> -           '*xbzrle-cache': 'XBZRLECacheStats'} }
> +           '*xbzrle-cache': 'XBZRLECacheStats',
> +           'total-time': 'int'} }

Anthony - are you planning on taking this series for 1.2?  If we don't
get this patch in on time, then taking this for 1.3 would result in
changing released QMP interface (right now, there has been no release
with the field in the wrong type).

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 620 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Qemu-devel] [PATCH 5/8] migration: print total downtime for final phase of migration
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 5/8] migration: print total downtime for final phase of migration Juan Quintela
@ 2012-08-18 13:04   ` Eric Blake
  2012-08-21 10:57   ` Orit Wasserman
  1 sibling, 0 replies; 23+ messages in thread
From: Eric Blake @ 2012-08-18 13:04 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]

On 08/18/2012 05:17 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(-)

> +++ b/qmp-commands.hx
> @@ -2242,6 +2242,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)
> @@ -2279,6 +2281,7 @@ Examples:
>            "remaining":123,
>            "total":246,
>            "total-time":12345,
> +          "expected-downtime":12345,

s/expected-//

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 620 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Qemu-devel] [PATCH 8/8] migration: print expected downtime in info migrate
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 8/8] migration: print expected downtime in info migrate Juan Quintela
@ 2012-08-18 13:05   ` Eric Blake
  0 siblings, 0 replies; 23+ messages in thread
From: Eric Blake @ 2012-08-18 13:05 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1271 bytes --]

On 08/18/2012 05:17 AM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  arch_init.c      | 2 ++
>  hmp.c            | 4 ++++
>  migration.c      | 2 ++
>  migration.h      | 1 +
>  qapi-schema.json | 5 +++++
>  qmp-commands.hx  | 6 ++++++
>  6 files changed, 20 insertions(+)
> 

> +++ b/qmp-commands.hx
> @@ -2244,6 +2244,9 @@ The main json-object contains the following:
>  		 time (json-int)
>  - "downtime": only present when migration has finished correctly
>                  total amount in ms for downtime that happened (json-int)
> +- "expected-downtime": only present while migration is active
> +                total amount in ms for downtime that was calculated on
> +		the last bitmap round (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)
> @@ -2305,6 +2308,7 @@ Examples:
>              "remaining":123,
>              "total":246,
>              "total-time":12345,
> +	    "expected-downtime":12345,

TAB damage, on several examples.

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 620 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Qemu-devel] [PATCH 1/8] buffered_file: g_realloc() can't fail
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 1/8] buffered_file: g_realloc() can't fail Juan Quintela
@ 2012-08-21 10:40   ` Orit Wasserman
  0 siblings, 0 replies; 23+ messages in thread
From: Orit Wasserman @ 2012-08-21 10:40 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

On 08/18/2012 02:17 PM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  buffered_file.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/buffered_file.c b/buffered_file.c
> index f170aa0..4148abb 100644
> --- a/buffered_file.c
> +++ b/buffered_file.c
> @@ -50,20 +50,12 @@ static void buffered_append(QEMUFileBuffered *s,
>                              const uint8_t *buf, size_t size)
>  {
>      if (size > (s->buffer_capacity - s->buffer_size)) {
> -        void *tmp;
> -
>          DPRINTF("increasing buffer capacity from %zu by %zu\n",
>                  s->buffer_capacity, size + 1024);
> 
>          s->buffer_capacity += size + 1024;
> 
> -        tmp = g_realloc(s->buffer, s->buffer_capacity);
> -        if (tmp == NULL) {
> -            fprintf(stderr, "qemu file buffer expansion failed\n");
> -            exit(1);
> -        }
> -
> -        s->buffer = tmp;
> +        s->buffer = g_realloc(s->buffer, s->buffer_capacity);
>      }
> 
>      memcpy(s->buffer + s->buffer_size, buf, size);
> 

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Qemu-devel] [PATCH 2/8] fix migration sync
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 2/8] fix migration sync Juan Quintela
@ 2012-08-21 10:52   ` Orit Wasserman
  0 siblings, 0 replies; 23+ messages in thread
From: Orit Wasserman @ 2012-08-21 10:52 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

On 08/18/2012 02:17 PM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  arch_init.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch_init.c b/arch_init.c
> index 9b46bfc..0a9ca85 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -488,6 +488,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
>      ram_addr_t addr;
>      RAMBlock *block;
> 
> +    memory_global_sync_dirty_bitmap(get_system_memory());
>      bytes_transferred = 0;
>      last_block = NULL;
>      last_offset = 0;
> 
Reviewed-by: Orit Wasserman <owasserm@redhat.com>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Qemu-devel] [PATCH 3/8] migration: move total_time from ram stats to migration info
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 3/8] migration: move total_time from ram stats to migration info Juan Quintela
  2012-08-18 13:02   ` [Qemu-devel] For 1.2: " Eric Blake
@ 2012-08-21 10:53   ` Orit Wasserman
  1 sibling, 0 replies; 23+ messages in thread
From: Orit Wasserman @ 2012-08-21 10:53 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

On 08/18/2012 02:17 PM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  hmp.c            |  4 ++--
>  migration.c      |  6 +++---
>  qapi-schema.json | 14 +++++++-------
>  qmp-commands.hx  |  6 +++---
>  4 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/hmp.c b/hmp.c
> index a9d5675..81c8acb 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -149,6 +149,8 @@ void hmp_info_migrate(Monitor *mon)
> 
>      if (info->has_status) {
>          monitor_printf(mon, "Migration status: %s\n", info->status);
> +        monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n",
> +                       info->total_time);
>      }
> 
>      if (info->has_ram) {
> @@ -158,8 +160,6 @@ void hmp_info_migrate(Monitor *mon)
>                         info->ram->remaining >> 10);
>          monitor_printf(mon, "total ram: %" PRIu64 " kbytes\n",
>                         info->ram->total >> 10);
> -        monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n",
> -                       info->ram->total_time);
>          monitor_printf(mon, "duplicate: %" PRIu64 " pages\n",
>                         info->ram->duplicate);
>          monitor_printf(mon, "normal: %" PRIu64 " pages\n",
> diff --git a/migration.c b/migration.c
> index 653a3c1..8e4c508 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -166,14 +166,14 @@ MigrationInfo *qmp_query_migrate(Error **errp)
>      case MIG_STATE_ACTIVE:
>          info->has_status = true;
>          info->status = g_strdup("active");
> +        info->total_time = qemu_get_clock_ms(rt_clock)
> +            - s->total_time;
> 
>          info->has_ram = true;
>          info->ram = g_malloc0(sizeof(*info->ram));
>          info->ram->transferred = ram_bytes_transferred();
>          info->ram->remaining = ram_bytes_remaining();
>          info->ram->total = ram_bytes_total();
> -        info->ram->total_time = qemu_get_clock_ms(rt_clock)
> -            - s->total_time;
>          info->ram->duplicate = dup_mig_pages_transferred();
>          info->ram->normal = norm_mig_pages_transferred();
>          info->ram->normal_bytes = norm_mig_bytes_transferred();
> @@ -193,13 +193,13 @@ MigrationInfo *qmp_query_migrate(Error **errp)
> 
>          info->has_status = true;
>          info->status = g_strdup("completed");
> +        info->total_time = s->total_time;
> 
>          info->has_ram = true;
>          info->ram = g_malloc0(sizeof(*info->ram));
>          info->ram->transferred = ram_bytes_transferred();
>          info->ram->remaining = 0;
>          info->ram->total = ram_bytes_total();
> -        info->ram->total_time = s->total_time;
>          info->ram->duplicate = dup_mig_pages_transferred();
>          info->ram->normal = norm_mig_pages_transferred();
>          info->ram->normal_bytes = norm_mig_bytes_transferred();
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 3d2b2d1..f83cf22 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -290,10 +290,6 @@
>  #
>  # @total: total amount of bytes involved in the migration process
>  #
> -# @total-time: total amount of ms since migration started.  If
> -#        migration has ended, it returns the total migration
> -#        time. (since 1.2)
> -#
>  # @duplicate: number of duplicate pages (since 1.2)
>  #
>  # @normal : number of normal pages (since 1.2)
> @@ -304,8 +300,7 @@
>  ##
>  { 'type': 'MigrationStats',
>    'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' ,
> -           'total-time': 'int', 'duplicate': 'int', 'normal': 'int',
> -           'normal-bytes': 'int' } }
> +           'duplicate': 'int', 'normal': 'int', 'normal-bytes': 'int' } }
> 
>  ##
>  # @XBZRLECacheStats
> @@ -350,12 +345,17 @@
>  #                migration statistics, only returned if XBZRLE feature is on and
>  #                status is 'active' or 'completed' (since 1.2)
>  #
> +# @total-time: total amount of milliseconds since migration started.
> +#        If migration has ended, it returns the total migration
> +#        time. (since 1.2)
> +#
>  # Since: 0.14.0
>  ##
>  { 'type': 'MigrationInfo',
>    'data': {'*status': 'str', '*ram': 'MigrationStats',
>             '*disk': 'MigrationStats',
> -           '*xbzrle-cache': 'XBZRLECacheStats'} }
> +           '*xbzrle-cache': 'XBZRLECacheStats',
> +           'total-time': 'int'} }
> 
>  ##
>  # @query-migrate
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index 2ce4ce6..8671bf3 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -2239,14 +2239,14 @@ The main json-object contains the following:
> 
>  - "status": migration status (json-string)
>       - Possible values: "active", "completed", "failed", "cancelled"
> +- "total-time": total amount of ms since migration started.  If
> +                migration has ended, it returns the total migration
> +		 time (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)
>           - "remaining": amount remaining (json-int)
>           - "total": total (json-int)
> -         - "total-time": total amount of ms since migration started.  If
> -                         migration has ended, it returns the total migration time
> -                         (json-int)
>           - "duplicate": number of duplicated pages (json-int)
>           - "normal" : number of normal pages transferred (json-int)
>           - "normal-bytes" : number of normal bytes transferred (json-int)
> 
Reviewed-by: Orit Wasserman <owasserm@redhat.com>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Qemu-devel] [PATCH 5/8] migration: print total downtime for final phase of migration
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 5/8] migration: print total downtime for final phase of migration Juan Quintela
  2012-08-18 13:04   ` Eric Blake
@ 2012-08-21 10:57   ` Orit Wasserman
  1 sibling, 0 replies; 23+ messages in thread
From: Orit Wasserman @ 2012-08-21 10:57 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

On 08/18/2012 02:17 PM, 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 81c8acb..8f24d9d 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -151,6 +151,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 159728d..49cd336 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -194,6 +194,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));
> @@ -326,9 +328,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);
> 
> @@ -339,6 +342,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 f83cf22..29f601a 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -349,13 +349,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.2)
will it make it to 1.2 ? if not than 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 8671bf3..b5ca99f 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -2242,6 +2242,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)
> @@ -2279,6 +2281,7 @@ Examples:
>            "remaining":123,
>            "total":246,
>            "total-time":12345,
> +          "expected-downtime":12345,
>            "duplicate":123,
>            "normal":123,
>            "normal-bytes":123456
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Qemu-devel] [PATCH 6/8] migration: rename expected_time to expected_downtime
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 6/8] migration: rename expected_time to expected_downtime Juan Quintela
@ 2012-08-21 10:57   ` Orit Wasserman
  0 siblings, 0 replies; 23+ messages in thread
From: Orit Wasserman @ 2012-08-21 10:57 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

On 08/18/2012 02:17 PM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  arch_init.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/arch_init.c b/arch_init.c
> index 0a9ca85..7eb6e86 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -538,7 +538,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
>      double bwidth = 0;
>      int ret;
>      int i;
> -    uint64_t expected_time;
> +    uint64_t expected_downtime;
> 
>      bytes_transferred_last = bytes_transferred;
>      bwidth = qemu_get_clock_ns(rt_clock);
> @@ -577,24 +577,25 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
>      bwidth = qemu_get_clock_ns(rt_clock) - bwidth;
>      bwidth = (bytes_transferred - bytes_transferred_last) / bwidth;
> 
> -    /* if we haven't transferred anything this round, force expected_time to a
> -     * a very high value, but without crashing */
> +    /* if we haven't transferred anything this round, force
> +     * expected_downtime to a very high value, but without
> +     * crashing */
>      if (bwidth == 0) {
>          bwidth = 0.000001;
>      }
> 
>      qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
> 
> -    expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
> +    expected_downtime = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
> 
>      DPRINTF("ram_save_live: expected(" PRIu64 ") <= max(" PRIu64 ")?\n",
> -            expected_time, migrate_max_downtime());
> +            expected_downtime, migrate_max_downtime());
> 
> -    if (expected_time <= migrate_max_downtime()) {
> +    if (expected_downtime <= migrate_max_downtime()) {
>          memory_global_sync_dirty_bitmap(get_system_memory());
> -        expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
> +        expected_downtime = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
> 
> -        return expected_time <= migrate_max_downtime();
> +        return expected_downtime <= migrate_max_downtime();
>      }
>      return 0;
>  }
> 
Reviewed-by: Orit Wasserman <owasserm@redhat.com>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Qemu-devel] [PATCH 7/8] migration: export migrate_get_current()
  2012-08-18 11:17 ` [Qemu-devel] [PATCH 7/8] migration: export migrate_get_current() Juan Quintela
@ 2012-08-21 10:58   ` Orit Wasserman
  0 siblings, 0 replies; 23+ messages in thread
From: Orit Wasserman @ 2012-08-21 10:58 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

On 08/18/2012 02:17 PM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  migration.c | 2 +-
>  migration.h | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/migration.c b/migration.c
> index 49cd336..186bcf2 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -53,7 +53,7 @@ static NotifierList migration_state_notifiers =
>     migrations at once.  For now we don't need to add
>     dynamic creation of migration */
> 
> -static MigrationState *migrate_get_current(void)
> +MigrationState *migrate_get_current(void)
>  {
>      static MigrationState current_migration = {
>          .state = MIG_STATE_SETUP,
> diff --git a/migration.h b/migration.h
> index 3462917..dabc333 100644
> --- a/migration.h
> +++ b/migration.h
> @@ -81,6 +81,7 @@ void remove_migration_state_change_notifier(Notifier *notify);
>  bool migration_is_active(MigrationState *);
>  bool migration_has_finished(MigrationState *);
>  bool migration_has_failed(MigrationState *);
> +MigrationState *migrate_get_current(void);
> 
>  uint64_t ram_bytes_remaining(void);
>  uint64_t ram_bytes_transferred(void);
> 
Reviewed-by: Orit Wasserman <owasserm@redhat.com>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Qemu-devel] For 1.2: Re: [PATCH 3/8] migration: move total_time from ram stats to migration info
  2012-08-18 13:02   ` [Qemu-devel] For 1.2: " Eric Blake
@ 2012-08-21 14:42     ` Luiz Capitulino
  2012-08-21 15:00       ` Juan Quintela
  2012-08-22 13:22     ` Anthony Liguori
  1 sibling, 1 reply; 23+ messages in thread
From: Luiz Capitulino @ 2012-08-21 14:42 UTC (permalink / raw)
  To: Eric Blake; +Cc: Anthony Liguori, qemu-devel, Juan Quintela

On Sat, 18 Aug 2012 07:02:50 -0600
Eric Blake <eblake@redhat.com> wrote:

> On 08/18/2012 05:17 AM, Juan Quintela wrote:
> > Signed-off-by: Juan Quintela <quintela@redhat.com>
> > ---
> >  hmp.c            |  4 ++--
> >  migration.c      |  6 +++---
> >  qapi-schema.json | 14 +++++++-------
> >  qmp-commands.hx  |  6 +++---
> >  4 files changed, 15 insertions(+), 15 deletions(-)
> > 
> 
> > +++ b/qapi-schema.json
> > @@ -290,10 +290,6 @@
> >  #
> >  # @total: total amount of bytes involved in the migration process
> >  #
> > -# @total-time: total amount of ms since migration started.  If
> > -#        migration has ended, it returns the total migration
> > -#        time. (since 1.2)
> > -#
> >  # @duplicate: number of duplicate pages (since 1.2)
> >  #
> >  # @normal : number of normal pages (since 1.2)
> > @@ -304,8 +300,7 @@
> >  ##
> >  { 'type': 'MigrationStats',
> >    'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' ,
> > -           'total-time': 'int', 'duplicate': 'int', 'normal': 'int',
> > -           'normal-bytes': 'int' } }
> > +           'duplicate': 'int', 'normal': 'int', 'normal-bytes': 'int' } }
> > 
> >  ##
> >  # @XBZRLECacheStats
> > @@ -350,12 +345,17 @@
> >  #                migration statistics, only returned if XBZRLE feature is on and
> >  #                status is 'active' or 'completed' (since 1.2)
> >  #
> > +# @total-time: total amount of milliseconds since migration started.
> > +#        If migration has ended, it returns the total migration
> > +#        time. (since 1.2)

Field is optional, needs to be marked as such and the has_total_time field
should be set appropriately.

> > +#
> >  # Since: 0.14.0
> >  ##
> >  { 'type': 'MigrationInfo',
> >    'data': {'*status': 'str', '*ram': 'MigrationStats',
> >             '*disk': 'MigrationStats',
> > -           '*xbzrle-cache': 'XBZRLECacheStats'} }
> > +           '*xbzrle-cache': 'XBZRLECacheStats',
> > +           'total-time': 'int'} }
> 
> Anthony - are you planning on taking this series for 1.2?  If we don't
> get this patch in on time, then taking this for 1.3 would result in
> changing released QMP interface (right now, there has been no release
> with the field in the wrong type).

I can cherry-pick this into the qmp branch.

Juan, I can also fix myself the problem I pointed out above if that
works for you.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Qemu-devel] For 1.2: Re: [PATCH 3/8] migration: move total_time from ram stats to migration info
  2012-08-21 14:42     ` Luiz Capitulino
@ 2012-08-21 15:00       ` Juan Quintela
  2012-08-21 18:24         ` Luiz Capitulino
  0 siblings, 1 reply; 23+ messages in thread
From: Juan Quintela @ 2012-08-21 15:00 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: Anthony Liguori, Eric Blake, qemu-devel

Luiz Capitulino <lcapitulino@redhat.com> wrote:
> On Sat, 18 Aug 2012 07:02:50 -0600
> Eric Blake <eblake@redhat.com> wrote:
>
> I can cherry-pick this into the qmp branch.
>
> Juan, I can also fix myself the problem I pointed out above if that
> works for you.

I very much preffer that.  But what to do with the other ones?

They are really simple, and it makes things better for users?

Anthony?

Later, Juan.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Qemu-devel] For 1.2: Re: [PATCH 3/8] migration: move total_time from ram stats to migration info
  2012-08-21 15:00       ` Juan Quintela
@ 2012-08-21 18:24         ` Luiz Capitulino
  0 siblings, 0 replies; 23+ messages in thread
From: Luiz Capitulino @ 2012-08-21 18:24 UTC (permalink / raw)
  To: quintela; +Cc: Anthony Liguori, Eric Blake, qemu-devel

On Tue, 21 Aug 2012 17:00:20 +0200
Juan Quintela <quintela@redhat.com> wrote:

> Luiz Capitulino <lcapitulino@redhat.com> wrote:
> > On Sat, 18 Aug 2012 07:02:50 -0600
> > Eric Blake <eblake@redhat.com> wrote:
> >
> > I can cherry-pick this into the qmp branch.
> >
> > Juan, I can also fix myself the problem I pointed out above if that
> > works for you.
> 
> I very much preffer that.

Done, and applied to the qmp branch for 1.2.

>  But what to do with the other ones?

They look good to me, but I think it's too late for 1.2.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Qemu-devel] For 1.2: Re: [PATCH 3/8] migration: move total_time from ram stats to migration info
  2012-08-18 13:02   ` [Qemu-devel] For 1.2: " Eric Blake
  2012-08-21 14:42     ` Luiz Capitulino
@ 2012-08-22 13:22     ` Anthony Liguori
  2012-08-22 14:48       ` Eric Blake
  1 sibling, 1 reply; 23+ messages in thread
From: Anthony Liguori @ 2012-08-22 13:22 UTC (permalink / raw)
  To: Eric Blake, Juan Quintela; +Cc: qemu-devel

Eric Blake <eblake@redhat.com> writes:

> On 08/18/2012 05:17 AM, Juan Quintela wrote:
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> ---
>>  hmp.c            |  4 ++--
>>  migration.c      |  6 +++---
>>  qapi-schema.json | 14 +++++++-------
>>  qmp-commands.hx  |  6 +++---
>>  4 files changed, 15 insertions(+), 15 deletions(-)
>> 
>
>> +++ b/qapi-schema.json
>> @@ -290,10 +290,6 @@
>>  #
>>  # @total: total amount of bytes involved in the migration process
>>  #
>> -# @total-time: total amount of ms since migration started.  If
>> -#        migration has ended, it returns the total migration
>> -#        time. (since 1.2)
>> -#
>>  # @duplicate: number of duplicate pages (since 1.2)
>>  #
>>  # @normal : number of normal pages (since 1.2)
>> @@ -304,8 +300,7 @@
>>  ##
>>  { 'type': 'MigrationStats',
>>    'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' ,
>> -           'total-time': 'int', 'duplicate': 'int', 'normal': 'int',
>> -           'normal-bytes': 'int' } }
>> +           'duplicate': 'int', 'normal': 'int', 'normal-bytes': 'int' } }
>> 
>>  ##
>>  # @XBZRLECacheStats
>> @@ -350,12 +345,17 @@
>>  #                migration statistics, only returned if XBZRLE feature is on and
>>  #                status is 'active' or 'completed' (since 1.2)
>>  #
>> +# @total-time: total amount of milliseconds since migration started.
>> +#        If migration has ended, it returns the total migration
>> +#        time. (since 1.2)
>> +#
>>  # Since: 0.14.0
>>  ##
>>  { 'type': 'MigrationInfo',
>>    'data': {'*status': 'str', '*ram': 'MigrationStats',
>>             '*disk': 'MigrationStats',
>> -           '*xbzrle-cache': 'XBZRLECacheStats'} }
>> +           '*xbzrle-cache': 'XBZRLECacheStats',
>> +           'total-time': 'int'} }
>
> Anthony - are you planning on taking this series for 1.2?

No.  This is a new feature and we're past freeze.

> If we don't
> get this patch in on time, then taking this for 1.3 would result in
> changing released QMP interface (right now, there has been no release
> with the field in the wrong type).

Ack.  We need to preserve compat with the 1.2 interface.

Regards,

Anthony Liguori

>
> -- 
> Eric Blake   eblake@redhat.com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [Qemu-devel] For 1.2: Re: [PATCH 3/8] migration: move total_time from ram stats to migration info
  2012-08-22 13:22     ` Anthony Liguori
@ 2012-08-22 14:48       ` Eric Blake
  0 siblings, 0 replies; 23+ messages in thread
From: Eric Blake @ 2012-08-22 14:48 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, Juan Quintela

[-- Attachment #1: Type: text/plain, Size: 1193 bytes --]

On 08/22/2012 07:22 AM, Anthony Liguori wrote:

Just restating things to make sure I'm clear...

>>>  { 'type': 'MigrationInfo',
>>>    'data': {'*status': 'str', '*ram': 'MigrationStats',
>>>             '*disk': 'MigrationStats',
>>> -           '*xbzrle-cache': 'XBZRLECacheStats'} }
>>> +           '*xbzrle-cache': 'XBZRLECacheStats',
>>> +           'total-time': 'int'} }
>>
>> Anthony - are you planning on taking this series for 1.2?
> 
> No.  This is a new feature and we're past freeze.

No, the overall series (patches 1,2,4-8) is not appropriate at this time.

> 
>> If we don't
>> get this patch in on time, then taking this for 1.3 would result in
>> changing released QMP interface (right now, there has been no release
>> with the field in the wrong type).
> 
> Ack.  We need to preserve compat with the 1.2 interface.

Yes, this particular patch 3 is a bug fix in order to prevent a future
regression when 1.3 takes the rest of the series, and must therefore be
part of the 1.2 release (and Luiz is on top of that, via the qmp branch).

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 620 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2012-08-22 14:48 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-18 11:17 [Qemu-devel] [PATCH v2 0/8] Migration stats Juan Quintela
2012-08-18 11:17 ` [Qemu-devel] [PATCH 1/8] buffered_file: g_realloc() can't fail Juan Quintela
2012-08-21 10:40   ` Orit Wasserman
2012-08-18 11:17 ` [Qemu-devel] [PATCH 2/8] fix migration sync Juan Quintela
2012-08-21 10:52   ` Orit Wasserman
2012-08-18 11:17 ` [Qemu-devel] [PATCH 3/8] migration: move total_time from ram stats to migration info Juan Quintela
2012-08-18 13:02   ` [Qemu-devel] For 1.2: " Eric Blake
2012-08-21 14:42     ` Luiz Capitulino
2012-08-21 15:00       ` Juan Quintela
2012-08-21 18:24         ` Luiz Capitulino
2012-08-22 13:22     ` Anthony Liguori
2012-08-22 14:48       ` Eric Blake
2012-08-21 10:53   ` [Qemu-devel] " Orit Wasserman
2012-08-18 11:17 ` [Qemu-devel] [PATCH 4/8] migration: store end_time in a local variable Juan Quintela
2012-08-18 11:17 ` [Qemu-devel] [PATCH 5/8] migration: print total downtime for final phase of migration Juan Quintela
2012-08-18 13:04   ` Eric Blake
2012-08-21 10:57   ` Orit Wasserman
2012-08-18 11:17 ` [Qemu-devel] [PATCH 6/8] migration: rename expected_time to expected_downtime Juan Quintela
2012-08-21 10:57   ` Orit Wasserman
2012-08-18 11:17 ` [Qemu-devel] [PATCH 7/8] migration: export migrate_get_current() Juan Quintela
2012-08-21 10:58   ` Orit Wasserman
2012-08-18 11:17 ` [Qemu-devel] [PATCH 8/8] migration: print expected downtime in info migrate Juan Quintela
2012-08-18 13:05   ` Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.