virtio-devices, vmm: Always restore virtio devices in paused state

Following the new restore design, it is not appropriate to set every
virtio device threads into a paused state after they've been started.

This is why we remove the line of code pausing the devices only after
they've been restored, and replace it with a small patch in every virtio
device implementation. When a virtio device is created as part of a
restored VM, the associated "paused" boolean is set to true. This
ensures the corresponding thread will be directly parked when being
started, avoiding the thread to be in a different state than the one it
was on the source VM during the snapshot.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2022-11-30 17:10:04 +01:00
parent 8f1e03fcf4
commit b62a40efae
15 changed files with 400 additions and 332 deletions

View File

@@ -348,16 +348,16 @@ where
exit_evt: EventFd,
state: Option<VsockState>,
) -> io::Result<Vsock<B>> {
let (avail_features, acked_features) = if let Some(state) = state {
let (avail_features, acked_features, paused) = if let Some(state) = state {
info!("Restoring virtio-vsock {}", id);
(state.avail_features, state.acked_features)
(state.avail_features, state.acked_features, true)
} else {
let mut avail_features = 1u64 << VIRTIO_F_VERSION_1 | 1u64 << VIRTIO_F_IN_ORDER;
if iommu {
avail_features |= 1u64 << VIRTIO_F_IOMMU_PLATFORM;
}
(avail_features, 0)
(avail_features, 0, false)
};
Ok(Vsock {
@@ -368,6 +368,7 @@ where
paused_sync: Some(Arc::new(Barrier::new(2))),
queue_sizes: QUEUE_SIZES.to_vec(),
min_queues: NUM_QUEUES as u16,
paused: Arc::new(AtomicBool::new(paused)),
..Default::default()
},
id,