Skip to content

RFC Add a plugin to support out-of-band live migration for VFIO pass-through device

Lei Rao qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest13 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13vfio/migration: put together checks of migration initialization conditionshw/vfio/migration.c+17 -60 replies
2/13vfio/migration: move migration struct allocation out of vfio_migration_inithw/vfio/migration.c+6 -60 replies
3/13vfio/migration: move vfio_get_dev_region_info out of vfio_migration_probehw/vfio/migration.c+15 -150 replies
4/13vfio/migration: Separated functions that relate to the In-Band approachhw/vfio/migration.c+49 -150 replies
5/13vfio/migration: rename functions that relate to the In-Band approachhw/vfio/migration.c hw/vfio/trace-events+42 -380 replies
6/13vfio/migration: introduce VFIOMigrationOps layer in VFIO live migration frameworkhw/vfio/migration.c include/hw/vfio/vfio-common.h+142 -750 replies
7/13vfio/migration: move the statistics of bytes_transferred to generic VFIO migration layerhw/vfio/migration.c+2 -10 replies
8/13vfio/migration: split migration handler registering from vfio_migration_inithw/vfio/migration.c+37 -190 replies
9/13vfio/migration: move the functions of In-Band approach to a new filehw/vfio/meson.build hw/vfio/migration-local.c hw/vfio/migration.c +1 more+455 -4210 replies
10/13vfio/pci: introduce command-line parameters to specify migration methodhw/vfio/pci.c include/hw/vfio/vfio-common.h+8 -00 replies
11/13vfio/migration: add a plugin layer to support out-of-band live migrationdocs/devel/vfio-migration-plugin.rst hw/vfio/meson.build hw/vfio/migration-plugin.c +3 more+471 -30 replies
12/13vfio/migration: add some trace-events for vfio migration pluginhw/vfio/migration-plugin.c hw/vfio/trace-events+10 -30 replies
13/13vfio/migration: make the region and plugin member of struct VFIOMigration to be a unionhw/vfio/migration-local.c include/hw/vfio/vfio-common.h+22 -170 replies

Reviews trailers per patch

11 of 13 patches have a Reviewed-by or Acked-by.

PatchEddie Dong
1/13R-b
2/13
3/13
4/13R-b
5/13R-b
6/13R-b
7/13R-b
8/13R-b
9/13R-b
10/13R-b
11/13R-b
12/13R-b
13/13R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [RFC PATCH 00/13] Add a plugin to support out-of-band live migration for VFIO pass-through device

Migration of a VFIO passthrough device can be supported by using a device specific kernel driver to save/restore the device state thru device specific interfaces. But this approach doesn't work for devices that lack a state migration interface, e.g. NVMe.

On the other hand, Infrastructure Process Unit (IPU) or Data Processing Unit (DPU) vendors may choose to implement an out-of-band interface from the SoC to help manage the state of such non-migratable devices e.g. via gRPC or JSON-RPC protocols.

This RFC attempts to support such out-of-band migration interface by introducing the concept of migration backends in vfio. The existing logic around vfio migration uAPI is now called the 'local' backend while a new 'out-of-band' backend is further introduced allowing vfio to redirect VMState ops to an external plugin.

Currently, the backend migration Ops is defined close to SaveVMHandlers. We also considered whether there is value of abstracting it in a lower level e.g. close to vfio migration uAPI but no clear conclusion. Hence this is one part which we'd like to hear suggestions.

This proposal adopts a plugin mechanism (an example can be found in [1]) given that IPU/DPU vendors usually implement proprietary migration interfaces without a standard. But we are also open if an alternative option makes better sense, e.g. via loadable modules (with Qemu supporting gRPC or JSON-RPC support) or an IPC mechanism similar to vhost-user.

