savevm: set right return value for qemu_file_rate_limit
PATCH 1/1 savevm: set right return value for qemu_file_rate_limit
Commit 1964a397063967acc5ce71a2a24ed26e74824ee1 refactors rate limiting to QEMUFile, but set the return value for qemu_file_rate_limit to 1 in the case of qemu_file_get_error. It is wrong and should be negative compared to the original function buffered_rate_limit and the current logic in ram_save_iterate. As qemu_file_rate_limit is called manually to determine if it has to exit, add the defination of the meaning of the return values as well.
--- savevm.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)
savevm.c +12 -2
@@ -904,10 +904,20 @@ int64_t qemu_ftell(QEMUFile *f)return f->pos; } +/* +* The meaning of the return values is: +* 0: We can continue sending +* 1: Time to stop +* negative: There has been an error +*/ +int qemu_file_rate_limit (QEMUFile *f) { -if (qemu_file_get_error (f)) { -return 1 ; +int ret; + + ret =qemu_file_get_error (f); +if (ret) { +return ret; }if (f->xfer_limit >0 && f->bytes_xfer > f->xfer_limit) {return 1 ;
Signature · 1 line
1.7.7.6
In the logic of ram_save_iterate(), it checks the ret of qemu_file_rate_limit(f) by ret < 0 if there has been an error. But now it will never return negative value because qemu_file_rate_limit() return 1 if qemu_file_get_error().
Also the original implementation of qemu_file_rate_limit() as function buffered_rate_limit() did return negative for this situation.
Quoted 41 lines · Lei Li
Commit
1964a397063967acc5ce71a2a24ed26e74824ee1refactors rate limiting to QEMUFile, but set the return value forqemu_file_rate_limitto 1 in the case ofqemu_file_get_error. It is wrong and should be negative compared to the original functionbuffered_rate_limitand the current logic inram_save_iterate. Asqemu_file_rate_limitis called manually to determine if it has to exit, add the defination of the meaning of the return values as well.Signed-off-by Lei Li <[email protected]>--- savevm.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)savevm.c +12
-2@@ -904,10 +904,20 @@ int64_t qemu_ftell(QEMUFile *f)return f->pos; } +/* +* The meaning of the return values is: +* 0: We can continue sending +* 1: Time to stop +* negative: There has been an error +*/ +int qemu_file_rate_limit (QEMUFile *f) { -if (qemu_file_get_error (f)) { -return 1 ; +int ret; + + ret =qemu_file_get_error (f); +if (ret) { +return ret; }if (f->xfer_limit >0 && f->bytes_xfer > f->xfer_limit) {return 1 ;
Signature · 1 line
Lei
PING? any comments?
Quoted 52 lines · Lei Li
In the logic of
ram_save_iterate(), it checks the ret ofqemu_file_rate_limit(f)by ret < 0 if there has been an error. But now it will never return negative value becauseqemu_file_rate_limit()return 1 ifqemu_file_get_error().Also the original implementation of
qemu_file_rate_limit()as functionbuffered_rate_limit()did return negative for this situation.Quoted 41 lines · Lei Li
Commit
1964a397063967acc5ce71a2a24ed26e74824ee1refactors rate limiting to QEMUFile, but set the return value forqemu_file_rate_limitto 1 in the case ofqemu_file_get_error. It is wrong and should be negative compared to the original functionbuffered_rate_limitand the current logic inram_save_iterate. Asqemu_file_rate_limitis called manually to determine if it has to exit, add the defination of the meaning of the return values as well.Signed-off-by Lei Li <[email protected]>--- savevm.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)savevm.c +12
-2@@ -904,10 +904,20 @@ int64_t qemu_ftell(QEMUFile *f)return f->pos; } +/* +* The meaning of the return values is: +* 0: We can continue sending +* 1: Time to stop +* negative: There has been an error +*/ +int qemu_file_rate_limit (QEMUFile *f) { -if (qemu_file_get_error (f)) { -return 1 ; +int ret; + + ret =qemu_file_get_error (f); +if (ret) { +return ret; }if (f->xfer_limit >0 && f->bytes_xfer > f->xfer_limit) {return 1 ;
Signature · 1 line
Lei