File tree 2 files changed +11
-3
lines changed
bin/propolis-server/src/lib/vm
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -872,12 +872,15 @@ impl VmController {
872
872
impl Drop for VmController {
873
873
fn drop ( & mut self ) {
874
874
info ! ( self . log, "Dropping VM controller" ) ;
875
- let instance = self
875
+ let machine = self
876
876
. vm_objects
877
877
. machine
878
878
. take ( )
879
879
. 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 ( ) ;
881
884
882
885
// A fully-initialized controller is kept alive in part by its worker
883
886
// thread, which owns the sender side of the controller's state-change
Original file line number Diff line number Diff line change @@ -96,7 +96,12 @@ impl Machine {
96
96
}
97
97
impl Drop for Machine {
98
98
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
+ }
100
105
}
101
106
}
102
107
You can’t perform that action at this time.
0 commit comments