The following graph describes the overall component relationship:

 +----------------------------------------------------+
 | QEMU                                               |
 | +------------------------------------------------+ |
 | |        VFIO Live Migration Framework           | |
 | |    +--------------------------------------+    | |
 | |    |         VFIOMigrationOps             |    | |
 | |    +-------^---------------------^--------+    | |
 | |            |                     |             | |
 | |    +-------v-------+     +-------v--------+    | |
 | |    | LM Backend Via|     | LM Backend Via |    | |
 | |    |   Device Fd   |     |    Plugins     |    | |
 | |    +-------^-------+     |     +----------+    | |
 | |            |             |     |Plugin Ops+----+-+------------+
 | |            |             +-----+----------+    | |            |
 | |            |                                   | |  +---------v----------+
 | +------------+-----------------------------------+ |  |  Vendor Specific   |
 |              |                                     |  |    Plugins(.so)    |
 +--------------+-------------------------------------+  +----------+---------+
  UserSpace     |                                                   |
----------------+---------------------------------------------      |
  Kernel        |                                                   |
                |                                                   |
     +----------v----------------------+                            |
     |        Kernel VFIO Driver       |                            |
     |    +-------------------------+  |                            |
     |    |                         |  |                            | Network
     |    | Vendor-Specific Driver  |  |                            |
     |    |                         |  |                            |
     |    +----------^--------------+  |                            |
     |               |                 |                            |
     +---------------+-----------------+                            |
                     |                                              |
                     |                                              |
---------------------+-----------------------------------------     |
  Hardware           |                                              |
                     |            +-----+-----+-----+----+-----+    |
          +----------v------+     | VF0 | VF1 | VF2 | ...| VFn |    |
          |   Traditional   |     +-----+-----+-----+----+-----+    |
          |  PCIe Devices   |     |                            |    |
          +-----------------+     |   +--------+------------+  |    |
                                  |   |        |   Agent    |<-+----+
                                  |   |        +------------+  |
                                  |   |                     |  |
                                  |   | SOC                 |  |
                                  |   +---------------------+  |
                                  | IPU                        |
                                  +----------------------------+

Two command-line parameters (x-plugin-path and x-plugin-arg) are introduced to enable the out-of-band backend. If specified, vfio will attempt to use the out-of-band backend.

The following is an example of VFIO command-line parameters for OOB-Approach:

-device vfio-pci,id=$ID,host=$bdf,x-enable-migration,x-plugin-path=$plugin_path,x-plugin-arg=$plugin_arg

[1] https://github.com/raolei-intel/vfio-lm-plugin-example.git

Lei Rao (13):
vfio/migration: put together checks of migration initialization
conditions
vfio/migration: move migration struct allocation out of
vfio_migration_init
vfio/migration: move vfio_get_dev_region_info out of
vfio_migration_probe
vfio/migration: Separated functions that relate to the In-Band
approach
vfio/migration: rename functions that relate to the In-Band approach vfio/migration: introduce VFIOMigrationOps layer in VFIO live
migration framework
vfio/migration: move the statistics of bytes_transferred to generic
VFIO migration layer
vfio/migration: split migration handler registering from
vfio_migration_init
vfio/migration: move the functions of In-Band approach to a new file vfio/pci: introduce command-line parameters to specify migration
method
vfio/migration: add a plugin layer to support out-of-band live
migration
vfio/migration: add some trace-events for vfio migration plugin vfio/migration: make the region and plugin member of struct
VFIOMigration to be a union

 docs/devel/vfio-migration-plugin.rst    | 165 +++++++
 hw/vfio/meson.build                     |   2 +
 hw/vfio/migration-local.c               | 456 +++++++++++++++++++
 hw/vfio/migration-plugin.c              | 266 +++++++++++
 hw/vfio/migration.c                     | 577 ++++++------------------
 hw/vfio/pci.c                           |   2 +
 hw/vfio/trace-events                    |   9 +-
 include/hw/vfio/vfio-common.h           |  37 +-
 include/hw/vfio/vfio-migration-plugin.h |  21 +
 9 files changed, 1096 insertions(+), 439 deletions(-)
 create mode 100644 docs/devel/vfio-migration-plugin.rst
 create mode 100644 hw/vfio/migration-local.c
 create mode 100644 hw/vfio/migration-plugin.c
 create mode 100644 include/hw/vfio/vfio-migration-plugin.h
Signature · 1 line
2.32.0