summaryrefslogtreecommitdiffhomepage
path: root/runsc/container/test_app.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-10-11 11:55:45 -0700
committerShentubot <shentubot@google.com>2018-10-11 11:56:54 -0700
commitf413e4b11794cd71cc3b2b64c8f6861f5394a3f1 (patch)
treeff9af373751ee40db971ae6dd23a6c752e8d43fe /runsc/container/test_app.go
parent0bfa03d61c7791aad03da5ac021bc60e4578858e (diff)
Add bare bones unsupported syscall logging
This change introduces a new flags to create/run called --user-log. Logs to this files are visible to users and are meant to help debugging problems with their images and containers. For now only unsupported syscalls are sent to this log, and only minimum support was added. We can build more infrastructure around it as needed. PiperOrigin-RevId: 216735977 Change-Id: I54427ca194604991c407d49943ab3680470de2d0
Diffstat (limited to 'runsc/container/test_app.go')
-rw-r--r--runsc/container/test_app.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/runsc/container/test_app.go b/runsc/container/test_app.go
index f69cfdf83..9e4b5326d 100644
--- a/runsc/container/test_app.go
+++ b/runsc/container/test_app.go
@@ -24,6 +24,7 @@ import (
"os"
"os/exec"
"strconv"
+ sys "syscall"
"time"
"flag"
@@ -38,6 +39,7 @@ func main() {
subcommands.Register(new(taskTree), "")
subcommands.Register(new(forkBomb), "")
subcommands.Register(new(reaper), "")
+ subcommands.Register(new(syscall), "")
flag.Parse()
@@ -241,3 +243,37 @@ func (c *reaper) Execute(ctx context.Context, f *flag.FlagSet, args ...interface
defer stop()
select {}
}
+
+type syscall struct {
+ sysno uint64
+}
+
+// Name implements subcommands.Command.
+func (*syscall) Name() string {
+ return "syscall"
+}
+
+// Synopsis implements subcommands.Command.
+func (*syscall) Synopsis() string {
+ return "syscall makes a syscall"
+}
+
+// Usage implements subcommands.Command.
+func (*syscall) Usage() string {
+ return "syscall <flags>"
+}
+
+// SetFlags implements subcommands.Command.
+func (s *syscall) SetFlags(f *flag.FlagSet) {
+ f.Uint64Var(&s.sysno, "syscall", 0, "syscall to call")
+}
+
+// Execute implements subcommands.Command.
+func (s *syscall) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
+ if _, _, errno := sys.Syscall(uintptr(s.sysno), 0, 0, 0); errno != 0 {
+ fmt.Printf("syscall(%d, 0, 0...) failed: %v\n", s.sysno, errno)
+ } else {
+ fmt.Printf("syscall(%d, 0, 0...) success\n", s.sysno)
+ }
+ return subcommands.ExitSuccess
+}