virtio-devices, vmm: vdpa: Implement live migration support

Vdpa now implements the Migratable trait, which allows the device to be
added to the DeviceTree and therefore allows live migrating any vDPA
device that supports being suspended.

Given a vDPA device can't be resumed from a suspended state without
having to reset everything, we don't support pause/resume for a vDPA
device, as well as snapshot/restore (which requires resume to be
supported).

In order for the migration to work locally, reusing the same device on
the same host machine, the vhost-vdpa handler is dropped after the
snapshot has been performed, which allows the destination VM to open the
device without any conflict about the device being busy.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2022-10-12 11:23:16 +02:00
parent 340fd6571a
commit 099cdd2af8
2 changed files with 205 additions and 4 deletions

View File

@@ -2852,6 +2852,7 @@ impl DeviceManager {
device_path,
self.memory_manager.lock().unwrap().guest_memory(),
vdpa_cfg.num_queues as u16,
self.restoring,
)
.map_err(DeviceManagerError::CreateVdpa)?,
));
@@ -2865,7 +2866,7 @@ impl DeviceManager {
self.device_tree
.lock()
.unwrap()
.insert(id.clone(), device_node!(id));
.insert(id.clone(), device_node!(id, vdpa_device));
Ok(MetaVirtioDevice {
virtio_device: vdpa_device as Arc<Mutex<dyn virtio_devices::VirtioDevice>>,