vmm: virtio-devices: Restore every VirtioDevice upon creation

Following the new design proposal to improve the restore codepath when
migrating a VM, all virtio devices are supplied with an optional state
they can use to restore from. The restore() implementation every device
was providing has been removed in order to prevent from going through
the restoration twice.

Here is the list of devices now following the new restore design:

- Block (virtio-block)
- Net (virtio-net)
- Rng (virtio-rng)
- Fs (vhost-user-fs)
- Blk (vhost-user-block)
- Net (vhost-user-net)
- Pmem (virtio-pmem)
- Vsock (virtio-vsock)
- Mem (virtio-mem)
- Balloon (virtio-balloon)
- Watchdog (virtio-watchdog)
- Vdpa (vDPA)
- Console (virtio-console)
- Iommu (virtio-iommu)

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2022-10-18 17:14:43 +02:00
parent 157db33d65
commit 1f0e5eb66a
26 changed files with 716 additions and 699 deletions

View File

@@ -236,6 +236,23 @@ impl Snapshot {
}
}
pub fn snapshot_from_id(snapshot: Option<&Snapshot>, id: &str) -> Option<Snapshot> {
snapshot.and_then(|s| s.snapshots.get(id).map(|s| *s.clone()))
}
pub fn versioned_state_from_id<T>(
snapshot: Option<&Snapshot>,
id: &str,
) -> Result<Option<T>, MigratableError>
where
T: Versionize + VersionMapped,
{
snapshot
.and_then(|s| s.snapshots.get(id).map(|s| *s.clone()))
.map(|s| s.to_versioned_state(id))
.transpose()
}
/// A snapshottable component can be snapshotted.
pub trait Snapshottable: Pausable {
/// The snapshottable component id.