Skip to content

Commit 19d9eb3

Browse files
committed
Clean up VMM resource on server shutdown
After the integration of #639, the CI tests report lingering VMM resources after conclusion of the run.
1 parent 760039e commit 19d9eb3

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

bin/propolis-server/src/lib/vm/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -872,12 +872,15 @@ impl VmController {
872872
impl Drop for VmController {
873873
fn drop(&mut self) {
874874
info!(self.log, "Dropping VM controller");
875-
let instance = self
875+
let machine = self
876876
.vm_objects
877877
.machine
878878
.take()
879879
.expect("VM controller should have an instance at drop");
880-
drop(instance);
880+
881+
// Destroy the underlying kernel VMM resource
882+
let hdl = machine.destroy();
883+
let _ = hdl.destroy();
881884

882885
// A fully-initialized controller is kept alive in part by its worker
883886
// thread, which owns the sender side of the controller's state-change

lib/propolis/src/vmm/machine.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ impl Machine {
9696
}
9797
impl Drop for Machine {
9898
fn drop(&mut self) {
99-
let _ = self.do_destroy();
99+
// If consumer has not opted to own the fate of the contained VmmHdl
100+
// through an explicit call to Machine::destroy(), then clean up the
101+
// kernel VMM resource backing it automatically.
102+
if let Some(hdl) = self.do_destroy() {
103+
let _ = hdl.destroy();
104+
}
100105
}
101106
}
102107

0 commit comments

Comments
 (0)