aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-03-21 16:08:02 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-03-21 16:08:02 +0100
commitd60b9c6b0ec77c5d458a17467f1b4939cc2f6812 (patch)
treecfc0a0b8ada856f1150d73700645e0e61c72ff74
parenta2d5b1c04d22c7db220cc795dc2b4d48b17437be (diff)
vm/vmimpl: refactor DiagnoseFree/OpenBSD
Make signatures of these functions match vm.Diagnose. Both more flexible, less code, more reasonable.
-rw-r--r--vm/bhyve/bhyve.go2
-rw-r--r--vm/gce/gce.go4
-rw-r--r--vm/vmimpl/freebsd.go4
-rw-r--r--vm/vmimpl/openbsd.go4
-rw-r--r--vm/vmm/vmm.go2
5 files changed, 8 insertions, 8 deletions
diff --git a/vm/bhyve/bhyve.go b/vm/bhyve/bhyve.go
index 0000e2c27..810ad4241 100644
--- a/vm/bhyve/bhyve.go
+++ b/vm/bhyve/bhyve.go
@@ -346,7 +346,7 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
}
func (inst *instance) Diagnose() ([]byte, bool) {
- return nil, vmimpl.DiagnoseFreeBSD(inst.consolew)
+ return vmimpl.DiagnoseFreeBSD(inst.consolew)
}
func parseIP(output []byte) string {
diff --git a/vm/gce/gce.go b/vm/gce/gce.go
index 98ab494dd..097bcd707 100644
--- a/vm/gce/gce.go
+++ b/vm/gce/gce.go
@@ -371,10 +371,10 @@ func waitForConsoleConnect(merger *vmimpl.OutputMerger) error {
func (inst *instance) Diagnose() ([]byte, bool) {
if inst.env.OS == "freebsd" {
- return nil, vmimpl.DiagnoseFreeBSD(inst.consolew)
+ return vmimpl.DiagnoseFreeBSD(inst.consolew)
}
if inst.env.OS == "openbsd" {
- return nil, vmimpl.DiagnoseOpenBSD(inst.consolew)
+ return vmimpl.DiagnoseOpenBSD(inst.consolew)
}
return nil, false
}
diff --git a/vm/vmimpl/freebsd.go b/vm/vmimpl/freebsd.go
index c6074028a..f2ebfba56 100644
--- a/vm/vmimpl/freebsd.go
+++ b/vm/vmimpl/freebsd.go
@@ -12,7 +12,7 @@ import (
// is expected to be connected to a panicked FreeBSD kernel. If kernel
// just hanged, we've lost connection or detected some non-panic
// error, console still shows normal login prompt.
-func DiagnoseFreeBSD(w io.Writer) bool {
+func DiagnoseFreeBSD(w io.Writer) ([]byte, bool) {
commands := []string{
"",
"set $lines = 0", // disable pagination
@@ -28,5 +28,5 @@ func DiagnoseFreeBSD(w io.Writer) bool {
w.Write([]byte(c + "\n"))
time.Sleep(1 * time.Second)
}
- return true
+ return nil, true
}
diff --git a/vm/vmimpl/openbsd.go b/vm/vmimpl/openbsd.go
index 5e5ce3d3f..73460cb80 100644
--- a/vm/vmimpl/openbsd.go
+++ b/vm/vmimpl/openbsd.go
@@ -12,7 +12,7 @@ import (
// is expected to be connected to a paniced openbsd kernel. If kernel
// just hanged, we've lost connection or detected some non-panic
// error, console still shows normal login prompt.
-func DiagnoseOpenBSD(w io.Writer) bool {
+func DiagnoseOpenBSD(w io.Writer) ([]byte, bool) {
commands := []string{
"",
"set $lines = 0", // disable pagination
@@ -30,5 +30,5 @@ func DiagnoseOpenBSD(w io.Writer) bool {
w.Write([]byte(c + "\n"))
time.Sleep(1 * time.Second)
}
- return true
+ return nil, true
}
diff --git a/vm/vmm/vmm.go b/vm/vmm/vmm.go
index f3b5fc457..62908de1f 100644
--- a/vm/vmm/vmm.go
+++ b/vm/vmm/vmm.go
@@ -311,7 +311,7 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin
}
func (inst *instance) Diagnose() ([]byte, bool) {
- return nil, vmimpl.DiagnoseOpenBSD(inst.consolew)
+ return vmimpl.DiagnoseOpenBSD(inst.consolew)
}
// Run the given vmctl(8) command and wait for it to finish.