From 1252cd55219817d09798457a023f515428397808 Mon Sep 17 00:00:00 2001 From: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> Date: Fri, 21 Aug 2026 14:01:45 -0700 Subject: [PATCH] WHP: releasing file mappings after deleting partition in Drop Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> --- .../src/hypervisor/virtual_machine/whp.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hyperlight_host/src/hypervisor/virtual_machine/whp.rs b/src/hyperlight_host/src/hypervisor/virtual_machine/whp.rs index 350607cd3..8a3448a50 100644 --- a/src/hyperlight_host/src/hypervisor/virtual_machine/whp.rs +++ b/src/hyperlight_host/src/hypervisor/virtual_machine/whp.rs @@ -1360,11 +1360,6 @@ impl WhpVm { impl Drop for WhpVm { fn drop(&mut self) { - // Clean up any remaining file mappings that weren't explicitly unmapped. - for (handle, view) in self.file_mappings.drain(..) { - release_file_mapping(view, handle); - } - // Stop the software timer thread before tearing down the partition. #[cfg(feature = "hw-interrupts")] if let Some(mut t) = self.timer.take() { @@ -1379,6 +1374,11 @@ impl Drop for WhpVm { if let Err(e) = unsafe { WHvDeletePartition(self.partition) } { tracing::error!("Failed to delete partition: {}", e); } + + // Clean up any remaining file mappings that weren't explicitly unmapped. + for (handle, view) in self.file_mappings.drain(..) { + release_file_mapping(view, handle); + } } }