diff options
author | Fabricio Voznika <fvoznika@google.com> | 2019-04-11 17:53:24 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-04-11 17:54:34 -0700 |
commit | 546a1df7d15fd80f510d4203c5f9255bba4b4211 (patch) | |
tree | fd65630e6685d2952e6fc079bb81289d213ed728 /runsc/main.go | |
parent | 6b24f7ab0863004a30c2f1aff88440fbb4cf3b3c (diff) |
Add 'runsc do' command
It provides an easy way to run commands to quickly test gVisor.
By default it maps the host root as the container root with a
writable overlay on top (so the host root is not modified).
Example:
sudo runsc do ls -lh --color
sudo runsc do ~/src/test/my-test.sh
PiperOrigin-RevId: 243178711
Change-Id: I05f3d6ce253fe4b5f1362f4a07b5387f6ddb5dd9
Diffstat (limited to 'runsc/main.go')
-rw-r--r-- | runsc/main.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/runsc/main.go b/runsc/main.go index bbf08228c..74253a844 100644 --- a/runsc/main.go +++ b/runsc/main.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "io" + "io/ioutil" "os" "path/filepath" "strings" @@ -80,6 +81,7 @@ func main() { subcommands.Register(new(cmd.Checkpoint), "") subcommands.Register(new(cmd.Create), "") subcommands.Register(new(cmd.Delete), "") + subcommands.Register(new(cmd.Do), "") subcommands.Register(new(cmd.Events), "") subcommands.Register(new(cmd.Exec), "") subcommands.Register(new(cmd.Gofer), "") @@ -168,6 +170,8 @@ func main() { log.SetLevel(log.Debug) } + subcommand := flag.CommandLine.Arg(0) + var logFile io.Writer = os.Stderr if *logFD > -1 { logFile = os.NewFile(uintptr(*logFD), "log file") @@ -180,11 +184,12 @@ func main() { cmd.Fatalf("error opening log file %q: %v", *logFilename, err) } logFile = f + } else if subcommand == "do" { + logFile = ioutil.Discard } e := newEmitter(*logFormat, logFile) - subcommand := flag.CommandLine.Arg(0) if *debugLogFD > -1 { f := os.NewFile(uintptr(*debugLogFD), "debug log file") |