Revert "[serial][botanist] Respect ctx.Cancel()."

This reverts commit ccd2b698f792b5ebeb383b3a7cff464879750611.

Reason for revert: Breaks bots in some weird instances.

Original change's description:
> [serial][botanist] Respect ctx.Cancel().
> 
> This refactors the Serial object into its own interface that extends the
> normal io.ReadWriteCloser behavior to allow cancellation during
> io.Read() so that io.Copy() may be cancelled prematurely on
> ctx.Cancel().
> 
> Change-Id: I1c3dc325cf3a02b0475a4a878ef251076b1f681c

TBR=kjharland@google.com,joshuaseaton@google.com,nmulcahey@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Iaa43ae472a554f6365b0f9095e22205feb4d357e
diff --git a/botanist/serial_device.go b/botanist/serial_device.go
deleted file mode 100644
index 9ddc626..0000000
--- a/botanist/serial_device.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2019 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package botanist
-
-import (
-	"context"
-	"io"
-
-	"fuchsia.googlesource.com/tools/serial"
-)
-
-// SerialDevice is the interface to interacting with a serial device.
-type SerialDevice struct {
-	ctx context.Context
-	io.ReadWriteCloser
-}
-
-// NewSerialDevice returns a new SerialDevice which is usable as io.ReadWriteCloser.
-func NewSerialDevice(ctx context.Context, device string) (*SerialDevice, error) {
-	s, err := serial.Open(device)
-	if err != nil {
-		return nil, err
-	}
-	return &SerialDevice{
-		ctx:             ctx,
-		ReadWriteCloser: s,
-	}, nil
-}
-
-// Read is a thin wrapper around io.Read() which respects Context.cancel() so that we may cancel an in-flight io.Copy().
-func (s *SerialDevice) Read(p []byte) (int, error) {
-	select {
-	case <-s.ctx.Done():
-		return 0, s.ctx.Err()
-	default:
-		return s.ReadWriteCloser.Read(p)
-	}
-}
diff --git a/botanist/target/device.go b/botanist/target/device.go
index ced7696..6c14c9b 100644
--- a/botanist/target/device.go
+++ b/botanist/target/device.go
@@ -9,6 +9,7 @@
 	"encoding/json"
 	"errors"
 	"fmt"
+	"io"
 	"io/ioutil"
 	"net"
 	"time"
@@ -16,8 +17,10 @@
 	"fuchsia.googlesource.com/tools/botanist"
 	"fuchsia.googlesource.com/tools/botanist/power"
 	"fuchsia.googlesource.com/tools/build"
+	"fuchsia.googlesource.com/tools/logger"
 	"fuchsia.googlesource.com/tools/netboot"
 	"fuchsia.googlesource.com/tools/netutil"
+	"fuchsia.googlesource.com/tools/serial"
 
 	"golang.org/x/crypto/ssh"
 )
@@ -71,7 +74,7 @@
 	config  DeviceConfig
 	opts    Options
 	signers []ssh.Signer
-	serial  *botanist.SerialDevice
+	serial  io.ReadWriteCloser
 }
 
 // NewDeviceTarget returns a new device target with a given configuration.
@@ -85,11 +88,14 @@
 	if err != nil {
 		return nil, fmt.Errorf("could not parse out signers from private keys: %v", err)
 	}
-	var s *botanist.SerialDevice
+	var s io.ReadWriteCloser
 	if config.Serial != "" {
-		s, err = botanist.NewSerialDevice(ctx, config.Serial)
+		s, err = serial.Open(config.Serial)
 		if err != nil {
-			return nil, err
+			// TODO(IN-????): This should be returned as an error, but we don't want to fail any
+			// test runs for misconfigured serial until it is actually required to complete certain
+			// tasks.
+			logger.Errorf(ctx, "unable to open %s: %v", config.Serial, err)
 		}
 	}
 	return &DeviceTarget{
@@ -115,7 +121,7 @@
 }
 
 // Serial returns the serial device associated with the target for serial i/o.
-func (t *DeviceTarget) Serial() *botanist.SerialDevice {
+func (t *DeviceTarget) Serial() io.ReadWriteCloser {
 	return t.serial
 }
 
diff --git a/botanist/target/qemu.go b/botanist/target/qemu.go
index a71e1d9..a9faf9b 100644
--- a/botanist/target/qemu.go
+++ b/botanist/target/qemu.go
@@ -15,7 +15,6 @@
 	"os/exec"
 	"path/filepath"
 
-	"fuchsia.googlesource.com/tools/botanist"
 	"fuchsia.googlesource.com/tools/build"
 	"fuchsia.googlesource.com/tools/qemu"
 )
@@ -105,7 +104,7 @@
 }
 
 // Serial returns the serial device associated with the target for serial i/o.
-func (t *QEMUTarget) Serial() *botanist.SerialDevice {
+func (t *QEMUTarget) Serial() io.ReadWriteCloser {
 	return nil
 }
 
diff --git a/cmd/botanist/run.go b/cmd/botanist/run.go
index 7c33917..60a425d 100644
--- a/cmd/botanist/run.go
+++ b/cmd/botanist/run.go
@@ -38,7 +38,7 @@
 	IPv4Addr() (net.IP, error)
 
 	// Serial returns the serial device associated with the target for serial i/o.
-	Serial() *botanist.SerialDevice
+	Serial() io.ReadWriteCloser
 
 	// SSHKey returns the private key corresponding an authorized SSH key of the target.
 	SSHKey() string
@@ -200,8 +200,8 @@
 	}
 
 	opts := target.Options{
-		Netboot: r.netboot,
-		SSHKey:  r.sshKey,
+		Netboot:  r.netboot,
+		SSHKey:   r.sshKey,
 	}
 
 	data, err := ioutil.ReadFile(r.configFile)
@@ -253,12 +253,9 @@
 
 			go func() {
 				_, err := io.Copy(serialLog, t.Serial())
-				if err != nil && err != context.Canceled {
+				if err != nil {
 					logger.Errorf(ctx, "failed to write serial log: %v", err)
 				}
-				if err := serialLog.Sync(); err != nil {
-					logger.Errorf(ctx, "failed to fsync serial log: %v", err)
-				}
 			}()
 			r.zirconArgs = append(r.zirconArgs, "kernel.bypass-debuglog=true")
 		}