qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] vfio/migration: Block VFIO migration with postcopy and background snapshot
@ 2023-08-28 15:18 Avihai Horon
  2023-08-28 15:18 ` [PATCH 1/6] migration: Add migration prefix to functions in target.c Avihai Horon
                   ` (5 more replies)
  0 siblings, 6 replies; 25+ messages in thread
From: Avihai Horon @ 2023-08-28 15:18 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alex Williamson, Cédric Le Goater, Juan Quintela, Peter Xu,
	Leonardo Bras, Yanghang Liu, Avihai Horon

Hello,

Recently added VFIO migration is not compatible with some of the
pre-existing migration features. This was overlooked and today these
combinations are not blocked by QEMU. This series fixes it.

Postcopy migration:
VFIO migration is not compatible with postcopy migration. A VFIO device
in the destination can't handle page faults for pages that have not been
sent yet. Doing such migration will cause the VM to crash in the
destination.

Background snapshot:
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.

This series blocks these combinations explicitly:
If a VFIO device is added when postcopy or background snapshot are on,
a migration blocker will be added. If a VFIO device is present, setting
postcopy or background snapshot capabilities will fail with an
appropriate error message.

Note that this series is based on the P2P series [1] sent a few weeks
ago.

Comments and suggestions will be greatly appreciated.

Thanks.

[1]
https://lore.kernel.org/qemu-devel/20230802081449.2528-1-avihaih@nvidia.com/

Avihai Horon (6):
  migration: Add migration prefix to functions in target.c
  vfio/migration: Fail adding device with enable-migration=on and
    existing blocker
  vfio/migration: Add vfio_migratable_devices_num()
  vfio/migration: Change vfio_mig_active() semantics
  vfio/migration: Block VFIO migration with postcopy migration
  vfio/migration: Block VFIO migration with background snapshot

 include/hw/vfio/vfio-common.h |   4 ++
 migration/migration.h         |   7 +-
 hw/vfio/common.c              | 120 +++++++++++++++++++++++++++++-----
 hw/vfio/migration.c           |  12 ++++
 migration/migration.c         |   6 +-
 migration/options.c           |  26 ++++++++
 migration/savevm.c            |   2 +-
 migration/target.c            |  36 ++++++++--
 8 files changed, 187 insertions(+), 26 deletions(-)

-- 
2.26.3



^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2023-08-30 16:11 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-28 15:18 [PATCH 0/6] vfio/migration: Block VFIO migration with postcopy and background snapshot Avihai Horon
2023-08-28 15:18 ` [PATCH 1/6] migration: Add migration prefix to functions in target.c Avihai Horon
2023-08-29 13:23   ` Cédric Le Goater
2023-08-29 14:04   ` Peter Xu
2023-08-29 15:59     ` Avihai Horon
2023-08-28 15:18 ` [PATCH 2/6] vfio/migration: Fail adding device with enable-migration=on and existing blocker Avihai Horon
2023-08-29 13:23   ` Cédric Le Goater
2023-08-28 15:18 ` [PATCH 3/6] vfio/migration: Add vfio_migratable_devices_num() Avihai Horon
2023-08-29 13:24   ` Cédric Le Goater
2023-08-28 15:18 ` [PATCH 4/6] vfio/migration: Change vfio_mig_active() semantics Avihai Horon
2023-08-28 15:18 ` [PATCH 5/6] vfio/migration: Block VFIO migration with postcopy migration Avihai Horon
2023-08-29 13:24   ` Cédric Le Goater
2023-08-29 15:52     ` Avihai Horon
2023-08-29 14:53   ` Peter Xu
2023-08-29 16:20     ` Avihai Horon
2023-08-29 18:27       ` Peter Xu
2023-08-30  7:01         ` Avihai Horon
2023-08-30  8:37           ` Cédric Le Goater
2023-08-30  9:21             ` Avihai Horon
2023-08-30  9:53               ` Cédric Le Goater
2023-08-30 10:12                 ` Avihai Horon
2023-08-30 11:17                   ` Cédric Le Goater
2023-08-30 14:22                     ` Peter Xu
2023-08-30 16:06                       ` Avihai Horon
2023-08-28 15:18 ` [PATCH 6/6] vfio/migration: Block VFIO migration with background snapshot Avihai Horon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).