This series RFC patches give a sample about how to enable the live migration on vfio mdev deivce with the new introduced vfio interface and vfio device status region.
In order to fulfill the migration requirement we add the following modifications to the mdev device driver. 1. Add the guest to host graphics address adjustment when guest try to access gma through mmio or graphics commands, so after migraiton the guest view of graphics address will remain the same. 2. Add handler for VFIO new ioctls to contorl the device stop/start and fetch the dirty page bitmap from device model. 3. Implement the function to save/retore the device context, which is accessed through VFIO new region VFIO_PCI_DEVICE_STATE_REGION_INDEX to transfer device status during the migration. Yulei Zhang (9): drm/i915/gvt: Apply g2h adjust for GTT mmio access drm/i915/gvt: Apply g2h adjustment during fence mmio access drm/i915/gvt: Adjust the gma parameter in gpu commands during command parser drm/i915/gvt: Retrieve the guest gm base address from PVINFO drm/i915/gvt: Align the guest gm aperture start offset for live migration drm/i915/gvt: Introduce new flag to indicate migration capability drm/i915/gvt: Introduce new VFIO ioctl for device status control drm/i915/gvt: Introduce new VFIO ioctl for mdev device dirty page sync drm/i915/gvt: Add support to VFIO region VFIO_PCI_DEVICE_STATE_REGION_INDEX drivers/gpu/drm/i915/gvt/Makefile | 2 +- drivers/gpu/drm/i915/gvt/aperture_gm.c | 6 +- drivers/gpu/drm/i915/gvt/cfg_space.c | 3 +- drivers/gpu/drm/i915/gvt/cmd_parser.c | 26 +- drivers/gpu/drm/i915/gvt/gtt.c | 19 +- drivers/gpu/drm/i915/gvt/gvt.c | 1 + drivers/gpu/drm/i915/gvt/gvt.h | 41 +- drivers/gpu/drm/i915/gvt/kvmgt.c | 65 ++- drivers/gpu/drm/i915/gvt/migrate.c | 715 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/migrate.h | 82 ++++ drivers/gpu/drm/i915/gvt/mmio.c | 14 + drivers/gpu/drm/i915/gvt/mmio.h | 1 + drivers/gpu/drm/i915/gvt/vgpu.c | 8 +- include/uapi/linux/vfio.h | 33 +- 14 files changed, 984 insertions(+), 32 deletions(-) create mode 100644 drivers/gpu/drm/i915/gvt/migrate.c create mode 100644 drivers/gpu/drm/i915/gvt/migrate.h -- 2.7.4