aboutsummaryrefslogtreecommitdiffstats
path: root/vm/gce
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-11-19 10:53:39 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-11-21 09:22:22 +0100
commitc7ec2d19f82830161738378f96761b57328eed7a (patch)
tree86224fb35bf138ed6c9cd8ad3fbf47c080a8c93a /vm/gce
parent22238b0b79fc80d9a0218f8bf9ecf3e91401bd12 (diff)
vm/qemu, vm/gce: dump LOCKDEP state in Diagnose
For context see the discussion at: https://groups.google.com/g/syzkaller/c/ruwaYUvwHTw/m/E9Cg9OfvAgAJ
Diffstat (limited to 'vm/gce')
-rw-r--r--vm/gce/gce.go30
1 files changed, 20 insertions, 10 deletions
diff --git a/vm/gce/gce.go b/vm/gce/gce.go
index b5565aff0..c4cd9f184 100644
--- a/vm/gce/gce.go
+++ b/vm/gce/gce.go
@@ -20,6 +20,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "strings"
"time"
"github.com/google/syzkaller/pkg/config"
@@ -266,13 +267,7 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
sshRpipe.Close()
return nil, nil, err
}
- if inst.env.OS == targets.Linux {
- if inst.sshUser != "root" {
- command = fmt.Sprintf("sudo bash -c '%v'", command)
- }
- }
- args := append(vmimpl.SSHArgs(inst.debug, inst.sshKey, 22), inst.sshUser+"@"+inst.ip, command)
- ssh := osutil.Command("ssh", args...)
+ ssh := osutil.Command("ssh", inst.sshArgs(command)...)
ssh.Stdout = sshWpipe
ssh.Stderr = sshWpipe
if err := ssh.Start(); err != nil {
@@ -371,15 +366,30 @@ func waitForConsoleConnect(merger *vmimpl.OutputMerger) error {
}
func (inst *instance) Diagnose(rep *report.Report) ([]byte, bool) {
- if inst.env.OS == targets.FreeBSD {
+ switch inst.env.OS {
+ case targets.Linux:
+ output, wait, _ := vmimpl.DiagnoseLinux(rep, inst.ssh)
+ return output, wait
+ case targets.FreeBSD:
return vmimpl.DiagnoseFreeBSD(inst.consolew)
- }
- if inst.env.OS == targets.OpenBSD {
+ case targets.OpenBSD:
return vmimpl.DiagnoseOpenBSD(inst.consolew)
}
return nil, false
}
+func (inst *instance) ssh(args ...string) ([]byte, error) {
+ return osutil.RunCmd(time.Minute, "", "ssh", inst.sshArgs(args...)...)
+}
+
+func (inst *instance) sshArgs(args ...string) []string {
+ sshArgs := append(vmimpl.SSHArgs(inst.debug, inst.sshKey, 22), inst.sshUser+"@"+inst.ip)
+ if inst.env.OS == targets.Linux && inst.sshUser != "root" {
+ args = []string{"sudo", "bash", "-c", "'" + strings.Join(args, " ") + "'"}
+ }
+ return append(sshArgs, args...)
+}
+
func (pool *Pool) getSerialPortOutput(name, gceKey string) ([]byte, error) {
conRpipe, conWpipe, err := osutil.LongPipe()
if err != nil {