migration: Fix return code of ram_save_iterate()
PATCH 1/1 migration: Fix return code of ram_save_iterate()
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().
--- migration/ram.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
migration/ram.c +3 -3
@@ -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 */
Signature · 1 line
1.8.3.1
Quoted 13 lines · Thomas Huth
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.qcow21M 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.
Quoted 6 lines
After the first iteration,
ram_save_iterate()always returns 0 here, so thatqemu_savevm_state_iterate()hangs in an endless loop and you can only "kill -9" the QEMU process.
Fix it by using proper return values inram_save_iterate().Signed-off-by Thomas Huth <[email protected]>
Hmm. I think the change is technically correct, but I'm uneasy with this approach to the solution. The whole reason this wasn't caught earlier is that almost nothing looks at the return value. Without changing that I think it's very likely someone will mess this up again.
I think it would be preferable to change the return type to void to make it explicit that this function is not directly returning the "completion" status, but instead that's calculated from the other progress variables it updates.
Quoted 37 lines
--- migration/ram.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)migration/ram.c +3
-3@@ -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 */
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 27 lines · David Gibson
Quoted 13 lines · Thomas Huth
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.qcow21M 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.
Quoted 6 lines
After the first iteration,
ram_save_iterate()always returns 0 here, so thatqemu_savevm_state_iterate()hangs in an endless loop and you can only "kill -9" the QEMU process.
Fix it by using proper return values inram_save_iterate().Signed-off-by Thomas Huth <[email protected]>Hmm. I think the change is technically correct, but I'm uneasy with this approach to the solution. The whole reason this wasn't caught earlier is that almost nothing looks at the return value. Without changing that I think it's very likely someone will mess this up again.
Quoted 4 lines
I think it would be preferable to change the return type to void to make it explicit that this function is not directly returning the "completion" status, but instead that's calculated from the other progress variables it updates.
Not sure how such a patch should finally look like. Could you propose a patch?
Anyway, we're in soft freeze already ... do we still want such a major change of the logic at this point in time? If not, we should maybe go with fixing the return type only for 2.8, and do the major change for 2.9 instead?
Thomas
Quoted 5 lines · Thomas Huth
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):
"works with" -- does that mean reproduces with?
Quoted 42 lines
qemu-img create -f qcow2
/tmp/test.qcow21M 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 thatqemu_savevm_state_iterate()hangs in an endless loop and you can only "kill -9" the QEMU process.
Fix it by using proper return values inram_save_iterate().Signed-off-by Thomas Huth <[email protected]>--- migration/ram.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)migration/ram.c +2
-2@@ -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
migration/ram.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 2048
Quoted 6 lines
migration/ram.c +1
-1@@ -2044,7 +2044,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)return ret; } -return pages_sent; +return done; }
I agree with David, we can just remove the return value. The first patch of the series can do that; and this one could become the 2nd patch. Should be OK for the soft freeze.
Amit
Quoted 8 lines · Amit Shah
Quoted 5 lines · Thomas Huth
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):"works with" -- does that mean reproduces with?
Yes, that's what I've meant: You can reproduce it with TCG (e.g. running on a x86 system), too, there's no need for a real POWER machine with KVM here.
Quoted 45 lines
Quoted 45 lines
qemu-img create -f qcow2
/tmp/test.qcow21M 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 thatqemu_savevm_state_iterate()hangs in an endless loop and you can only "kill -9" the QEMU process.
Fix it by using proper return values inram_save_iterate().Signed-off-by Thomas Huth <[email protected]>--- migration/ram.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)migration/ram.c +2
-2@@ -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; }
Quoted 7 lines
migration/ram.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 2048
Quoted 3 lines
migration/ram.c +1
-1-return pages_sent; +return done; }I agree with David, we can just remove the return value. The first patch of the series can do that; and this one could become the 2nd patch. Should be OK for the soft freeze.
Sorry, I still did not quite get it - if I'd change the return type of ram_save_iterate() and the other iterate functions to "void", how is qemu_savevm_state_iterate() supposed to know whether all iterators are done or not? And other iterators also use negative return values to signal errors - should that then be handled via an "Error **" parameter instead? ... my gut feeling still says that such a bigger rework (we've got to touch all iterators for this!) should rather not be done right in the middle of the freeze period...
Thomas
Quoted 8 lines · * Thomas Huth ([email protected]) wrote:
Quoted 7 lines · Amit Shah
Quoted 5 lines · Thomas Huth
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):
Quoted 5 lines
Quoted 1 line
"works with" -- does that mean reproduces with?
Yes, that's what I've meant: You can reproduce it with TCG (e.g. running on a x86 system), too, there's no need for a real POWER machine with KVM here.
How did you trigger it on x86?
Dave
Quoted 62 lines
Quoted 45 lines
Quoted 45 lines
qemu-img create -f qcow2
/tmp/test.qcow21M 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 thatqemu_savevm_state_iterate()hangs in an endless loop and you can only "kill -9" the QEMU process.
Fix it by using proper return values inram_save_iterate().Signed-off-by Thomas Huth <[email protected]>--- migration/ram.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)migration/ram.c +2
-2@@ -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; }Quoted 7 lines
migration/ram.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 2048
Quoted 3 lines
migration/ram.c +1
-1-return pages_sent; +return done; }I agree with David, we can just remove the return value. The first patch of the series can do that; and this one could become the 2nd patch. Should be OK for the soft freeze.
Sorry, I still did not quite get it - if I'd change the return type of
ram_save_iterate()and the other iterate functions to "void", how isqemu_savevm_state_iterate()supposed to know whether all iterators are done or not? And other iterators also use negative return values to signal errors - should that then be handled via an "Error **" parameter instead? ... my gut feeling still says that such a bigger rework (we've got to touch all iterators for this!) should rather not be done right in the middle of the freeze period...
Quoted 2 lines
Thomas
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 9 lines · Dr. David Alan Gilbert
Quoted 8 lines · * Thomas Huth ([email protected]) wrote:
Quoted 7 lines · Amit Shah
Quoted 5 lines · Thomas Huth
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):
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
"works with" -- does that mean reproduces with?
Yes, that's what I've meant: You can reproduce it with TCG (e.g. running on a x86 system), too, there's no need for a real POWER machine with KVM here.
How did you trigger it on x86?
As described below - qemu-img + qemu-system-ppc64 + savevm is enough to trigger it on a x86 host.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
qemu-img create -f qcow2
/tmp/test.qcow21M 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.
Thomas
Quoted 12 lines · * Thomas Huth ([email protected]) wrote:
Quoted 11 lines · Dr. David Alan Gilbert
Quoted 10 lines · * Thomas Huth ([email protected]) wrote:
Quoted 8 lines · Amit Shah
Quoted 5 lines · Thomas Huth
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):"works with" -- does that mean reproduces with?
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Yes, that's what I've meant: You can reproduce it with TCG (e.g. running on a x86 system), too, there's no need for a real POWER machine with KVM here.
How did you trigger it on x86?
As described below - qemu-img + qemu-system-ppc64 + savevm is enough to trigger it on a x86 host.
Oh OK; so yes still ppc64 target.
Dave
Quoted 10 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
qemu-img create -f qcow2
/tmp/test.qcow21M 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.
Thomas
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 67 lines · Thomas Huth
Quoted 8 lines · Amit Shah
Quoted 5 lines · Thomas Huth
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):"works with" -- does that mean reproduces with?
Yes, that's what I've meant: You can reproduce it with TCG (e.g. running on a x86 system), too, there's no need for a real POWER machine with KVM here.
Quoted 45 lines
Quoted 45 lines
qemu-img create -f qcow2
/tmp/test.qcow21M 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 thatqemu_savevm_state_iterate()hangs in an endless loop and you can only "kill -9" the QEMU process.
Fix it by using proper return values inram_save_iterate().Signed-off-by Thomas Huth <[email protected]>--- migration/ram.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)migration/ram.c +2
-2@@ -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; }Quoted 7 lines
migration/ram.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 2048
Quoted 3 lines
migration/ram.c +1
-1-return pages_sent; +return done; }I agree with David, we can just remove the return value. The first patch of the series can do that; and this one could become the 2nd patch. Should be OK for the soft freeze.
Quoted 4 lines
Sorry, I still did not quite get it - if I'd change the return type of
ram_save_iterate()and the other iterate functions to "void", how isqemu_savevm_state_iterate()supposed to know whether all iterators are done or not?
It doesn't - it's return value is, in turn, mostly ignored by the caller.
On the migration path we already determine whether to proceed or not based purely on the separate state_pending callbacks.
For the savevm path, we don't really need the iteration phase at all - we can jump straight to the completion phase, since downtime is not an issue.
Quoted 2 lines
And other iterators also use negative return values to signal errors
Ah.. that's a good point. Possibly we should leave in the negative codes for errors and just remove all positive return values.
Quoted 4 lines
- should that then be handled via an "Error **" parameter instead? ... my gut feeling still says that such a bigger rework (we've got to touch all iterators for this!) should rather not be done right in the middle of the freeze period...
Yeah the errors could - and probably should - be handled with Error ** instead of return codes, but I also wonder if that's too much for soft freeze. I guess that's the call of the migration guys.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 13 lines · Thomas Huth
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.qcow21M 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.
Quoted 6 lines
After the first iteration,
ram_save_iterate()always returns 0 here, so thatqemu_savevm_state_iterate()hangs in an endless loop and you can only "kill -9" the QEMU process.
Fix it by using proper return values inram_save_iterate().Signed-off-by Thomas Huth <[email protected]>
Applied.
I don't know how we broked this so much.
Thanks, Juan.
Quoted 19 lines · Juan Quintela
Quoted 18 lines · Thomas Huth
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.qcow21M 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 thatqemu_savevm_state_iterate()hangs in an endless loop and you can only "kill -9" the QEMU process.
Fix it by using proper return values inram_save_iterate().
Quoted 7 lines
Quoted 1 line
Signed-off-by Thomas Huth <[email protected]>Reviewed-by Juan Quintela <[email protected]>Applied.
I don't know how we broked this so much.
Note that block save iterate has the same bug...
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 22 lines · David Gibson
Quoted 21 lines · Juan Quintela
Quoted 19 lines · Thomas Huth
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.qcow21M 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 thatqemu_savevm_state_iterate()hangs in an endless loop and you can only "kill -9" the QEMU process.
Fix it by using proper return values inram_save_iterate().Signed-off-by Thomas Huth <[email protected]>
Quoted 7 lines
Quoted 5 lines
Reviewed-by Juan Quintela <[email protected]>Applied.
I don't know how we broked this so much.
Note that block save iterate has the same bug...
I think you're right. Care to send a patch?
Thomas
[Qemu-devel] Is block_save_iterate() dead code? (was: migration: Fix return code of ram_save_iterate() )
Quoted 25 lines · Thomas Huth
Quoted 24 lines · David Gibson
Quoted 23 lines · Juan Quintela
Quoted 13 lines · Thomas Huth
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.qcow21M 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.
Quoted 6 lines
After the first iteration,
ram_save_iterate()always returns 0 here, so thatqemu_savevm_state_iterate()hangs in an endless loop and you can only "kill -9" the QEMU process.
Fix it by using proper return values inram_save_iterate().Signed-off-by Thomas Huth <[email protected]>Reviewed-by Juan Quintela <[email protected]>
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Applied.
I don't know how we broked this so much.
Note that block save iterate has the same bug...
I think you're right. Care to send a patch?
Looking at this issue again ... could it be that block_save_iterate() is currently just dead code?
As far as I can see, the ->save_live_iterate() handlers are only called from qemu_savevm_state_iterate(), right? And qemu_savevm_state_iterate() only calls the handlers if se->ops->is_active(se->opaque) returns true. But block_is_active() seems to only return 0 during savevm, most likely because qemu_savevm_state() explicitly sets the "blk" and "shared" MigrationParams to zero.
So to me, it looks like we could also just remove block_save_iterate() completely ... or did I miss something here?
Thomas
Re: [Qemu-devel] Is block_save_iterate() dead code? (was: migration: Fix return code of ram_save_iterate() )
Quoted 34 lines · * Thomas Huth ([email protected]) wrote:
Quoted 25 lines · Thomas Huth
Quoted 24 lines · David Gibson
Quoted 23 lines · Juan Quintela
Quoted 13 lines · Thomas Huth
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.qcow21M 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.
Quoted 6 lines
After the first iteration,
ram_save_iterate()always returns 0 here, so thatqemu_savevm_state_iterate()hangs in an endless loop and you can only "kill -9" the QEMU process.
Fix it by using proper return values inram_save_iterate().Signed-off-by Thomas Huth <[email protected]>Reviewed-by Juan Quintela <[email protected]>Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Applied.
I don't know how we broked this so much.
Note that block save iterate has the same bug...
I think you're right. Care to send a patch?
Quoted 10 lines
Looking at this issue again ... could it be that
block_save_iterate()is currently just dead code?
As far as I can see, the ->save_live_iterate() handlers are only called fromqemu_savevm_state_iterate(), right? Andqemu_savevm_state_iterate()only calls the handlers ifse->ops->is_active(se->opaque)returns true. Butblock_is_active()seems to only return 0 during savevm, most likely becauseqemu_savevm_state()explicitly sets the "blk" and "shared" MigrationParams to zero.
So to me, it looks like we could also just removeblock_save_iterate()completely ... or did I miss something here?
Doesn't it get called by migrate -b ?
Dave
Quoted 3 lines
Thomas
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [Qemu-devel] Is block_save_iterate() dead code?
Quoted 46 lines · Dr. David Alan Gilbert
Quoted 34 lines · * Thomas Huth ([email protected]) wrote:
Quoted 25 lines · Thomas Huth
Quoted 24 lines · David Gibson
Quoted 23 lines · Juan Quintela
Quoted 13 lines · Thomas Huth
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.qcow21M 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.
Quoted 6 lines
After the first iteration,
ram_save_iterate()always returns 0 here, so thatqemu_savevm_state_iterate()hangs in an endless loop and you can only "kill -9" the QEMU process.
Fix it by using proper return values inram_save_iterate().Signed-off-by Thomas Huth <[email protected]>Reviewed-by Juan Quintela <[email protected]>Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Applied.
I don't know how we broked this so much.
Note that block save iterate has the same bug...
I think you're right. Care to send a patch?
Quoted 10 lines
Looking at this issue again ... could it be that
block_save_iterate()is currently just dead code?
As far as I can see, the ->save_live_iterate() handlers are only called fromqemu_savevm_state_iterate(), right? Andqemu_savevm_state_iterate()only calls the handlers ifse->ops->is_active(se->opaque)returns true. Butblock_is_active()seems to only return 0 during savevm, most likely becauseqemu_savevm_state()explicitly sets the "blk" and "shared" MigrationParams to zero.
So to me, it looks like we could also just removeblock_save_iterate()completely ... or did I miss something here?
Quoted 1 line
Doesn't it get called by migrate -b ?
Ah, right, yes, I somehow missed that ... I probably shouldn't do such experiments at the end of Friday afternoon ;-)
OK, so it seems that
- block_save_iterate() is not called during savevm at all (and thus the bad return code does not matter here)
- migrate -b runs block_save_iterate() but the return code is ignored in migration_thread()
So we do not have a real problem here, but I think we should still clean up the return code of block_save_iterate() to be on the safe side for the future...
Thomas
Re: [Qemu-devel] Is block_save_iterate() dead code?
Quoted 58 lines · Thomas Huth
Quoted 46 lines · Dr. David Alan Gilbert
Quoted 34 lines · * Thomas Huth ([email protected]) wrote:
Quoted 25 lines · Thomas Huth
Quoted 24 lines · David Gibson
Quoted 23 lines · Juan Quintela
Quoted 13 lines · Thomas Huth
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.qcow21M 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.
Quoted 6 lines
After the first iteration,
ram_save_iterate()always returns 0 here, so thatqemu_savevm_state_iterate()hangs in an endless loop and you can only "kill -9" the QEMU process.
Fix it by using proper return values inram_save_iterate().Signed-off-by Thomas Huth <[email protected]>Reviewed-by Juan Quintela <[email protected]>Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Applied.
I don't know how we broked this so much.
Note that block save iterate has the same bug...
I think you're right. Care to send a patch?
Quoted 10 lines
Looking at this issue again ... could it be that
block_save_iterate()is currently just dead code?
As far as I can see, the ->save_live_iterate() handlers are only called fromqemu_savevm_state_iterate(), right? Andqemu_savevm_state_iterate()only calls the handlers ifse->ops->is_active(se->opaque)returns true. Butblock_is_active()seems to only return 0 during savevm, most likely becauseqemu_savevm_state()explicitly sets the "blk" and "shared" MigrationParams to zero.
So to me, it looks like we could also just removeblock_save_iterate()completely ... or did I miss something here?Quoted 1 line
Doesn't it get called by migrate -b ?
Ah, right, yes, I somehow missed that ... I probably shouldn't do such experiments at the end of Friday afternoon ;-)
OK, so it seems that
-block_save_iterate()is not called during savevm at all (and thus the bad return code does not matter here)
- migrate -b runsblock_save_iterate()but the return code is ignored inmigration_thread()
Quoted 7 lines
So we do not have a real problem here, but I think we should still clean up the return code of
block_save_iterate()to be on the safe side for the future...Thomas
If it confused you, it'll confuse someone else. Worth fixing for consistency's sake alone.
--js