From: Gonglei <arei.gong...@huawei.com> After commit 4c7e251a (), when dump memory completed, the s->fd will be closed twice. We should return directly when dump completed.
Using do/while block, make the badly chosen return values of get_next_block() more visible and fix this issue. Signed-off-by: Gonglei <arei.gong...@huawei.com> --- v2 -> v1: Using do/while block, make the badly chosen return values of get_next_block() more visible and fix this issue. (Markus) --- dump.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/dump.c b/dump.c index 06a4915..9c7dad8 100644 --- a/dump.c +++ b/dump.c @@ -604,10 +604,9 @@ static void dump_iterate(DumpState *s, Error **errp) { GuestPhysBlock *block; int64_t size; - int ret; Error *local_err = NULL; - while (1) { + do { block = s->next_block; size = block->target_end - block->target_start; @@ -623,11 +622,9 @@ static void dump_iterate(DumpState *s, Error **errp) return; } - ret = get_next_block(s, block); - if (ret == 1) { - dump_completed(s); - } - } + } while (!get_next_block(s, block)); + + dump_completed(s); } static void create_vmcore(DumpState *s, Error **errp) -- 1.7.12.4