[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 30/42] migration: Drop inactivate_disk param in qemu_savevm_state_
From: |
Fabiano Rosas |
Subject: |
[PULL 30/42] migration: Drop inactivate_disk param in qemu_savevm_state_complete* |
Date: |
Wed, 29 Jan 2025 13:00:47 -0300 |
From: Peter Xu <peterx@redhat.com>
This parameter is only used by one caller, which is the genuine precopy
complete path (migration_completion_precopy).
The parameter was introduced in a1fbe750fd ("migration: Fix race of image
locking between src and dst") to make sure the inactivate will happen
before EOF to make sure dest will always be able to activate the disk
properly. However there's no limitation on how early we inactivate the
disk. For precopy completion path, we can always do that as long as VM is
stopped.
Move the disk inactivate there, then we can remove this inactivate_disk
parameter in the whole call stack, because all the rest users pass in false
always.
Signed-off-by: Peter Xu <peterx@redhat.com>
Tested-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Link: 20250114230746.3268797-6-peterx@redhat.com">https://lore.kernel.org/r/20250114230746.3268797-6-peterx@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
migration/migration.c | 24 +++++++++++++++++-------
migration/savevm.c | 27 +++++----------------------
migration/savevm.h | 5 ++---
3 files changed, 24 insertions(+), 32 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 07b6b730b7..d8a6bc12e0 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2682,7 +2682,7 @@ static int postcopy_start(MigrationState *ms, Error
**errp)
* Cause any non-postcopiable, but iterative devices to
* send out their final data.
*/
- qemu_savevm_state_complete_precopy(ms->to_dst_file, true, false);
+ qemu_savevm_state_complete_precopy(ms->to_dst_file, true);
/*
* in Finish migrate and with the io-lock held everything should
@@ -2727,7 +2727,7 @@ static int postcopy_start(MigrationState *ms, Error
**errp)
*/
qemu_savevm_send_postcopy_listen(fb);
- qemu_savevm_state_complete_precopy(fb, false, false);
+ qemu_savevm_state_complete_precopy(fb, false);
if (migrate_postcopy_ram()) {
qemu_savevm_send_ping(fb, 3);
}
@@ -2859,11 +2859,21 @@ static int migration_completion_precopy(MigrationState
*s,
goto out_unlock;
}
- migration_rate_set(RATE_LIMIT_DISABLED);
-
/* Inactivate disks except in COLO */
- ret = qemu_savevm_state_complete_precopy(s->to_dst_file, false,
- !migrate_colo());
+ if (!migrate_colo()) {
+ /*
+ * Inactivate before sending QEMU_VM_EOF so that the
+ * bdrv_activate_all() on the other end won't fail.
+ */
+ if (!migration_block_inactivate()) {
+ ret = -EFAULT;
+ goto out_unlock;
+ }
+ }
+
+ migration_rate_set(RATE_LIMIT_DISABLED);
+
+ ret = qemu_savevm_state_complete_precopy(s->to_dst_file, false);
out_unlock:
bql_unlock();
return ret;
@@ -3744,7 +3754,7 @@ static void *bg_migration_thread(void *opaque)
* save their state to channel-buffer along with devices.
*/
cpu_synchronize_all_states();
- if (qemu_savevm_state_complete_precopy_non_iterable(fb, false, false)) {
+ if (qemu_savevm_state_complete_precopy_non_iterable(fb, false)) {
goto fail;
}
/*
diff --git a/migration/savevm.c b/migration/savevm.c
index cfe9dfaf5c..5e56a5d9fc 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1521,8 +1521,7 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUFile
*f, bool in_postcopy)
}
int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
- bool in_postcopy,
- bool inactivate_disks)
+ bool in_postcopy)
{
MigrationState *ms = migrate_get_current();
int64_t start_ts_each, end_ts_each;
@@ -1553,20 +1552,6 @@ int
qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
end_ts_each - start_ts_each);
}
- if (inactivate_disks) {
- /*
- * Inactivate before sending QEMU_VM_EOF so that the
- * bdrv_activate_all() on the other end won't fail.
- */
- if (!migration_block_inactivate()) {
- error_setg(&local_err, "%s: bdrv_inactivate_all() failed",
- __func__);
- migrate_set_error(ms, local_err);
- error_report_err(local_err);
- qemu_file_set_error(f, -EFAULT);
- return -1;
- }
- }
if (!in_postcopy) {
/* Postcopy stream will still be going */
qemu_put_byte(f, QEMU_VM_EOF);
@@ -1587,8 +1572,7 @@ int
qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
return 0;
}
-int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only,
- bool inactivate_disks)
+int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only)
{
int ret;
Error *local_err = NULL;
@@ -1613,8 +1597,7 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f, bool
iterable_only,
goto flush;
}
- ret = qemu_savevm_state_complete_precopy_non_iterable(f, in_postcopy,
- inactivate_disks);
+ ret = qemu_savevm_state_complete_precopy_non_iterable(f, in_postcopy);
if (ret) {
return ret;
}
@@ -1717,7 +1700,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
ret = qemu_file_get_error(f);
if (ret == 0) {
- qemu_savevm_state_complete_precopy(f, false, false);
+ qemu_savevm_state_complete_precopy(f, false);
ret = qemu_file_get_error(f);
}
if (ret != 0) {
@@ -1743,7 +1726,7 @@ cleanup:
void qemu_savevm_live_state(QEMUFile *f)
{
/* save QEMU_VM_SECTION_END section */
- qemu_savevm_state_complete_precopy(f, true, false);
+ qemu_savevm_state_complete_precopy(f, true);
qemu_put_byte(f, QEMU_VM_EOF);
}
diff --git a/migration/savevm.h b/migration/savevm.h
index 9ec96a995c..c48a53e95e 100644
--- a/migration/savevm.h
+++ b/migration/savevm.h
@@ -39,8 +39,7 @@ void qemu_savevm_state_header(QEMUFile *f);
int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy);
void qemu_savevm_state_cleanup(void);
void qemu_savevm_state_complete_postcopy(QEMUFile *f);
-int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only,
- bool inactivate_disks);
+int qemu_savevm_state_complete_precopy(QEMUFile *f, bool iterable_only);
void qemu_savevm_state_pending_exact(uint64_t *must_precopy,
uint64_t *can_postcopy);
void qemu_savevm_state_pending_estimate(uint64_t *must_precopy,
@@ -68,6 +67,6 @@ int qemu_loadvm_state_main(QEMUFile *f,
MigrationIncomingState *mis);
int qemu_load_device_state(QEMUFile *f);
int qemu_loadvm_approve_switchover(void);
int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
- bool in_postcopy, bool inactivate_disks);
+ bool in_postcopy);
#endif
--
2.35.3
- [PULL 05/42] physmem: fd-based shared memory, (continued)
- [PULL 05/42] physmem: fd-based shared memory, Fabiano Rosas, 2025/01/29
- [PULL 07/42] machine: aux-ram-share option, Fabiano Rosas, 2025/01/29
- [PULL 10/42] hostmem-memfd: preserve for cpr, Fabiano Rosas, 2025/01/29
- [PULL 02/42] backends/hostmem-shm: factor out allocation of "anonymous shared memory with an fd", Fabiano Rosas, 2025/01/29
- [PULL 12/42] migration: enhance migrate_uri_parse, Fabiano Rosas, 2025/01/29
- [PULL 15/42] migration: VMSTATE_FD, Fabiano Rosas, 2025/01/29
- [PULL 20/42] tests/qtest: defer connection, Fabiano Rosas, 2025/01/29
- [PULL 22/42] tests/qtest: enhance migration channels, Fabiano Rosas, 2025/01/29
- [PULL 23/42] tests/qtest: assert qmp connected, Fabiano Rosas, 2025/01/29
- [PULL 26/42] migration: Remove postcopy implications in should_send_vmdesc(), Fabiano Rosas, 2025/01/29
- [PULL 30/42] migration: Drop inactivate_disk param in qemu_savevm_state_complete*,
Fabiano Rosas <=
- [PULL 33/42] migration: Adjust locking in migration_maybe_pause(), Fabiano Rosas, 2025/01/29
- [PULL 03/42] physmem: fix qemu_ram_alloc_from_fd size calculation, Fabiano Rosas, 2025/01/29
- [PULL 06/42] memory: add RAM_PRIVATE, Fabiano Rosas, 2025/01/29
- [PULL 11/42] hostmem-shm: preserve for cpr, Fabiano Rosas, 2025/01/29
- [PULL 21/42] migration-test: defer connection, Fabiano Rosas, 2025/01/29
- [PULL 14/42] migration: SCM_RIGHTS for QEMUFile, Fabiano Rosas, 2025/01/29
- [PULL 28/42] migration: Optimize postcopy on downtime by avoiding JSON writer, Fabiano Rosas, 2025/01/29
- [PULL 29/42] migration: Avoid two src-downtime-end tracepoints for postcopy, Fabiano Rosas, 2025/01/29
- [PULL 34/42] migration: Drop cached migration state in migration_maybe_pause(), Fabiano Rosas, 2025/01/29
- [PULL 24/42] migration-test: cpr-transfer, Fabiano Rosas, 2025/01/29