aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorLaura Peskin <pesk@google.com>2024-03-13 17:51:47 -0700
committerAleksandr Nogikh <nogikh@google.com>2024-04-15 13:04:43 +0000
commit416332e39df7236896d0d13bebcc7bb13105c0a4 (patch)
tree508d429b06f8c562c0cbd6b92c3971deb7eada83 /vm
parent3aad190a2e29390065928299d214cc740e5585bb (diff)
vm/starnix: run chmod +x on executor binary after adb push
The x bit seems to get dropped now, at least when adbd is running as root. Thanks @eepeep for investigating!
Diffstat (limited to 'vm')
-rw-r--r--vm/starnix/starnix.go48
1 files changed, 45 insertions, 3 deletions
diff --git a/vm/starnix/starnix.go b/vm/starnix/starnix.go
index feb723bdc..2f5a087d3 100644
--- a/vm/starnix/starnix.go
+++ b/vm/starnix/starnix.go
@@ -326,7 +326,9 @@ func (inst *instance) Copy(hostSrc string) (string, error) {
if inst.debug {
log.Logf(1, "instance %s: attempting to push executor binary over ADB", inst.name)
}
- err := inst.runCommand(
+ output, err := osutil.RunCmd(
+ 1*time.Minute,
+ inst.fuchsiaDirectory,
"adb",
"-s",
fmt.Sprintf("127.0.0.1:%d", inst.port),
@@ -334,10 +336,17 @@ func (inst *instance) Copy(hostSrc string) (string, error) {
hostSrc,
vmDst)
if err == nil {
- return vmDst, nil
+ err = inst.Chmod(vmDst)
+ return vmDst, err
+ }
+ // Retryable connection errors usually look like "adb: error: ... : device offline"
+ // or "adb: error: ... closed"
+ if !strings.HasPrefix(string(output), "adb: error:") {
+ log.Logf(0, "instance %s: adb push failed: %s", inst.name, string(output))
+ return vmDst, err
}
if inst.debug {
- log.Logf(1, "instance %s: adb push failed", inst.name)
+ log.Logf(1, "instance %s: adb push failed: %s", inst.name, string(output))
}
if time.Since(startTime) > (inst.adbTimeout - inst.adbRetryWait) {
return vmDst, fmt.Errorf("instance %s: can't push executor binary to VM", inst.name)
@@ -346,6 +355,39 @@ func (inst *instance) Copy(hostSrc string) (string, error) {
}
}
+func (inst *instance) Chmod(vmDst string) error {
+ startTime := time.Now()
+ for {
+ if inst.debug {
+ log.Logf(1, "instance %s: attempting to chmod executor script over ADB", inst.name)
+ }
+ output, err := osutil.RunCmd(
+ 1*time.Minute,
+ inst.fuchsiaDirectory,
+ "adb",
+ "-s",
+ fmt.Sprintf("127.0.0.1:%d", inst.port),
+ "shell",
+ fmt.Sprintf("chmod +x %s", vmDst))
+ if err == nil {
+ return nil
+ }
+ // Retryable connection errors usually look like "adb: error: ... : device offline"
+ // or "adb: error: ... closed"
+ if !strings.HasPrefix(string(output), "adb: error:") {
+ log.Logf(0, "instance %s: adb shell command failed: %s", inst.name, string(output))
+ return err
+ }
+ if inst.debug {
+ log.Logf(1, "instance %s: adb shell command failed: %s", inst.name, string(output))
+ }
+ if time.Since(startTime) > (inst.adbTimeout - inst.adbRetryWait) {
+ return fmt.Errorf("instance %s: can't chmod executor script for VM", inst.name)
+ }
+ vmimpl.SleepInterruptible(inst.adbRetryWait)
+ }
+}
+
func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command string) (
<-chan []byte, <-chan error, error) {
rpipe, wpipe, err := osutil.LongPipe()