block-migration: handle errors with the return codes correctly
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
ceb2bd09a1
commit
43be3a25c9
@ -423,10 +423,9 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
DPRINTF("Error reading sector %" PRId64 "\n", sector);
|
DPRINTF("Error reading sector %" PRId64 "\n", sector);
|
||||||
qemu_file_set_error(f, ret);
|
|
||||||
g_free(blk->buf);
|
g_free(blk->buf);
|
||||||
g_free(blk);
|
g_free(blk);
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return value:
|
/* return value:
|
||||||
@ -440,7 +439,7 @@ static int blk_mig_save_dirty_block(QEMUFile *f, int is_async)
|
|||||||
|
|
||||||
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
|
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
|
||||||
ret = mig_save_device_dirty(f, bmds, is_async);
|
ret = mig_save_device_dirty(f, bmds, is_async);
|
||||||
if (ret == 0) {
|
if (ret <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -600,12 +599,17 @@ static int block_save_iterate(QEMUFile *f, void *opaque)
|
|||||||
block_mig_state.bulk_completed = 1;
|
block_mig_state.bulk_completed = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (blk_mig_save_dirty_block(f, 1) != 0) {
|
ret = blk_mig_save_dirty_block(f, 1);
|
||||||
|
if (ret != 0) {
|
||||||
/* no more dirty blocks */
|
/* no more dirty blocks */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ret) {
|
||||||
|
blk_mig_cleanup();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ret = flush_blks(f);
|
ret = flush_blks(f);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -637,18 +641,16 @@ static int block_save_complete(QEMUFile *f, void *opaque)
|
|||||||
all async read completed */
|
all async read completed */
|
||||||
assert(block_mig_state.submitted == 0);
|
assert(block_mig_state.submitted == 0);
|
||||||
|
|
||||||
while (blk_mig_save_dirty_block(f, 0) == 0) {
|
do {
|
||||||
/* Do nothing */
|
ret = blk_mig_save_dirty_block(f, 0);
|
||||||
}
|
} while (ret == 0);
|
||||||
|
|
||||||
blk_mig_cleanup();
|
blk_mig_cleanup();
|
||||||
|
|
||||||
/* report completion */
|
|
||||||
qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS);
|
|
||||||
|
|
||||||
ret = qemu_file_get_error(f);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
/* report completion */
|
||||||
|
qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS);
|
||||||
|
|
||||||
DPRINTF("Block migration completed\n");
|
DPRINTF("Block migration completed\n");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user