mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
+30
-27
@@ -879,34 +879,36 @@ impl Iommu {
|
||||
msi_iova_space: (u64, u64),
|
||||
state: Option<IommuState>,
|
||||
) -> io::Result<(Self, Arc<IommuMapping>)> {
|
||||
let (avail_features, acked_features, endpoints, domains) = if let Some(state) = state {
|
||||
info!("Restoring virtio-iommu {}", id);
|
||||
(
|
||||
state.avail_features,
|
||||
state.acked_features,
|
||||
state.endpoints.into_iter().collect(),
|
||||
state
|
||||
.domains
|
||||
.into_iter()
|
||||
.map(|(k, v)| {
|
||||
(
|
||||
k,
|
||||
Domain {
|
||||
mappings: v.0.into_iter().collect(),
|
||||
bypass: v.1,
|
||||
},
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
} else {
|
||||
let avail_features = 1u64 << VIRTIO_F_VERSION_1
|
||||
| 1u64 << VIRTIO_IOMMU_F_MAP_UNMAP
|
||||
| 1u64 << VIRTIO_IOMMU_F_PROBE
|
||||
| 1u64 << VIRTIO_IOMMU_F_BYPASS_CONFIG;
|
||||
let (avail_features, acked_features, endpoints, domains, paused) =
|
||||
if let Some(state) = state {
|
||||
info!("Restoring virtio-iommu {}", id);
|
||||
(
|
||||
state.avail_features,
|
||||
state.acked_features,
|
||||
state.endpoints.into_iter().collect(),
|
||||
state
|
||||
.domains
|
||||
.into_iter()
|
||||
.map(|(k, v)| {
|
||||
(
|
||||
k,
|
||||
Domain {
|
||||
mappings: v.0.into_iter().collect(),
|
||||
bypass: v.1,
|
||||
},
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
true,
|
||||
)
|
||||
} else {
|
||||
let avail_features = 1u64 << VIRTIO_F_VERSION_1
|
||||
| 1u64 << VIRTIO_IOMMU_F_MAP_UNMAP
|
||||
| 1u64 << VIRTIO_IOMMU_F_PROBE
|
||||
| 1u64 << VIRTIO_IOMMU_F_BYPASS_CONFIG;
|
||||
|
||||
(avail_features, 0, BTreeMap::new(), BTreeMap::new())
|
||||
};
|
||||
(avail_features, 0, BTreeMap::new(), BTreeMap::new(), false)
|
||||
};
|
||||
|
||||
let config = VirtioIommuConfig {
|
||||
page_size_mask: VIRTIO_IOMMU_PAGE_SIZE_MASK,
|
||||
@@ -930,6 +932,7 @@ impl Iommu {
|
||||
acked_features,
|
||||
paused_sync: Some(Arc::new(Barrier::new(2))),
|
||||
min_queues: NUM_QUEUES as u16,
|
||||
paused: Arc::new(AtomicBool::new(paused)),
|
||||
..Default::default()
|
||||
},
|
||||
config,
|
||||
|
||||
Reference in New Issue
Block a user