pci: vfio: Implement dirty page tracking for VfioPciDevice

Wire the previously empty Migratable implementation on VfioPciDevice to
VFIO DMA logging so the pages the device writes to guest memory are
tracked during a live migration. The Vfio trait gains the DMA logging
operations with defaults that report no migration support.

Without a virtual IOMMU the device sees an identity mapping of guest
memory, so the tracked ranges are the guest memory regions with iova
equal to gpa. The requested page size is only a hint, so the device
reports back the granularity it actually applied.

A device that does not support migration, or one behind a virtual
IOMMU, is refused at migration start rather than silently skipping
dirty tracking and producing an incorrect log. Under a virtual IOMMU
the reported IOVAs are not guest addresses and the logged range set
would have to track the mapping changes a guest makes mid migration,
so that configuration is out of scope.

Signed-off-by: Saravanan D <saravanand@crusoe.ai>
This commit is contained in:
Saravanan D
2026-07-04 07:27:50 +00:00
committed by Bo Chen
parent 794997f241
commit c3c4281069
2 changed files with 391 additions and 4 deletions

View File

@@ -4152,6 +4152,11 @@ impl DeviceManager {
.as_ref()
.is_none_or(|p| p.vfio_p2p_dma);
let (memory_slot_allocator, guest_memory) = {
let mut mm = memory_manager.lock().unwrap();
(mm.memory_slot_allocator(), mm.guest_memory())
};
let vfio_pci_device = VfioPciDevice::new(
vfio_name.clone(),
self.address_manager.vm.clone(),
@@ -4162,7 +4167,8 @@ impl DeviceManager {
device_cfg.pci_common.iommu,
vfio_p2p_dma,
pci_device_bdf,
memory_manager.lock().unwrap().memory_slot_allocator(),
memory_slot_allocator,
guest_memory,
vm_migration::snapshot_from_id(snapshot, vfio_name.as_str()),
device_cfg.x_nv_gpudirect_clique,
device_cfg