vm/vmimpl: refactor DiagnoseFree/OpenBSD

Make signatures of these functions match vm.Diagnose.
Both more flexible, less code, more reasonable.
This commit is contained in:
Dmitry Vyukov 2020-03-21 16:08:02 +01:00
parent a2d5b1c04d
commit d60b9c6b0e
5 changed files with 8 additions and 8 deletions

View File

@ -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 {

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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.