Revert "[botanist] Expose a socket to proxy serial I/O"
This reverts commit 0a415e513e94d6025efa9893c71897eb3126e465.
Reason for revert: QEMU is mysteriously hanging
Original change's description:
> [botanist] Expose a socket to proxy serial I/O
>
> Bug: 41930
> Bug: 41377
>
> Test: CQ consumes botanist from source.
>
> Change-Id: Ice609af336852143fa9bc4e129c7310c6bba51da
TBR=phosek@google.com,garymm@google.com,joshuaseaton@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: 41930, 41377
Change-Id: Ic34653843105ca516373a9728d9933ddeaf7c93f
diff --git a/tools/botanist/botanist.go b/tools/botanist/botanist.go
deleted file mode 100644
index 016eea1c..0000000
--- a/tools/botanist/botanist.go
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2019 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can
-// found in the LICENSE file.
-
-package botanist
-
-const (
- // SerialLogBufferSize gives the amount of data to buffer when doing serial
- // I/O.
- // The size of the serial log of an entire test run is on the order of 1MB;
- // accordingly, we allow a buffer size of an order of magnitude less for
- // conservative estimate.
- SerialLogBufferSize = (1000 * 1000) / 10
-)
diff --git a/tools/botanist/cmd/run.go b/tools/botanist/cmd/run.go
index 13f784f..eb54c46 100644
--- a/tools/botanist/cmd/run.go
+++ b/tools/botanist/cmd/run.go
@@ -5,8 +5,6 @@
import (
"context"
- "crypto/rand"
- "encoding/hex"
"encoding/json"
"flag"
"fmt"
@@ -14,19 +12,16 @@
"io/ioutil"
"net"
"os"
- "path/filepath"
"sync"
"time"
"go.fuchsia.dev/fuchsia/tools/bootserver/lib"
- "go.fuchsia.dev/fuchsia/tools/botanist/lib"
"go.fuchsia.dev/fuchsia/tools/botanist/target"
"go.fuchsia.dev/fuchsia/tools/lib/command"
"go.fuchsia.dev/fuchsia/tools/lib/logger"
"go.fuchsia.dev/fuchsia/tools/lib/runner"
"go.fuchsia.dev/fuchsia/tools/lib/syslog"
"go.fuchsia.dev/fuchsia/tools/net/sshutil"
- "go.fuchsia.dev/fuchsia/tools/serial"
"github.com/google/subcommands"
)
@@ -175,40 +170,22 @@
errs := make(chan error)
- var socketPath string
- if t0.Serial() != nil {
+ serial := t0.Serial()
+ if serial != nil && r.serialLogFile != "" {
// Modify the zirconArgs passed to the kernel on boot to enable serial on x64.
// arm64 devices should already be enabling kernel.serial at compile time.
r.zirconArgs = append(r.zirconArgs, "kernel.serial=legacy")
// Force serial output to the console instead of buffering it.
r.zirconArgs = append(r.zirconArgs, "kernel.bypass-debuglog=true")
- sOpts := serial.ServerOptions{
- WriteBufferSize: botanist.SerialLogBufferSize,
- }
- if r.serialLogFile != "" {
- serialLog, err := os.Create(r.serialLogFile)
- if err != nil {
- return err
- }
- defer serialLog.Close()
- sOpts.AuxiliaryOutput = serialLog
- }
-
- s := serial.NewServer(t0.Serial(), sOpts)
- socketPath = createSocketPath()
- addr := &net.UnixAddr{Name: socketPath, Net: "unix"}
- l, err := net.ListenUnix("unix", addr)
+ serialLog, err := os.Create(r.serialLogFile)
if err != nil {
return err
}
- defer l.Close()
- ctx, cancel := context.WithCancel(ctx)
- defer cancel()
+ defer serialLog.Close()
go func() {
- if err := s.Run(ctx, l); err != nil {
- errs <- err
- return
+ if _, err := io.Copy(serialLog, serial); err != nil {
+ errs <- fmt.Errorf("failed to write serial log: %v", err)
}
}()
}
@@ -250,7 +227,7 @@
}
go func() {
wg.Wait()
- errs <- r.runAgainstTarget(ctx, t0, args, socketPath)
+ errs <- r.runAgainstTarget(ctx, t0, args)
}()
select {
@@ -261,10 +238,9 @@
return nil
}
-func (r *RunCommand) runAgainstTarget(ctx context.Context, t Target, args []string, socketPath string) error {
+func (r *RunCommand) runAgainstTarget(ctx context.Context, t Target, args []string) error {
subprocessEnv := map[string]string{
- "FUCHSIA_NODENAME": t.Nodename(),
- "FUCHSIA_SERIAL_SOCKET": socketPath,
+ "FUCHSIA_NODENAME": t.Nodename(),
}
// If |netboot| is true, then we assume that fuchsia is not provisioned
@@ -345,13 +321,6 @@
return subcommands.ExitSuccess
}
-func createSocketPath() string {
- // We randomly construct a socket path that is highly improbable to collide with anything.
- randBytes := make([]byte, 16)
- rand.Read(randBytes)
- return filepath.Join(os.TempDir(), "serial"+hex.EncodeToString(randBytes)+".sock")
-}
-
func deriveTarget(ctx context.Context, obj []byte, opts target.Options) (Target, error) {
type typed struct {
Type string `json:"type"`