qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.8] migration: Fix return code of ram_save_iterate()
@ 2016-11-04 13:10 Thomas Huth
  2016-11-08  1:14 ` David Gibson
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Thomas Huth @ 2016-11-04 13:10 UTC (permalink / raw)
  To: Juan Quintela, Amit Shah, qemu-devel, Dr. David Alan Gilbert; +Cc: David Gibson

qemu_savevm_state_iterate() expects the iterators to return 1
when they are done, and 0 if there is still something left to do.
However, ram_save_iterate() does not obey this rule and returns
the number of saved pages instead. This causes a fatal hang with
ppc64 guests when you run QEMU like this (also works with TCG):

 qemu-img create -f qcow2  /tmp/test.qcow2 1M
 qemu-system-ppc64 -nographic -nodefaults -m 256 \
                   -hda /tmp/test.qcow2 -serial mon:stdio

... then switch to the monitor by pressing CTRL-a c and try to
save a snapshot with "savevm test1" for example.

After the first iteration, ram_save_iterate() always returns 0 here,
so that qemu_savevm_state_iterate() hangs in an endless loop and you
can only "kill -9" the QEMU process.
Fix it by using proper return values in ram_save_iterate().

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 migration/ram.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index fb9252d..a1c8089 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1987,7 +1987,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
     int ret;
     int i;
     int64_t t0;
-    int pages_sent = 0;
+    int done = 0;
 
     rcu_read_lock();
     if (ram_list.version != last_version) {
@@ -2007,9 +2007,9 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
         pages = ram_find_and_save_block(f, false, &bytes_transferred);
         /* no more pages to sent */
         if (pages == 0) {
+            done = 1;
             break;
         }
-        pages_sent += pages;
         acct_info.iterations++;
 
         /* we want to check in the 1st loop, just in case it was the 1st time
@@ -2044,7 +2044,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
         return ret;
     }
 
-    return pages_sent;
+    return done;
 }
 
 /* Called with iothread lock */
-- 
1.8.3.1

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

end of thread, other threads:[~2016-12-19 20:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-04 13:10 [Qemu-devel] [PATCH for-2.8] migration: Fix return code of ram_save_iterate() Thomas Huth
2016-11-08  1:14 ` David Gibson
2016-11-08  6:57   ` Thomas Huth
2016-11-09  7:18 ` Amit Shah
2016-11-09  7:46   ` Thomas Huth
2016-11-09 13:08     ` David Gibson
2016-11-09 15:13     ` Dr. David Alan Gilbert
2016-11-09 15:28       ` Thomas Huth
2016-11-09 15:32         ` Dr. David Alan Gilbert
2016-11-14 18:34 ` Juan Quintela
2016-11-17  3:45   ` David Gibson
2016-11-18  8:13     ` Thomas Huth
2016-12-16 16:55       ` [Qemu-devel] Is block_save_iterate() dead code? (was: migration: Fix return code of ram_save_iterate() ) Thomas Huth
2016-12-16 17:03         ` Dr. David Alan Gilbert
2016-12-19 16:30           ` [Qemu-devel] Is block_save_iterate() dead code? Thomas Huth
2016-12-19 20:19             ` John Snow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).