Skip to contentSkip to conversation

augment info migrate with page status

PATCH In review Glauber Costa 3 participants 3 messages May 21, 2009 – May 24, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 augment info migrate with page status

This patch augments info migrate output with status about:
* ram bytes remaining
* ram bytes transferred
* ram bytes total

This should be enough for management tools to realize whether or not there is progress in migration. We can add more information later on, if the need arrives

---
 migration.c |    3 +++
 sysemu.h    |    4 ++++
 vl.c        |   21 ++++++++++++++++++++-
 3 files changed, 27 insertions(+), 1 deletions(-)
migration.c +3 -0
index b9e3368..a771f37 100644
@@ -116,6 +116,9 @@ void do_info_migrate(Monitor *mon)
         switch (s->get_status(s)) {
         case MIG_STATE_ACTIVE:
             monitor_printf(mon, "active\n");
+            monitor_printf(mon, "transferred ram: %lu kbytes\n", ram_bytes_transferred() >> 10);
+            monitor_printf(mon, "remaining ram: %lu kbytes\n", ram_bytes_remaining() >> 10);
+            monitor_printf(mon, "total ram: %lu kbytes\n", ram_bytes_total() >> 10);
             break;
         case MIG_STATE_COMPLETED:
             monitor_printf(mon, "completed\n");
sysemu.h +4 -0
index 7d65804..73f63df 100644
@@ -28,6 +28,10 @@ void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
 void vm_start(void);
 void vm_stop(int reason);
 
+unsigned long ram_bytes_remaining(void);
+unsigned long ram_bytes_transferred(void);
+unsigned long ram_bytes_total(void);
+
 int64_t cpu_get_ticks(void);
 void cpu_enable_ticks(void);
 void cpu_disable_ticks(void);
vl.c +20 -1
index d84ecef..74ad688 100644
@@ -3236,6 +3236,7 @@ static int ram_save_block(QEMUFile *f)
 }
 
 static ram_addr_t ram_save_threshold = 10;
+static ram_addr_t bytes_transferred = 0;
 
 static ram_addr_t ram_save_remaining(void)
 {
@@ -3250,6 +3251,21 @@ static ram_addr_t ram_save_remaining(void)
     return count;
 }
 
+unsigned long ram_bytes_remaining(void)
+{
+    return ram_save_remaining() * TARGET_PAGE_SIZE;
+}
+
+unsigned long ram_bytes_transferred(void)
+{
+    return bytes_transferred;
+}
+
+unsigned long ram_bytes_total(void)
+{
+    return last_ram_offset;
+}
+
 static int ram_save_live(QEMUFile *f, int stage, void *opaque)
 {
     ram_addr_t addr;
@@ -3271,6 +3287,7 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
         int ret;
 
         ret = ram_save_block(f);
+        bytes_transferred += ret * TARGET_PAGE_SIZE;
         if (ret == 0) /* no more blocks */
             break;
     }
@@ -3280,7 +3297,9 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
     if (stage == 3) {
 
         /* flush all remaining blocks regardless of rate limiting */
-        while (ram_save_block(f) != 0);
+        while (ram_save_block(f) != 0) {
+            bytes_transferred += TARGET_PAGE_SIZE;
+        }
         cpu_physical_memory_set_dirty_tracking(0);
     }
 
Signature · 1 line
1.5.6.6
#1 lore raw
Quoted 21 lines · Glauber Costa

This patch augments info migrate output with status about:
* ram bytes remaining
* ram bytes transferred
* ram bytes total

This should be enough for management tools to realize whether or not there is progress in migration. We can add more information later on, if the need arrives

---
 migration.c |    3 +++
 sysemu.h    |    4 ++++
 vl.c        |   21 ++++++++++++++++++++-
 3 files changed, 27 insertions(+), 1 deletions(-)
migration.c +0 -0
index b9e3368..a771f37 100644

migration.c void do_info_migrate(Monitor *mon) · line 122

Quoted 7 lines
migration.c +3 -0
@@ -116,6 +116,9 @@ void do_info_migrate(Monitor *mon)
         switch (s->get_status(s)) {
         case MIG_STATE_ACTIVE:
             monitor_printf(mon, "active\n");
+            monitor_printf(mon, "transferred ram: %lu kbytes\n", ram_bytes_transferred() >> 10);
+            monitor_printf(mon, "remaining ram: %lu kbytes\n", ram_bytes_remaining() >> 10);
+            monitor_printf(mon, "total ram: %lu kbytes\n", ram_bytes_total() >> 10);
 

ram_addr_t isn't %lu. It's 64-bit. There's a PRI macro somewhere for it...

Signature · 3 lines
Regards,

Anthony Liguori
#2 lore raw
Quoted 9 lines · Anthony Liguori
Quoted 7 lines

+ monitor_printf(mon, "transferred ram: %lu kbytes\n",
ram_bytes_transferred() >> 10);
+ monitor_printf(mon, "remaining ram: %lu kbytes\n",
ram_bytes_remaining() >> 10);
+ monitor_printf(mon, "total ram: %lu kbytes\n",
ram_bytes_total() >> 10);

ram_addr_t isn't %lu. It's 64-bit. There's a PRI macro somewhere for it...

It actually is a %lu. Unless kqemu is enabled. Looks like we need a PRI_ram_addr, or to drop C as the implementation language.

Signature · 1 line
error compiling committee.c: too many arguments to function