]> git.proxmox.com Git - mirror_qemu.git/commitdiff
migration: Guard ram_bytes_remaining against early call
authorDr. David Alan Gilbert <dgilbert@redhat.com>
Fri, 15 Dec 2017 11:51:23 +0000 (11:51 +0000)
committerJuan Quintela <quintela@redhat.com>
Mon, 15 Jan 2018 11:48:04 +0000 (12:48 +0100)
Calling ram_bytes_remaining during the early part of setup is unsafe
because the ram_state isn't yet initialised.

This can happen in the sequence:
   migrate
   migrate_cancel
   info migrate

if the migrate sticks trying to connect (e.g. to an unresponsive
destination due to the connect timeout).  Here 'info migrate' sees
a state of CANCELLING and so assumes the migrate has partially happened.

partial fix for:
RH bz: https://bugzilla.redhat.com/show_bug.cgi?id=1525899
Reported-by: Xianxian Wang <xianwang@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
migration/ram.c

index 021d583b9bdf89882eea9341c54a6fef6668ec3b..cb1950f3eb9b804d29011e1c18793ce802a0a870 100644 (file)
@@ -237,7 +237,8 @@ static RAMState *ram_state;
 
 uint64_t ram_bytes_remaining(void)
 {
-    return ram_state->migration_dirty_pages * TARGET_PAGE_SIZE;
+    return ram_state ? (ram_state->migration_dirty_pages * TARGET_PAGE_SIZE) :
+                       0;
 }
 
 MigrationStats ram_counters;