mirror of https://github.com/cirruslabs/tart.git
Support stopping of suspended VMs (#541)
This commit is contained in:
parent
d2ed4ef801
commit
e8dbb86fc0
|
|
@ -14,6 +14,21 @@ struct Stop: AsyncParsableCommand {
|
|||
|
||||
func run() async throws {
|
||||
let vmDir = try VMStorageLocal().open(name)
|
||||
switch try vmDir.state() {
|
||||
case "suspended":
|
||||
try stopSuspended(vmDir)
|
||||
case "running":
|
||||
try await stopRunning(vmDir)
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func stopSuspended(_ vmDir: VMDirectory) throws {
|
||||
try? FileManager.default.removeItem(at: vmDir.stateURL)
|
||||
}
|
||||
|
||||
func stopRunning(_ vmDir: VMDirectory) async throws {
|
||||
let lock = try PIDLock(lockURL: vmDir.configURL)
|
||||
|
||||
// Find the VM's PID
|
||||
|
|
|
|||
Loading…
Reference in New Issue