[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/26] migration/savevm: Allow immutable device state to be migrat
From: |
Juan Quintela |
Subject: |
[PULL 14/26] migration/savevm: Allow immutable device state to be migrated early (i.e., before RAM) |
Date: |
Thu, 2 Feb 2023 17:06:28 +0100 |
From: David Hildenbrand <david@redhat.com>
For virtio-mem, we want to have the plugged/unplugged state of memory
blocks available before migrating any actual RAM content, and perform
sanity checks before touching anything on the destination. This
information is immutable on the migration source while migration is active,
We want to use this information for proper preallocation support with
migration: currently, we don't preallocate memory on the migration target,
and especially with hugetlb, we can easily run out of hugetlb pages during
RAM migration and will crash (SIGBUS) instead of catching this gracefully
via preallocation.
Migrating device state via a VMSD before we start iterating is currently
impossible: the only approach that would be possible is avoiding a VMSD
and migrating state manually during save_setup(), to be restored during
load_state().
Let's allow for migrating device state via a VMSD early, during the
setup phase in qemu_savevm_state_setup(). To keep it simple, we
indicate applicable VMSD's using an "early_setup" flag.
Note that only very selected devices (i.e., ones seriously messing with
RAM setup) are supposed to make use of such early state migration.
While at it, also use a bool for the "unmigratable" member.
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>S
Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
include/migration/vmstate.h | 16 +++++++++++++++-
migration/savevm.c | 14 ++++++++++++++
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index ad24aa1934..64680d824e 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -178,7 +178,21 @@ struct VMStateField {
struct VMStateDescription {
const char *name;
- int unmigratable;
+ bool unmigratable;
+ /*
+ * This VMSD describes something that should be sent during setup phase
+ * of migration. It plays similar role as save_setup() for explicitly
+ * registered vmstate entries, so it can be seen as a way to describe
+ * save_setup() in VMSD structures.
+ *
+ * Note that for now, a SaveStateEntry cannot have a VMSD and
+ * operations (e.g., save_setup()) set at the same time. Consequently,
+ * save_setup() and a VMSD with early_setup set to true are mutually
+ * exclusive. For this reason, also early_setup VMSDs are migrated in a
+ * QEMU_VM_SECTION_FULL section, while save_setup() data is migrated in
+ * a QEMU_VM_SECTION_START section.
+ */
+ bool early_setup;
int version_id;
int minimum_version_id;
MigrationPriority priority;
diff --git a/migration/savevm.c b/migration/savevm.c
index 28f88b5521..6d985ad4af 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1201,6 +1201,15 @@ void qemu_savevm_state_setup(QEMUFile *f)
trace_savevm_state_setup();
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
+ if (se->vmsd && se->vmsd->early_setup) {
+ ret = vmstate_save(f, se, ms->vmdesc);
+ if (ret) {
+ qemu_file_set_error(f, ret);
+ break;
+ }
+ continue;
+ }
+
if (!se->ops || !se->ops->save_setup) {
continue;
}
@@ -1403,6 +1412,11 @@ int
qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
int ret;
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
+ if (se->vmsd && se->vmsd->early_setup) {
+ /* Already saved during qemu_savevm_state_setup(). */
+ continue;
+ }
+
ret = vmstate_save(f, se, vmdesc);
if (ret) {
qemu_file_set_error(f, ret);
--
2.39.1
- [PULL 02/26] migration: No save_live_pending() method uses the QEMUFile parameter, (continued)
- [PULL 02/26] migration: No save_live_pending() method uses the QEMUFile parameter, Juan Quintela, 2023/02/02
- [PULL 01/26] migration: Fix migration crash when target psize larger than host, Juan Quintela, 2023/02/02
- [PULL 04/26] migration: Remove unused threshold_size parameter, Juan Quintela, 2023/02/02
- [PULL 07/26] migration/ram: Fix populate_read_range(), Juan Quintela, 2023/02/02
- [PULL 05/26] migration: simplify migration_iteration_run(), Juan Quintela, 2023/02/02
- [PULL 08/26] migration/ram: Fix error handling in ram_write_tracking_start(), Juan Quintela, 2023/02/02
- [PULL 09/26] migration/ram: Don't explicitly unprotect when unregistering uffd-wp, Juan Quintela, 2023/02/02
- [PULL 10/26] migration/ram: Rely on used_length for uffd_change_protection(), Juan Quintela, 2023/02/02
- [PULL 12/26] migration/savevm: Move more savevm handling into vmstate_save(), Juan Quintela, 2023/02/02
- [PULL 13/26] migration/savevm: Prepare vmdesc json writer in qemu_savevm_state_setup(), Juan Quintela, 2023/02/02
- [PULL 14/26] migration/savevm: Allow immutable device state to be migrated early (i.e., before RAM),
Juan Quintela <=
- [PULL 16/26] migration/ram: Factor out check for advised postcopy, Juan Quintela, 2023/02/02
- [PULL 17/26] virtio-mem: Fail if a memory backend with "prealloc=on" is specified, Juan Quintela, 2023/02/02
- [PULL 06/26] util/userfaultfd: Add uffd_open(), Juan Quintela, 2023/02/02
- [PULL 03/26] migration: Split save_live_pending() into state_pending_*, Juan Quintela, 2023/02/02
- [PULL 15/26] migration/vmstate: Introduce VMSTATE_WITH_TMP_TEST() and VMSTATE_BITMAP_TEST(), Juan Quintela, 2023/02/02
- [PULL 18/26] virtio-mem: Migrate immutable properties early, Juan Quintela, 2023/02/02
- [PULL 19/26] virtio-mem: Proper support for preallocation with migration, Juan Quintela, 2023/02/02
- [PULL 11/26] migration/ram: Optimize ram_write_tracking_start() for RamDiscardManager, Juan Quintela, 2023/02/02
- [PULL 23/26] migration: Perform vmsd structure check during tests, Juan Quintela, 2023/02/02
- [PULL 20/26] migration: Show downtime during postcopy phase, Juan Quintela, 2023/02/02