[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/26] migration: Always report an error in block_save_setup()
From: |
Peter Xu |
Subject: |
[PULL 12/26] migration: Always report an error in block_save_setup() |
Date: |
Tue, 23 Apr 2024 18:37:59 -0400 |
From: Cédric Le Goater <clg@redhat.com>
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>
---
migration/block.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/migration/block.c b/migration/block.c
index 2b9054889a..f8a11beb37 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -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;
BlkMigDevState *bmds;
@@ -378,7 +378,6 @@ static int init_blk_migration(QEMUFile *f)
BlkMigDevState *bmds;
BlockDriverState *bs;
} *bmds_bs;
- Error *local_err = NULL;
int ret;
GRAPH_RDLOCK_GUARD_MAINLOOP();
@@ -406,6 +405,8 @@ static int init_blk_migration(QEMUFile *f)
continue;
}
if (sectors < 0) {
+ error_setg(errp, "Error getting length of block device %s",
+ bdrv_get_device_name(bs));
ret = sectors;
bdrv_next_cleanup(&it);
goto out;
@@ -442,9 +443,8 @@ static int init_blk_migration(QEMUFile *f)
bs = bmds_bs[i].bs;
if (bmds) {
- ret = blk_insert_bs(bmds->blk, bs, &local_err);
+ ret = blk_insert_bs(bmds->blk, bs, errp);
if (ret < 0) {
- error_report_err(local_err);
goto out;
}
@@ -714,6 +714,7 @@ static void block_migration_cleanup(void *opaque)
static int block_save_setup(QEMUFile *f, void *opaque)
{
int ret;
+ Error *local_err = NULL;
trace_migration_block_save("setup", block_mig_state.submitted,
block_mig_state.transferred);
@@ -721,18 +722,27 @@ static int block_save_setup(QEMUFile *f, void *opaque)
warn_report("block migration is deprecated;"
" use blockdev-mirror with NBD instead");
- ret = init_blk_migration(f);
+ ret = init_blk_migration(f, &local_err);
if (ret < 0) {
+ error_report_err(local_err);
return ret;
}
/* start track dirty blocks */
ret = set_dirty_tracking();
if (ret) {
+ error_setg_errno(&local_err, -ret,
+ "Failed to start block dirty tracking");
+ error_report_err(local_err);
return ret;
}
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();
qemu_put_be64(f, BLK_MIG_FLAG_EOS);
--
2.44.0
- [PULL 16/26] migration: Add Error** argument to .save_setup() handler, (continued)
- [PULL 16/26] migration: Add Error** argument to .save_setup() handler, Peter Xu, 2024/04/23
- [PULL 19/26] migration: Introduce ram_bitmaps_destroy(), Peter Xu, 2024/04/23
- [PULL 24/26] migration: Add Error** argument to add_bitmaps_to_list(), Peter Xu, 2024/04/23
- [PULL 26/26] migration/colo: Fix bdrv_graph_rdlock_main_loop: Assertion `!qemu_in_coroutine()' failed., Peter Xu, 2024/04/23
- [PULL 08/26] tests/qtest/migration: Add negative tests to validate migration QAPIs, Peter Xu, 2024/04/23
- [PULL 06/26] tests/qtest/migration: Add channels parameter in migrate_qmp, Peter Xu, 2024/04/23
- [PULL 17/26] migration: Add Error** argument to .load_setup() handler, Peter Xu, 2024/04/23
- [PULL 10/26] s390/stattrib: Add Error** argument to set_migrationmode() handler, Peter Xu, 2024/04/23
- [PULL 25/26] migration/multifd: solve zero page causing multiple page faults, Peter Xu, 2024/04/23
- [PULL 05/26] tests/qtest/migration: Add migrate_set_ports into migrate_qmp to update migration port value, Peter Xu, 2024/04/23
- [PULL 12/26] migration: Always report an error in block_save_setup(),
Peter Xu <=
- [PULL 14/26] migration: Add Error** argument to vmstate_save(), Peter Xu, 2024/04/23
- [PULL 09/26] tests/qtest/migration: Fix typo for vsock in SocketAddress_to_str, Peter Xu, 2024/04/23
- [PULL 11/26] vfio: Always report an error in vfio_save_setup(), Peter Xu, 2024/04/23
- [PULL 22/26] migration: Add Error** argument to xbzrle_init(), Peter Xu, 2024/04/23
- [PULL 03/26] tests/qtest/migration: Replace migrate_get_connect_uri inplace of migrate_get_socket_address, Peter Xu, 2024/04/23
- [PULL 15/26] migration: Add Error** argument to qemu_savevm_state_setup(), Peter Xu, 2024/04/23
- [PULL 18/26] memory: Add Error** argument to .log_global_start() handler, Peter Xu, 2024/04/23
- [PULL 23/26] migration: Modify ram_init_bitmaps() to report dirty tracking errors, Peter Xu, 2024/04/23
- [PULL 20/26] memory: Add Error** argument to the global_dirty_log routines, Peter Xu, 2024/04/23
- [PULL 21/26] migration: Add Error** argument to ram_state_init(), Peter Xu, 2024/04/23