cmd/buildet: allow halt of macOS QEMU VMs
Upcoming QEMU-based builders can shutdown in the same manner as
macstadium VMs.
For golang/go#48945.
Change-Id: I56cf8389c542b6a52773d333ed48a585b0b9c64b
Reviewed-on: https://go-review.googlesource.com/c/build/+/432115
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/cmd/buildlet/buildlet.go b/cmd/buildlet/buildlet.go
index 24bfa0d..35009c5 100644
--- a/cmd/buildlet/buildlet.go
+++ b/cmd/buildlet/buildlet.go
@@ -1221,10 +1221,11 @@
case "plan9":
err = exec.Command("fshalt").Run()
case "darwin":
- if os.Getenv("GO_BUILDER_ENV") == "macstadium_vm" {
+ switch os.Getenv("GO_BUILDER_ENV") {
+ case "macstadium_vm", "qemu_vm":
// Fast, sloppy, unsafe, because we're never reusing this VM again.
err = exec.Command("/usr/bin/sudo", "/sbin/halt", "-n", "-q", "-l").Run()
- } else {
+ default:
err = errors.New("not respecting -halt flag on macOS in unknown environment")
}
case "windows":