Skip to content

Commit 98db989

Browse files
committed
cmd/runqemubuildlet: run as root on darwin
QEMU needs to run as root on darwin for working networking. Currently we run runqemubuildlet as a normal user, and invoke QEMU with `sudo`. Unfortunately, this means that runqemubuildlet doesn't have permission to signal QEMU when the health check fails. Instead, run runqemubuildlet as root so it has permission to signal QEMU. For golang/go#48945. Change-Id: I07bd61168462c7272db05c328eb11dcd39743f79 Reviewed-on: https://go-review.googlesource.com/c/build/+/456042 Reviewed-by: Heschi Kreinick <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Michael Pratt <[email protected]>
1 parent 61e6a7f commit 98db989

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

cmd/runqemubuildlet/darwin.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ func darwinCmd(base string) *exec.Cmd {
4343

4444
disk := filepath.Join(base, "macos.qcow2")
4545

46-
// vmnet-shared requires that we run QEMU as root.
46+
// Note that vmnet-shared requires that we run QEMU as root, so
47+
// runqemubuildlet must run as root.
4748
//
4849
// These arguments should be kept in sync with env/darwin/aws/qemu.sh.
4950
args := []string{
50-
"env",
51-
fmt.Sprintf("DYLD_LIBRARY_PATH=%s", filepath.Join(sysroot, "lib")),
52-
filepath.Join(sysroot, "bin/qemu-system-x86_64"),
5351
// Discard disk changes on exit.
5452
"-snapshot",
5553
"-m", "4096",
@@ -86,6 +84,9 @@ func darwinCmd(base string) *exec.Cmd {
8684
args = append(args, "-device", fmt.Sprintf("vmxnet3,netdev=net0,id=net0,mac=52:54:00:c9:18:0%d", *guestIndex))
8785
}
8886

89-
cmd := exec.Command("sudo", args...)
87+
cmd := exec.Command(filepath.Join(sysroot, "bin/qemu-system-x86_64"), args...)
88+
cmd.Env = append(os.Environ(),
89+
fmt.Sprintf("DYLD_LIBRARY_PATH=%s", filepath.Join(sysroot, "lib")),
90+
)
9091
return cmd
9192
}

cmd/runqemubuildlet/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func main() {
5656
}
5757

5858
if err := runGuest(ctx, cmd); err != nil {
59-
log.Printf("runWindows10() = %v. Retrying in 10 seconds.", err)
59+
log.Printf("runGuest() = %v. Retrying in 10 seconds.", err)
6060
time.Sleep(10 * time.Second)
6161
continue
6262
}

env/darwin/aws/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ builders.
153153

154154
while true; do
155155
echo "Running QEMU..."
156-
$HOME/runqemubuildlet -guest-os=darwin -macos-version=${MACOS_VERSION?} -osk=${OSK_VALUE?} -guest-index=1 -buildlet-healthz-url="http://192.168.64.101:8080/healthz"
156+
sudo $HOME/runqemubuildlet -guest-os=darwin -macos-version=${MACOS_VERSION?} -osk=${OSK_VALUE?} -guest-index=1 -buildlet-healthz-url="http://192.168.64.101:8080/healthz"
157157
done
158158
```
159159

@@ -164,7 +164,7 @@ done
164164

165165
while true; do
166166
echo "Running QEMU..."
167-
$HOME/runqemubuildlet -guest-os=darwin -macos-version=${MACOS_VERSION?} -osk=${OSK_VALUE?} -guest-index=2 -buildlet-healthz-url="http://192.168.64.102:8080/healthz"
167+
sudo $HOME/runqemubuildlet -guest-os=darwin -macos-version=${MACOS_VERSION?} -osk=${OSK_VALUE?} -guest-index=2 -buildlet-healthz-url="http://192.168.64.102:8080/healthz"
168168
done
169169
```
170170

0 commit comments

Comments
 (0)