Migration fix
v2 cover Migration fix
This small patch series is extracted from localhost migration series that Paolo reviewed positively, send it separately as his request.
It fixs wrong initialization in RDMA hook ram_control_load_hook() and gets rid of the negative check for qemu_file_rate_limit() with bytes_transferred and return value adjusted correspondingly in ram_save_iterate.
Lei Li (3):
savevm: add comments for qemu_file_get_error()
savevm: fix wrong initialization by ram_control_load_hook
arch_init: right return for ram_save_iterate
arch_init.c | 15 ++++++++++----- savevm.c | 9 ++++++++- 2 files changed, 18 insertions(+), 6 deletions(-)
PATCH RESEND v2 1/3 savevm: add comments for qemu_file_get_error()
Add comments for qemu_file_get_error(), as its return value is not very clear.
--- savevm.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
savevm.c +7 -0
@@ -566,6 +566,13 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)return f; } +/* +* Get last error for stream f +* +* Return negative error value if there has been an error on previous +* operations, return 0 if no error happened. +* +*/ int qemu_file_get_error (QEMUFile *f) {return f->last_error;
Signature · 1 line
1.7.7.6
Re: [Qemu-devel] [PATCH 1/3 resend v2] savevm: add comments for qemu_file_get_error()
Quoted 4 lines · Lei Li
Add comments for
qemu_file_get_error(), as its return value is not very clear.Signed-off-by Lei Li <[email protected]>
PATCH RESEND v2 2/3 savevm: fix wrong initialization by ram_control_load_hook
In reply to Lei LiIt should set negative error value rather than 0 in QEMUFile if there has been an error.
---
Change since v1:
Initialize ret to -EINVAL rather than -1 from Paolo Bonzini.
savevm.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
savevm.c +1 -1
@@ -649,7 +649,7 @@ void ram_control_after_iterate(QEMUFile *f, uint64_t flags)void ram_control_load_hook (QEMUFile *f,uint64_t flags) { -int ret =0 ; +int ret = -EINVAL ;if (f->ops->hook_ram_load) { ret = f->ops->hook_ram_load (f, f->opaque, flags);
Signature · 1 line
1.7.7.6
PATCH RESEND v2 3/3 arch_init: right return for ram_save_iterate
In reply to Lei Liqemu_file_rate_limit() never return negative value since the refactor by Commit 1964a39, this patch gets rid of the negative check for it, adjust bytes_transferred and return value correspondingly in ram_save_iterate().
---
Change since v1:
Return fixes and improvement from Paolo Bonzini.
arch_init.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)
arch_init.c +10 -5
@@ -709,15 +709,20 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)*/ ram_control_after_iterate (f,RAM_CONTROL_ROUND ); + bytes_transferred += total_sent; + +/* +* Do not count these 8 bytes into total_sent, so that we can +* return 0 if no page had been dirtied. +*/ +qemu_put_be64 (f,RAM_SAVE_FLAG_EOS ); + bytes_transferred +=8 ; + + ret =qemu_file_get_error (f);if (ret <0 ) { - bytes_transferred += total_sent;return ret; } -qemu_put_be64 (f,RAM_SAVE_FLAG_EOS ); - total_sent +=8 ; - bytes_transferred += total_sent; -return total_sent; }
Signature · 1 line
1.7.7.6
Re: [Qemu-devel] [PATCH 3/3 resend v2] arch_init: right return for ram_save_iterate
Quoted 20 lines · Lei Li
qemu_file_rate_limit()never return negative value since the refactor by Commit 1964a39, this patch gets rid of the negative check for it, adjustbytes_transferredand return value correspondingly inram_save_iterate().Signed-off-by Lei Li <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>---
Change since v1:
Return fixes and improvement from Paolo Bonzini.arch_init.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)arch_init.c +0
-0
arch_init.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 712
Quoted 4 lines
arch_init.c +1
-0@@ -709,15 +709,20 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)*/ ram_control_after_iterate (f,RAM_CONTROL_ROUND ); + bytes_transferred += total_sent;
Agreed.
arch_init.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 722
Quoted 10 lines
arch_init.c +9
-0+ +/* +* Do not count these 8 bytes into total_sent, so that we can +* return 0 if no page had been dirtied. +*/ +qemu_put_be64 (f,RAM_SAVE_FLAG_EOS ); + bytes_transferred +=8 ; + + ret =qemu_file_get_error (f);if (ret <0 ) {
Not sure this is the right solution.
We are sending anyways RAM_SAVE_FLAG_EOS.
And I think that the right solution is make qemu_get_rate_limit() to return -1 in case of error (or the error, I don't care). Looking at the callers:
migration.c::migration_thread()
we check for error when we qemu_file_rate_limit() returns != 0. Well.
second call:
if (qemu_file_rate_limit(s->file)) {
/* usleep expects microseconds */
g_usleep((initial_time + BUFFER_DELAY - current_time)*1000);
}if should be:
if (qemu_file_rate_limit(s->file) == 1)
block_migration: not correct, we don't check for the error.
arch_init.c:
check is correct, but we need to return -ERROR in case of errors.
hw/ppc/spapr.c:
will work correctly even if changed to -ERROR.
savevm.c: qemu_savevm_state_iterate()
if (qemu_file_rate_limit(f)) {
return 0;
}check is incorrect again, we should return an error if there is one error.
I think that returning qemu_rate_limit() to return 0/1/negative makes sense.
Thoughts?
Thanks, Juan.
Re: [Qemu-devel] [PATCH 3/3 resend v2] arch_init: right return for ram_save_iterate
Il 11/09/2013 11:17, Juan Quintela ha scritto:
Quoted 41 lines
Quoted 20 lines · Lei Li
qemu_file_rate_limit()never return negative value since the refactor by Commit 1964a39, this patch gets rid of the negative check for it, adjustbytes_transferredand return value correspondingly inram_save_iterate().Signed-off-by Lei Li <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>---
Change since v1:
Return fixes and improvement from Paolo Bonzini.arch_init.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)arch_init.c +0
-0arch_init.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 712
Quoted 4 lines
arch_init.c +1
-0@@ -709,15 +709,20 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)*/ ram_control_after_iterate (f,RAM_CONTROL_ROUND ); + bytes_transferred += total_sent;Agreed.
arch_init.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 722
Quoted 10 lines
arch_init.c +9
-0+ +/* +* Do not count these 8 bytes into total_sent, so that we can +* return 0 if no page had been dirtied. +*/ +qemu_put_be64 (f,RAM_SAVE_FLAG_EOS ); + bytes_transferred +=8 ; + + ret =qemu_file_get_error (f);if (ret <0 ) {Not sure this is the right solution.
Quoted 1 line
We are sending anyways
RAM_SAVE_FLAG_EOS.
If there is an error, the qemu_put_be64 will do nothing. It is part of the design of QEMUFile that you can keep sending stuff to it after an error happened.
Quoted 2 lines
And I think that the right solution is make
qemu_get_rate_limit()to return -1 in case of error (or the error, I don't care).
You might do both things, it would avoid the useless g_usleep you pointed out below. But Lei's patch is good, because an error could happen exactly during the qemu_put_be64 that writes RAM_SAVE_FLAG_EOS.
Quoted 8 lines
savevm.c:qemu_savevm_state_iterate()if (qemu_file_rate_limit(f)) { return 0; }check is incorrect again, we should return an error if there is one error.
Nothing cares if qemu_savevm_state_iterate returns 0 or negative, so changing qemu_savevm_state_iterate to only return 0/1 would make sense too.
Paolo
Quoted 7 lines
I think that returning
qemu_rate_limit()to return 0/1/negative makes sense.Thoughts?
Thanks, Juan.
Re: [Qemu-devel] [PATCH 3/3 resend v2] arch_init: right return for ram_save_iterate
Quoted 48 lines · Paolo Bonzini
Il 11/09/2013 11:17, Juan Quintela ha scritto:
Quoted 41 lines
Quoted 20 lines · Lei Li
qemu_file_rate_limit()never return negative value since the refactor by Commit 1964a39, this patch gets rid of the negative check for it, adjustbytes_transferredand return value correspondingly inram_save_iterate().Signed-off-by Lei Li <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>---
Change since v1:
Return fixes and improvement from Paolo Bonzini.arch_init.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)arch_init.c +0
-0arch_init.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 712
Quoted 4 lines
arch_init.c +1
-0@@ -709,15 +709,20 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)*/ ram_control_after_iterate (f,RAM_CONTROL_ROUND ); + bytes_transferred += total_sent;Agreed.
arch_init.c static int ram_save_iterate(QEMUFile *f, void *opaque) · line 722
Quoted 10 lines
arch_init.c +9
-0+ +/* +* Do not count these 8 bytes into total_sent, so that we can +* return 0 if no page had been dirtied. +*/ +qemu_put_be64 (f,RAM_SAVE_FLAG_EOS ); + bytes_transferred +=8 ; + + ret =qemu_file_get_error (f);if (ret <0 ) {Not sure this is the right solution.
Quoted 1 line
We are sending anyways
RAM_SAVE_FLAG_EOS.If there is an error, the
qemu_put_be64will do nothing. It is part of the design of QEMUFile that you can keep sending stuff to it after an error happened.
Quoted 6 lines
Quoted 2 lines
And I think that the right solution is make
qemu_get_rate_limit()to return -1 in case of error (or the error, I don't care).You might do both things, it would avoid the useless
g_usleepyou pointed out below. But Lei's patch is good, because an error could happen exactly during theqemu_put_be64that writesRAM_SAVE_FLAG_EOS.
Caller checks also. This is the reason I wanted qemu_file_* callos to return an error. It has some advantages and some disadvantages. We don't agree on which ones are bigger O:-)
Quoted 7 lines
Quoted 7 lines
savevm.c:qemu_savevm_state_iterate()if (qemu_file_rate_limit(f)) { return 0; }
Quoted 5 lines
Quoted 2 lines
check is incorrect again, we should return an error if there is one error.
Nothing cares if
qemu_savevm_state_iteratereturns 0 or negative, so changingqemu_savevm_state_iterateto only return 0/1 would make sense too.
In this case, 0 means:
please, call us again
when what we mean is:
don't care about calling us again, there is an error. Handle the error.
Notice that qemu_save_iterate() already returns errors in other code paths, not there because it don't know, code should be:
ret = qemu_file_rate_limit(f))
if (ret == 1) {
return 0;
} else if (ret < 0) {
return ret;
}
If we change th ereturn value for qemu_file_rate_limit() the change that cames with this patch is not needed, that was my point.
Quoted 11 lines
Paolo
Quoted 7 lines
I think that returning
qemu_rate_limit()to return 0/1/negative makes sense.Thoughts?
Thanks, Juan.
Re: [Qemu-devel] [PATCH 3/3 resend v2] arch_init: right return for ram_save_iterate
Il 11/09/2013 13:06, Juan Quintela ha scritto:
Quoted 10 lines
Quoted 6 lines
Quoted 2 lines
And I think that the right solution is make
qemu_get_rate_limit()to return -1 in case of error (or the error, I don't care).You might do both things, it would avoid the useless
g_usleepyou pointed out below. But Lei's patch is good, because an error could happen exactly during theqemu_put_be64that writesRAM_SAVE_FLAG_EOS.Caller checks also. This is the reason I wanted qemu_file_* callers to return an error. It has some advantages and some disadvantages. We don't agree on which ones are bigger O:-)
I think the disadvantages are bigger. It litters the code with error handling, hides where things actually happen, and doesn't even simplify QEMUFile itself. Checking only at the toplevel is simpler, all we need to do is ensure that we get there every now and then (and that's what qemu_file_rate_limit does).
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
savevm.c:qemu_savevm_state_iterate()if (qemu_file_rate_limit(f)) { return 0; }check is incorrect again, we should return an error if there is one error.
Quoted 7 lines
Quoted 2 lines
Nothing cares if
qemu_savevm_state_iteratereturns 0 or negative, so changingqemu_savevm_state_iterateto only return 0/1 would make sense too.In this case, 0 means:
please, call us again
when what we mean is:
don't care about calling us again, there is an error. Handle the error.
Or alternatively, 0 means:
we haven't finished the work
when what we mean is:
we haven't finished the work (BTW, please check if there is an error)
Quoted 2 lines
Notice that
qemu_save_iterate()already returns errors in other code paths
Yes that's also unnecessary.
Quoted 2 lines
If we change th ereturn value for
qemu_file_rate_limit()the change that cames with this patch is not needed, that was my point.
This is what an earlier patch from Lei did. I told him (or her?) to leave qemu_file_rate_limit aside since the idea behind QEMUFile is to only handle the error at the top.
Paolo
Re: [Qemu-devel] [PATCH 3/3 resend v2] arch_init: right return for ram_save_iterate
Quoted 37 lines · Paolo Bonzini
Il 11/09/2013 13:06, Juan Quintela ha scritto:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
And I think that the right solution is make
qemu_get_rate_limit()to return -1 in case of error (or the error, I don't care).You might do both things, it would avoid the useless
g_usleepyou pointed out below. But Lei's patch is good, because an error could happen exactly during theqemu_put_be64that writesRAM_SAVE_FLAG_EOS.Caller checks also. This is the reason I wanted qemu_file_* callers to return an error. It has some advantages and some disadvantages. We don't agree on which ones are bigger O:-)
I think the disadvantages are bigger. It litters the code with error handling, hides where things actually happen, and doesn't even simplify QEMUFile itself. Checking only at the toplevel is simpler, all we need to do is ensure that we get there every now and then (and that's what
qemu_file_rate_limitdoes).Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
savevm.c:qemu_savevm_state_iterate()if (qemu_file_rate_limit(f)) { return 0; }Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
check is incorrect again, we should return an error if there is one error.
Nothing cares if
qemu_savevm_state_iteratereturns 0 or negative, so changingqemu_savevm_state_iterateto only return 0/1 would make sense too.In this case, 0 means:
please, call us again
when what we mean is:
don't care about calling us again, there is an error. Handle the error.Or alternatively, 0 means:
we haven't finished the work
when what we mean is:
we haven't finished the work (BTW, please check if there is an error)
Quoted 7 lines
Quoted 2 lines
Notice that
qemu_save_iterate()already returns errors in other code pathsYes that's also unnecessary.
Quoted 2 lines
If we change th ereturn value for
qemu_file_rate_limit()the change that cames with this patch is not needed, that was my point.This is what an earlier patch from Lei did. I told him (or her?) to
It's her. :)
Quoted 2 lines
leave
qemu_file_rate_limitaside since the idea behind QEMUFile is to only handle the error at the top.
Yes, I changed the return value for qemu_file_rate_limit() to negative for that if there has been an error at the beginning. After the discussion with Paolo, I think he's suggestion based on the idea that only handle error at the top behind QEMUFile makes sense to me, so that's where this patch come from.
Quoted 3 lines
Paolo
Signature · 1 line
Lei
Re: [Qemu-devel] [PATCH 3/3 resend v2] arch_init: right return for ram_save_iterate
In reply to Paolo BonziniQuoted 12 lines · Paolo Bonzini
Il 11/09/2013 13:06, Juan Quintela ha scritto:
Quoted 10 lines
Quoted 6 lines
Quoted 2 lines
And I think that the right solution is make
qemu_get_rate_limit()to return -1 in case of error (or the error, I don't care).You might do both things, it would avoid the useless
g_usleepyou pointed out below. But Lei's patch is good, because an error could happen exactly during theqemu_put_be64that writesRAM_SAVE_FLAG_EOS.Caller checks also. This is the reason I wanted qemu_file_* callers to return an error. It has some advantages and some disadvantages. We don't agree on which ones are bigger O:-)
Quoted 6 lines
I think the disadvantages are bigger. It litters the code with error handling, hides where things actually happen, and doesn't even simplify QEMUFile itself. Checking only at the toplevel is simpler, all we need to do is ensure that we get there every now and then (and that's what
qemu_file_rate_limitdoes).
I also prefer the error checking at the top level.
Orit
Quoted 39 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
savevm.c:qemu_savevm_state_iterate()if (qemu_file_rate_limit(f)) { return 0; }check is incorrect again, we should return an error if there is one error.
Quoted 7 lines
Quoted 2 lines
Nothing cares if
qemu_savevm_state_iteratereturns 0 or negative, so changingqemu_savevm_state_iterateto only return 0/1 would make sense too.In this case, 0 means:
please, call us again
when what we mean is:
don't care about calling us again, there is an error. Handle the error.Or alternatively, 0 means:
we haven't finished the work
when what we mean is:
we haven't finished the work (BTW, please check if there is an error)
Quoted 2 lines
Notice that
qemu_save_iterate()already returns errors in other code pathsYes that's also unnecessary.
Quoted 2 lines
If we change th ereturn value for
qemu_file_rate_limit()the change that cames with this patch is not needed, that was my point.This is what an earlier patch from Lei did. I told him (or her?) to leave
qemu_file_rate_limitaside since the idea behind QEMUFile is to only handle the error at the top.Paolo
Quoted 10 lines · Lei Li
This small patch series is extracted from localhost migration series that Paolo reviewed positively, send it separately as his request.
It fixs wrong initialization in RDMA hook
ram_control_load_hook()and gets rid of the negative check forqemu_file_rate_limit()withbytes_transferredand return value adjusted correspondingly inram_save_iterate.
Quoted 10 lines
Lei Li (3):
savevm: add comments forqemu_file_get_error()
savevm: fix wrong initialization byram_control_load_hook
arch_init: right return forram_save_iteratearch_init.c | 15 ++++++++++----- savevm.c | 9 ++++++++- 2 files changed, 18 insertions(+), 6 deletions(-)
Looks good,