aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorHuizi Yang <yanghuiz@google.com>2021-08-30 11:13:23 -0700
committerAleksandr Nogikh <wp32pw@gmail.com>2021-09-10 20:57:52 +0200
commit09a90cb2789a758ff9540eda063d49f30379249b (patch)
tree97eb9cb2708ead7773c6b3e21fcc5d5c0ca279b1 /vm
parent807b51966ef368d9a1e4851d375a302f2690a9ef (diff)
vm/vmimpl/console: tail to kernel log to get serial output
Diffstat (limited to 'vm')
-rw-r--r--vm/adb/adb.go25
-rw-r--r--vm/vmimpl/console.go27
2 files changed, 28 insertions, 24 deletions
diff --git a/vm/adb/adb.go b/vm/adb/adb.go
index 19766cf18..45b0d7f2a 100644
--- a/vm/adb/adb.go
+++ b/vm/adb/adb.go
@@ -38,7 +38,6 @@ type Device struct {
type Config struct {
Adb string `json:"adb"` // adb binary name ("adb" by default)
Devices []Device `json:"devices"` // list of adb devices to use
- CvdDir string `json:"cvd_dir"` // cvd directory path of cuttlefish
// Ensure that a device battery level is at 20+% before fuzzing.
// Sometimes we observe that a device can't charge during heavy fuzzing
@@ -440,29 +439,7 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
var err error
if ok, ip := isRemoteCuttlefish(inst.device); ok {
- log.Logf(0, "running on remote cuttlefish: %v", ip)
- conRpipe, conWpipe, err := osutil.LongPipe()
- if err != nil {
- return nil, nil, err
- }
- conAddr := "vsoc-01@" + ip
- con := osutil.Command("ssh", "-t", conAddr, "screen", inst.console)
- con.Env = []string{}
- con.Stdout = conWpipe
- con.Stderr = conWpipe
- if _, err := con.StdinPipe(); err != nil {
- conRpipe.Close()
- conWpipe.Close()
- return nil, nil, err
- }
- if err := con.Start(); err != nil {
- conRpipe.Close()
- conWpipe.Close()
- return nil, nil, fmt.Errorf("failed to connect to console server: %v", err)
- }
- tty = conRpipe
- conWpipe.Close()
-
+ tty, err = vmimpl.OpenRemoteKernelLog(ip, inst.console)
} else if inst.console == "adb" {
tty, err = vmimpl.OpenAdbConsole(inst.adbBin, inst.device)
} else {
diff --git a/vm/vmimpl/console.go b/vm/vmimpl/console.go
index 8688a0b52..38314bcf5 100644
--- a/vm/vmimpl/console.go
+++ b/vm/vmimpl/console.go
@@ -76,6 +76,33 @@ func (t *tty) Close() error {
return nil
}
+func OpenRemoteKernelLog(ip string, console string) (rc io.ReadCloser, err error) {
+ rpipe, wpipe, err := osutil.LongPipe()
+ if err != nil {
+ return nil, err
+ }
+ conAddr := "vsoc-01@" + ip
+ cmd := osutil.Command("ssh", conAddr, "tail", "-f", console)
+ cmd.Stdout = wpipe
+ cmd.Stderr = wpipe
+ if _, err := cmd.StdinPipe(); err != nil {
+ rpipe.Close()
+ wpipe.Close()
+ return nil, err
+ }
+ if err := cmd.Start(); err != nil {
+ rpipe.Close()
+ wpipe.Close()
+ return nil, fmt.Errorf("failed to connect to console server: %v", err)
+ }
+ wpipe.Close()
+ con := &remoteCon{
+ cmd: cmd,
+ rpipe: rpipe,
+ }
+ return con, nil
+}
+
// Open dmesg remotely.
func OpenRemoteConsole(bin string, args ...string) (rc io.ReadCloser, err error) {
rpipe, wpipe, err := osutil.LongPipe()