[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC 07/11] migration/block: Apply the migration_block_* API to po
From: |
Peter Xu |
Subject: |
[PATCH RFC 07/11] migration/block: Apply the migration_block_* API to postcopy |
Date: |
Tue, 3 Dec 2024 19:51:34 -0500 |
Postcopy also has similar error handling for re-activation of block
devices. Use the same API as precopy to do the re-activation, for both src
& dst sides.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/migration.c | 22 +++-------------------
migration/savevm.c | 10 ++++------
2 files changed, 7 insertions(+), 25 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index e01264168f..1a1c570c5b 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2544,7 +2544,6 @@ static int postcopy_start(MigrationState *ms, Error
**errp)
QIOChannelBuffer *bioc;
QEMUFile *fb;
uint64_t bandwidth = migrate_max_postcopy_bandwidth();
- bool restart_block = false;
int cur_state = MIGRATION_STATUS_ACTIVE;
if (migrate_postcopy_preempt()) {
@@ -2580,13 +2579,10 @@ static int postcopy_start(MigrationState *ms, Error
**errp)
goto fail;
}
- ret = bdrv_inactivate_all();
- if (ret < 0) {
- error_setg_errno(errp, -ret, "%s: Failed in bdrv_inactivate_all()",
- __func__);
+ if (!migration_block_inactivate(ms)) {
+ error_setg(errp, "%s: Failed in bdrv_inactivate_all()", __func__);
goto fail;
}
- restart_block = true;
/*
* Cause any non-postcopiable, but iterative devices to
@@ -2656,8 +2652,6 @@ static int postcopy_start(MigrationState *ms, Error
**errp)
goto fail_closefb;
}
- restart_block = false;
-
/* Now send that blob */
if (qemu_savevm_send_packaged(ms->to_dst_file, bioc->data, bioc->usage)) {
error_setg(errp, "%s: Failed to send packaged data", __func__);
@@ -2702,17 +2696,7 @@ fail_closefb:
fail:
migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,
MIGRATION_STATUS_FAILED);
- if (restart_block) {
- /* A failure happened early enough that we know the destination hasn't
- * accessed block devices, so we're safe to recover.
- */
- Error *local_err = NULL;
-
- bdrv_activate_all(&local_err);
- if (local_err) {
- error_report_err(local_err);
- }
- }
+ migration_block_activate(ms);
migration_call_notifiers(ms, MIG_EVENT_PRECOPY_FAILED, NULL);
bql_unlock();
return -1;
diff --git a/migration/savevm.c b/migration/savevm.c
index a335344c75..2ce5064efc 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2120,7 +2120,6 @@ static int
loadvm_postcopy_handle_listen(MigrationIncomingState *mis)
static void loadvm_postcopy_handle_run_bh(void *opaque)
{
- Error *local_err = NULL;
MigrationIncomingState *mis = opaque;
trace_vmstate_downtime_checkpoint("dst-postcopy-bh-enter");
@@ -2141,12 +2140,11 @@ static void loadvm_postcopy_handle_run_bh(void *opaque)
if (autostart) {
/* Make sure all file formats throw away their mutable metadata.
* If we get an error here, just don't restart the VM yet. */
- bdrv_activate_all(&local_err);
+ bool success = migration_block_activate(migrate_get_current());
+
trace_vmstate_downtime_checkpoint("dst-postcopy-bh-cache-invalidated");
- if (local_err) {
- error_report_err(local_err);
- local_err = NULL;
- } else {
+
+ if (success) {
vm_start();
}
} else {
--
2.47.0
- [PATCH RFC 03/11] migration/block: Apply late-block-active behavior to postcopy, (continued)
- [PATCH RFC 03/11] migration/block: Apply late-block-active behavior to postcopy, Peter Xu, 2024/12/03
- [PATCH RFC 02/11] migration/block: Make late-block-active the default, Peter Xu, 2024/12/03
- [PATCH RFC 06/11] migration/block: Extend the migration_block_* API to dest side, Peter Xu, 2024/12/03
- [PATCH RFC 05/11] migration/block: Merge block reactivations for fail/cancel, Peter Xu, 2024/12/03
- [PATCH RFC 04/11] migration/block: Fix possible race with block_inactive, Peter Xu, 2024/12/03
- [PATCH RFC 08/11] tests/qtest/migration: Move more code under only_target, Peter Xu, 2024/12/03
- [PATCH RFC 10/11] tests/qtest/migration: Support cleaning up only one side of migration, Peter Xu, 2024/12/03
- [PATCH RFC 09/11] tests/qtest/migration: Don't use hardcoded strings for -serial, Peter Xu, 2024/12/03
- [PATCH RFC 07/11] migration/block: Apply the migration_block_* API to postcopy,
Peter Xu <=
- [PATCH RFC 11/11] tests/qtest/migration: Test successive migrations, Peter Xu, 2024/12/03
- Re: [PATCH RFC 00/11] migration/block: disk activation rewrite, Peter Xu, 2024/12/04