Patchwork [21/23] block migration: Report progress also via info migration

login
register
mail settings
Submitter Jan Kiszka
Date Nov. 30, 2009, 5:21 p.m.
Message ID <20091130172121.22889.51678.stgit@mchn012c.ww002.siemens.net>
Download mbox | patch
Permalink /patch/39835/
State New
Headers show

Comments

Jan Kiszka - Nov. 30, 2009, 5:21 p.m.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

 block-migration.c |   32 ++++++++++++++++++++++++++++++++
 block-migration.h |    4 ++++
 migration.c       |    9 +++++++++
 3 files changed, 45 insertions(+), 0 deletions(-)

Patch

diff --git a/block-migration.c b/block-migration.c
index 22d10f0..7510923 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -91,6 +91,38 @@  static void blk_send(QEMUFile *f, BlkMigBlock * blk)
     qemu_put_buffer(f, blk->buf, BLOCK_SIZE);
 }
 
+int blk_mig_active(void)
+{
+    return !QSIMPLEQ_EMPTY(&block_mig_state.bmds_list);
+}
+
+uint64_t blk_mig_bytes_transferred(void)
+{
+    BlkMigDevState *bmds;
+    uint64_t sum = 0;
+
+    QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
+        sum += bmds->completed_sectors;
+    }
+    return sum << BDRV_SECTOR_BITS;
+}
+
+uint64_t blk_mig_bytes_remaining(void)
+{
+    return blk_mig_bytes_total() - blk_mig_bytes_transferred();
+}
+
+uint64_t blk_mig_bytes_total(void)
+{
+    BlkMigDevState *bmds;
+    uint64_t sum = 0;
+
+    QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
+        sum += bmds->total_sectors;
+    }
+    return sum << BDRV_SECTOR_BITS;
+}
+
 static void blk_mig_read_cb(void *opaque, int ret)
 {
     BlkMigBlock *blk = opaque;
diff --git a/block-migration.h b/block-migration.h
index a274d2d..ffa8ac0 100644
--- a/block-migration.h
+++ b/block-migration.h
@@ -15,5 +15,9 @@ 
 #define BLOCK_MIGRATION_H
 
 void blk_mig_init(void);
+int blk_mig_active(void);
+uint64_t blk_mig_bytes_transferred(void);
+uint64_t blk_mig_bytes_remaining(void);
+uint64_t blk_mig_bytes_total(void);
 
 #endif /* BLOCK_MIGRATION_H */
diff --git a/migration.c b/migration.c
index f4d3022..d6a3e26 100644
--- a/migration.c
+++ b/migration.c
@@ -18,6 +18,7 @@ 
 #include "sysemu.h"
 #include "block.h"
 #include "qemu_socket.h"
+#include "block-migration.h"
 
 //#define DEBUG_MIGRATION
 
@@ -174,6 +175,14 @@  void do_info_migrate(Monitor *mon)
             monitor_printf(mon, "transferred ram: %" PRIu64 " kbytes\n", ram_bytes_transferred() >> 10);
             monitor_printf(mon, "remaining ram: %" PRIu64 " kbytes\n", ram_bytes_remaining() >> 10);
             monitor_printf(mon, "total ram: %" PRIu64 " kbytes\n", ram_bytes_total() >> 10);
+            if (blk_mig_active()) {
+                monitor_printf(mon, "transferred disk: %" PRIu64 " kbytes\n",
+                               blk_mig_bytes_transferred() >> 10);
+                monitor_printf(mon, "remaining disk: %" PRIu64 " kbytes\n",
+                               blk_mig_bytes_remaining() >> 10);
+                monitor_printf(mon, "total disk: %" PRIu64 " kbytes\n",
+                               blk_mig_bytes_total() >> 10);
+            }
             break;
         case MIG_STATE_COMPLETED:
             monitor_printf(mon, "completed\n");