From 9f247751e7ff5f8689230094883a6d485a10ab83 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Tue, 21 May 2019 17:43:03 +0200 Subject: [PATCH] vm-allocator: Allow for freeing system resources We allow freeing PIO and MMIO address ranges for now. Fixes: #27 Signed-off-by: Samuel Ortiz --- vm-allocator/src/system.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vm-allocator/src/system.rs b/vm-allocator/src/system.rs index e074957ea..0c6cdacf1 100755 --- a/vm-allocator/src/system.rs +++ b/vm-allocator/src/system.rs @@ -100,4 +100,18 @@ impl SystemAllocator { ) -> Option { self.mmio_address_space.allocate(address, size) } + + /// Free an IO address range. + /// We can only free a range if it matches exactly an already allocated range. + pub fn free_io_addresses(&mut self, address: GuestAddress, size: GuestUsize) { + if let Some(io_address) = self.io_address_space.as_mut() { + io_address.free(address, size) + } + } + + /// Free an MMIO address range. + /// We can only free a range if it matches exactly an already allocated range. + pub fn free_mmio_addresses(&mut self, address: GuestAddress, size: GuestUsize) { + self.mmio_address_space.free(address, size) + } }