aboutsummaryrefslogtreecommitdiffstats
path: root/vm/vmimpl
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/vmimpl
parent807b51966ef368d9a1e4851d375a302f2690a9ef (diff)
vm/vmimpl/console: tail to kernel log to get serial output
Diffstat (limited to 'vm/vmimpl')
-rw-r--r--vm/vmimpl/console.go27
1 files changed, 27 insertions, 0 deletions
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()