[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/13] vfio/migration: Block VFIO migration with background snapsh
From: |
Cédric Le Goater |
Subject: |
[PULL 12/13] vfio/migration: Block VFIO migration with background snapshot |
Date: |
Mon, 11 Sep 2023 09:50:07 +0200 |
From: Avihai Horon <avihaih@nvidia.com>
Background snapshot allows creating a snapshot of the VM while it's
running and keeping it small by not including dirty RAM pages.
The way it works is by first stopping the VM, saving the non-iterable
devices' state and then starting the VM and saving the RAM while write
protecting it with UFFD. The resulting snapshot represents the VM state
at snapshot start.
VFIO migration is not compatible with background snapshot.
First of all, VFIO device state is not even saved in background snapshot
because only non-iterable device state is saved. But even if it was
saved, after starting the VM, a VFIO device could dirty pages without it
being detected by UFFD write protection. This would corrupt the
snapshot, as the RAM in it would not represent the RAM at snapshot
start.
To prevent this, block VFIO migration with background snapshot.
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/migration.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index
20994dc1d60b1606728415fec17c19cfd00c4dee..da43dcd2fe0734091960e3eb2ffa26750073be72
100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -340,7 +340,8 @@ static int vfio_save_prepare(void *opaque, Error **errp)
VFIODevice *vbasedev = opaque;
/*
- * Snapshot doesn't use postcopy, so allow snapshot even if postcopy is on.
+ * Snapshot doesn't use postcopy nor background snapshot, so allow snapshot
+ * even if they are on.
*/
if (runstate_check(RUN_STATE_SAVE_VM)) {
return 0;
@@ -353,6 +354,14 @@ static int vfio_save_prepare(void *opaque, Error **errp)
return -EOPNOTSUPP;
}
+ if (migrate_background_snapshot()) {
+ error_setg(
+ errp,
+ "%s: VFIO migration is not supported with background snapshot",
+ vbasedev->name);
+ return -EOPNOTSUPP;
+ }
+
return 0;
}
--
2.41.0
- [PULL 03/13] qdev: Add qdev_add_vm_change_state_handler_full(), (continued)
- [PULL 03/13] qdev: Add qdev_add_vm_change_state_handler_full(), Cédric Le Goater, 2023/09/11
- [PULL 05/13] vfio/migration: Add P2P support for VFIO migration, Cédric Le Goater, 2023/09/11
- [PULL 08/13] vfio/migration: Fail adding device with enable-migration=on and existing blocker, Cédric Le Goater, 2023/09/11
- [PULL 06/13] vfio/migration: Allow migration of multiple P2P supporting devices, Cédric Le Goater, 2023/09/11
- [PULL 07/13] migration: Add migration prefix to functions in target.c, Cédric Le Goater, 2023/09/11
- [PULL 10/13] migration: Add .save_prepare() handler to struct SaveVMHandlers, Cédric Le Goater, 2023/09/11
- [PULL 04/13] vfio/migration: Refactor PRE_COPY and RUNNING state checks, Cédric Le Goater, 2023/09/11
- [PULL 09/13] migration: Move more initializations to migrate_init(), Cédric Le Goater, 2023/09/11
- [PULL 11/13] vfio/migration: Block VFIO migration with postcopy migration, Cédric Le Goater, 2023/09/11
- [PULL 13/13] vfio/common: Separate vfio-pci ranges, Cédric Le Goater, 2023/09/11
- [PULL 12/13] vfio/migration: Block VFIO migration with background snapshot,
Cédric Le Goater <=
- Re: [PULL 00/13] vfio queue, Stefan Hajnoczi, 2023/09/11