vmm, virtio: pmem: Move freeing of mappped region into device

Move the release of the managed memory region from the DeviceManager to
the virtio-pmem device. This ensures that the memory will be freed when
the device is unplugged which will lead to it being Drop()ed.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2020-04-14 15:47:11 +01:00
parent 6565e478e6
commit 0c6706a510
2 changed files with 14 additions and 6 deletions
+1 -3
View File
@@ -1467,8 +1467,6 @@ impl DeviceManager {
.map_err(DeviceManagerError::NewMmapRegion)?;
let addr: u64 = mmap_region.as_ptr() as u64;
self._mmap_regions.push(mmap_region);
self.memory_manager
.lock()
.unwrap()
@@ -1482,7 +1480,7 @@ impl DeviceManager {
.map_err(DeviceManagerError::MemoryManager)?;
let virtio_pmem_device = Arc::new(Mutex::new(
vm_virtio::Pmem::new(file, pmem_guest_addr, size as GuestUsize, pmem_cfg.iommu)
vm_virtio::Pmem::new(file, pmem_guest_addr, mmap_region, pmem_cfg.iommu)
.map_err(DeviceManagerError::CreateVirtioPmem)?,
));