Skip to content

Commit 4e79f93

Browse files
committed
home: kill non-responsive VMs with second stop
If force stop fails, press stop button again for a kill.
1 parent aa27f6f commit 4e79f93

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Platform/iOS/UTMDataExtension.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ extension UTMData {
4545
if wrapped.registryEntry.isSuspended {
4646
wrapped.requestVmDeleteState()
4747
}
48-
wrapped.requestVmStop()
48+
if wrapped.state == .started || wrapped.state == .paused {
49+
wrapped.requestVmStop()
50+
} else {
51+
wrapped.requestVmStop(force: true)
52+
}
4953
}
5054

5155
func close(vm: VMData) {

Platform/macOS/Display/VMDisplayWindowController.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,13 @@ class VMDisplayWindowController: NSWindowController, UTMVirtualMachineDelegate {
110110
self.vm.requestVmStop(force: isKill)
111111
}
112112
}
113-
113+
114114
@IBAction func stopButtonPressed(_ sender: Any) {
115-
stop(isKill: false)
115+
if vm.state == .started || vm.state == .paused {
116+
stop(isKill: false)
117+
} else {
118+
stop(isKill: true)
119+
}
116120
}
117121

118122
@IBAction func startPauseButtonPressed(_ sender: Any) {

Platform/macOS/UTMDataExtension.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ extension UTMData {
115115
if wrapped.registryEntry.isSuspended {
116116
try? await wrapped.deleteSnapshot(name: nil)
117117
}
118-
try? await wrapped.stop(usingMethod: .force)
118+
if vm.state == .started || vm.state == .paused {
119+
try? await wrapped.stop(usingMethod: .force)
120+
} else {
121+
try? await wrapped.stop(usingMethod: .kill)
122+
}
119123
await MainActor.run {
120124
self.close(vm: vm)
121125
}

0 commit comments

Comments
 (0)