mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-02 11:35:46 +00:00
vmm: Remove virtio device's userspace mapping on hot-unplug
When a virtio device is dynamically removed from the VM through the hot-unplug mechanism, every mapping associated with it must be properly removed. Based on the previous patches letting a VirtioDevice expose the list of userspace mappings associated with it, this patch can now remove all the KVM userspace memory regions through the MemoryManager. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
0a97c25464
commit
c22fd39170
@ -2209,7 +2209,22 @@ impl DeviceManager {
|
|||||||
|
|
||||||
// Shutdown and remove the underlying virtio-device if present
|
// Shutdown and remove the underlying virtio-device if present
|
||||||
if let Some(virtio_device) = virtio_device {
|
if let Some(virtio_device) = virtio_device {
|
||||||
|
for mapping in virtio_device.lock().unwrap().userspace_mappings() {
|
||||||
|
self.memory_manager
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.remove_userspace_mapping(
|
||||||
|
mapping.addr.raw_value(),
|
||||||
|
mapping.len,
|
||||||
|
mapping.host_addr,
|
||||||
|
mapping.mergeable,
|
||||||
|
mapping.mem_slot,
|
||||||
|
)
|
||||||
|
.map_err(DeviceManagerError::MemoryManager)?;
|
||||||
|
}
|
||||||
|
|
||||||
virtio_device.lock().unwrap().shutdown();
|
virtio_device.lock().unwrap().shutdown();
|
||||||
|
|
||||||
self.virtio_devices
|
self.virtio_devices
|
||||||
.retain(|(d, _, _)| !Arc::ptr_eq(d, &virtio_device));
|
.retain(|(d, _, _)| !Arc::ptr_eq(d, &virtio_device));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user