mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-07-22 02:44:53 +00:00
migration: Always report an error in block_save_setup()
This will prepare ground for future changes adding an Error** argument to the save_setup() handler. We need to make sure that on failure, block_save_setup() always sets a new error. Cc: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Fabiano Rosas <farosas@suse.de> Signed-off-by: Cédric Le Goater <clg@redhat.com> Link: https://lore.kernel.org/r/20240320064911.545001-4-clg@redhat.com Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
parent
31cf7c1413
commit
150da48cb2
|
@ -367,7 +367,7 @@ static void unset_dirty_tracking(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init_blk_migration(QEMUFile *f)
|
static int init_blk_migration(QEMUFile *f, Error **errp)
|
||||||
{
|
{
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
BlkMigDevState *bmds;
|
BlkMigDevState *bmds;
|
||||||
|
@ -378,7 +378,6 @@ static int init_blk_migration(QEMUFile *f)
|
||||||
BlkMigDevState *bmds;
|
BlkMigDevState *bmds;
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
} *bmds_bs;
|
} *bmds_bs;
|
||||||
Error *local_err = NULL;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
||||||
|
@ -406,6 +405,8 @@ static int init_blk_migration(QEMUFile *f)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sectors < 0) {
|
if (sectors < 0) {
|
||||||
|
error_setg(errp, "Error getting length of block device %s",
|
||||||
|
bdrv_get_device_name(bs));
|
||||||
ret = sectors;
|
ret = sectors;
|
||||||
bdrv_next_cleanup(&it);
|
bdrv_next_cleanup(&it);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -442,9 +443,8 @@ static int init_blk_migration(QEMUFile *f)
|
||||||
bs = bmds_bs[i].bs;
|
bs = bmds_bs[i].bs;
|
||||||
|
|
||||||
if (bmds) {
|
if (bmds) {
|
||||||
ret = blk_insert_bs(bmds->blk, bs, &local_err);
|
ret = blk_insert_bs(bmds->blk, bs, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_report_err(local_err);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,6 +714,7 @@ static void block_migration_cleanup(void *opaque)
|
||||||
static int block_save_setup(QEMUFile *f, void *opaque)
|
static int block_save_setup(QEMUFile *f, void *opaque)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
Error *local_err = NULL;
|
||||||
|
|
||||||
trace_migration_block_save("setup", block_mig_state.submitted,
|
trace_migration_block_save("setup", block_mig_state.submitted,
|
||||||
block_mig_state.transferred);
|
block_mig_state.transferred);
|
||||||
|
@ -721,18 +722,27 @@ static int block_save_setup(QEMUFile *f, void *opaque)
|
||||||
warn_report("block migration is deprecated;"
|
warn_report("block migration is deprecated;"
|
||||||
" use blockdev-mirror with NBD instead");
|
" use blockdev-mirror with NBD instead");
|
||||||
|
|
||||||
ret = init_blk_migration(f);
|
ret = init_blk_migration(f, &local_err);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_report_err(local_err);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start track dirty blocks */
|
/* start track dirty blocks */
|
||||||
ret = set_dirty_tracking();
|
ret = set_dirty_tracking();
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
error_setg_errno(&local_err, -ret,
|
||||||
|
"Failed to start block dirty tracking");
|
||||||
|
error_report_err(local_err);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = flush_blks(f);
|
ret = flush_blks(f);
|
||||||
|
if (ret) {
|
||||||
|
error_setg_errno(&local_err, -ret, "Flushing block failed");
|
||||||
|
error_report_err(local_err);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
blk_mig_reset_dirty_cursor();
|
blk_mig_reset_dirty_cursor();
|
||||||
qemu_put_be64(f, BLK_MIG_FLAG_EOS);
|
qemu_put_be64(f, BLK_MIG_FLAG_EOS);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue