Commit 9f9e28cda74bc8cddd8ac4c0a9c007b31d42c6f6

Authored by Glauber Costa
Committed by Anthony Liguori
1 parent ed8b330b

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

[v2: fixes bytes_transferred type]

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing 3 changed files with 27 additions and 1 deletions
migration.c
... ... @@ -109,6 +109,9 @@ void do_info_migrate(Monitor *mon)
109 109 switch (s->get_status(s)) {
110 110 case MIG_STATE_ACTIVE:
111 111 monitor_printf(mon, "active\n");
  112 + monitor_printf(mon, "transferred ram: %" PRIu64 " kbytes\n", ram_bytes_transferred() >> 10);
  113 + monitor_printf(mon, "remaining ram: %" PRIu64 " kbytes\n", ram_bytes_remaining() >> 10);
  114 + monitor_printf(mon, "total ram: %" PRIu64 " kbytes\n", ram_bytes_total() >> 10);
112 115 break;
113 116 case MIG_STATE_COMPLETED:
114 117 monitor_printf(mon, "completed\n");
... ...
sysemu.h
... ... @@ -28,6 +28,10 @@ void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
28 28 void vm_start(void);
29 29 void vm_stop(int reason);
30 30  
  31 +uint64_t ram_bytes_remaining(void);
  32 +uint64_t ram_bytes_transferred(void);
  33 +uint64_t ram_bytes_total(void);
  34 +
31 35 int64_t cpu_get_ticks(void);
32 36 void cpu_enable_ticks(void);
33 37 void cpu_disable_ticks(void);
... ...
... ... @@ -3234,6 +3234,7 @@ static int ram_save_block(QEMUFile *f)
3234 3234 }
3235 3235  
3236 3236 static ram_addr_t ram_save_threshold = 10;
  3237 +static uint64_t bytes_transferred = 0;
3237 3238  
3238 3239 static ram_addr_t ram_save_remaining(void)
3239 3240 {
... ... @@ -3248,6 +3249,21 @@ static ram_addr_t ram_save_remaining(void)
3248 3249 return count;
3249 3250 }
3250 3251  
  3252 +uint64_t ram_bytes_remaining(void)
  3253 +{
  3254 + return ram_save_remaining() * TARGET_PAGE_SIZE;
  3255 +}
  3256 +
  3257 +uint64_t ram_bytes_transferred(void)
  3258 +{
  3259 + return bytes_transferred;
  3260 +}
  3261 +
  3262 +uint64_t ram_bytes_total(void)
  3263 +{
  3264 + return last_ram_offset;
  3265 +}
  3266 +
3251 3267 static int ram_save_live(QEMUFile *f, int stage, void *opaque)
3252 3268 {
3253 3269 ram_addr_t addr;
... ... @@ -3269,6 +3285,7 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
3269 3285 int ret;
3270 3286  
3271 3287 ret = ram_save_block(f);
  3288 + bytes_transferred += ret * TARGET_PAGE_SIZE;
3272 3289 if (ret == 0) /* no more blocks */
3273 3290 break;
3274 3291 }
... ... @@ -3278,7 +3295,9 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
3278 3295 if (stage == 3) {
3279 3296  
3280 3297 /* flush all remaining blocks regardless of rate limiting */
3281   - while (ram_save_block(f) != 0);
  3298 + while (ram_save_block(f) != 0) {
  3299 + bytes_transferred += TARGET_PAGE_SIZE;
  3300 + }
3282 3301 cpu_physical_memory_set_dirty_tracking(0);
3283 3302 }
3284 3303  
... ...