aboutsummaryrefslogtreecommitdiffstats
path: root/vm/gce
diff options
context:
space:
mode:
authorGreg Steuck <blackgnezdo@gmail.com>2018-12-02 05:22:10 -0800
committerDmitry Vyukov <dvyukov@google.com>2018-12-02 13:22:10 +0000
commit7a0edfbe7c3703a0bf48f01dd818173a68a8f747 (patch)
tree90c0faa35925f3a0cfcdd376315265a6936e396f /vm/gce
parent048d09b2054f0baeea83fe2595e496c0630e845f (diff)
vm/gce: use openbsd console diagnostic code for both vmm and gce
* openbsd: use console diagnostic code for both vmm and gce. * gometalinter wants less indentation and more stuff in scope * Comment no longer applies
Diffstat (limited to 'vm/gce')
-rw-r--r--vm/gce/gce.go31
1 files changed, 20 insertions, 11 deletions
diff --git a/vm/gce/gce.go b/vm/gce/gce.go
index 44f9e5d08..4c3708ad5 100644
--- a/vm/gce/gce.go
+++ b/vm/gce/gce.go
@@ -49,16 +49,17 @@ type Pool struct {
}
type instance struct {
- env *vmimpl.Env
- cfg *Config
- GCE *gce.Context
- debug bool
- name string
- ip string
- gceKey string // per-instance private ssh key associated with the instance
- sshKey string // ssh key
- sshUser string
- closed chan bool
+ env *vmimpl.Env
+ cfg *Config
+ GCE *gce.Context
+ debug bool
+ name string
+ ip string
+ gceKey string // per-instance private ssh key associated with the instance
+ sshKey string // ssh key
+ sshUser string
+ closed chan bool
+ consolew io.WriteCloser
}
func ctor(env *vmimpl.Env) (vmimpl.Pool, error) {
@@ -189,6 +190,9 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
func (inst *instance) Close() {
close(inst.closed)
inst.GCE.DeleteInstance(inst.name, false)
+ if inst.consolew != nil {
+ inst.consolew.Close()
+ }
}
func (inst *instance) Forward(port int) (string, error) {
@@ -218,11 +222,13 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
con.Env = []string{}
con.Stdout = conWpipe
con.Stderr = conWpipe
- if _, err := con.StdinPipe(); err != nil { // SSH would close connection on stdin EOF
+ conw, err := con.StdinPipe()
+ if err != nil {
conRpipe.Close()
conWpipe.Close()
return nil, nil, err
}
+ inst.consolew = conw
if err := con.Start(); err != nil {
conRpipe.Close()
conWpipe.Close()
@@ -358,6 +364,9 @@ func waitForConsoleConnect(merger *vmimpl.OutputMerger) error {
}
func (inst *instance) Diagnose() bool {
+ if inst.env.OS == "openbsd" {
+ return vmimpl.DiagnoseOpenBSD(inst.consolew)
+ }
return false
}