summaryrefslogtreecommitdiffhomepage
path: root/runsc
diff options
context:
space:
mode:
Diffstat (limited to 'runsc')
-rw-r--r--runsc/boot/BUILD4
-rw-r--r--runsc/boot/loader.go12
-rw-r--r--runsc/boot/loader_amd64.go26
-rw-r--r--runsc/boot/loader_arm64.go26
-rw-r--r--runsc/boot/loader_test.go12
-rw-r--r--runsc/cmd/syscalls.go23
6 files changed, 20 insertions, 83 deletions
diff --git a/runsc/boot/BUILD b/runsc/boot/BUILD
index 0e71e800b..a907c103b 100644
--- a/runsc/boot/BUILD
+++ b/runsc/boot/BUILD
@@ -15,8 +15,6 @@ go_library(
"fs.go",
"limits.go",
"loader.go",
- "loader_amd64.go",
- "loader_arm64.go",
"network.go",
"strace.go",
"vfs.go",
@@ -77,7 +75,6 @@ go_library(
"//pkg/sentry/socket/unix",
"//pkg/sentry/state",
"//pkg/sentry/strace",
- "//pkg/sentry/syscalls/linux",
"//pkg/sentry/syscalls/linux/vfs2",
"//pkg/sentry/time",
"//pkg/sentry/unimpl:unimplemented_syscall_go_proto",
@@ -126,7 +123,6 @@ go_test(
"//pkg/p9",
"//pkg/sentry/contexttest",
"//pkg/sentry/fs",
- "//pkg/sentry/kernel",
"//pkg/sentry/vfs",
"//pkg/sync",
"//pkg/unet",
diff --git a/runsc/boot/loader.go b/runsc/boot/loader.go
index 79ef3a880..8c8bad11c 100644
--- a/runsc/boot/loader.go
+++ b/runsc/boot/loader.go
@@ -77,8 +77,6 @@ import (
_ "gvisor.dev/gvisor/pkg/sentry/socket/unix"
)
-var syscallTable *kernel.SyscallTable
-
// Loader keeps state needed to start the kernel and run the container..
type Loader struct {
// k is the kernel.
@@ -204,14 +202,12 @@ func New(args Args) (*Loader, error) {
return nil, fmt.Errorf("setting up memory usage: %v", err)
}
- // Patch the syscall table.
- kernel.VFS2Enabled = args.Conf.VFS2
- if kernel.VFS2Enabled {
- vfs2.Override(syscallTable.Table)
+ // Is this a VFSv2 kernel?
+ if args.Conf.VFS2 {
+ kernel.VFS2Enabled = true
+ vfs2.Override()
}
- kernel.RegisterSyscallTable(syscallTable)
-
// Create kernel and platform.
p, err := createPlatform(args.Conf, args.Device)
if err != nil {
diff --git a/runsc/boot/loader_amd64.go b/runsc/boot/loader_amd64.go
deleted file mode 100644
index 78df86611..000000000
--- a/runsc/boot/loader_amd64.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2019 The gVisor Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// +build amd64
-
-package boot
-
-import (
- "gvisor.dev/gvisor/pkg/sentry/syscalls/linux"
-)
-
-func init() {
- // Set the global syscall table.
- syscallTable = linux.AMD64
-}
diff --git a/runsc/boot/loader_arm64.go b/runsc/boot/loader_arm64.go
deleted file mode 100644
index 250785010..000000000
--- a/runsc/boot/loader_arm64.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2019 The gVisor Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// +build arm64
-
-package boot
-
-import (
- "gvisor.dev/gvisor/pkg/sentry/syscalls/linux"
-)
-
-func init() {
- // Set the global syscall table.
- syscallTable = linux.ARM64
-}
diff --git a/runsc/boot/loader_test.go b/runsc/boot/loader_test.go
index 7a30fea70..e448fd773 100644
--- a/runsc/boot/loader_test.go
+++ b/runsc/boot/loader_test.go
@@ -31,7 +31,6 @@ import (
"gvisor.dev/gvisor/pkg/p9"
"gvisor.dev/gvisor/pkg/sentry/contexttest"
"gvisor.dev/gvisor/pkg/sentry/fs"
- "gvisor.dev/gvisor/pkg/sentry/kernel"
"gvisor.dev/gvisor/pkg/sentry/vfs"
"gvisor.dev/gvisor/pkg/sync"
"gvisor.dev/gvisor/pkg/unet"
@@ -69,11 +68,6 @@ func testSpec() *specs.Spec {
}
}
-func resetSyscallTable() {
- kernel.VFS2Enabled = false
- kernel.FlushSyscallTablesTestOnly()
-}
-
// startGofer starts a new gofer routine serving 'root' path. It returns the
// sandbox side of the connection, and a function that when called will stop the
// gofer.
@@ -150,13 +144,11 @@ func createLoader(vfsEnabled bool, spec *specs.Spec) (*Loader, func(), error) {
// TestRun runs a simple application in a sandbox and checks that it succeeds.
func TestRun(t *testing.T) {
- defer resetSyscallTable()
doRun(t, false)
}
// TestRunVFS2 runs TestRun in VFSv2.
func TestRunVFS2(t *testing.T) {
- defer resetSyscallTable()
doRun(t, true)
}
@@ -199,13 +191,11 @@ func doRun(t *testing.T, vfsEnabled bool) {
// TestStartSignal tests that the controller Start message will cause
// WaitForStartSignal to return.
func TestStartSignal(t *testing.T) {
- defer resetSyscallTable()
doStartSignal(t, false)
}
// TestStartSignalVFS2 does TestStartSignal with VFS2.
func TestStartSignalVFS2(t *testing.T) {
- defer resetSyscallTable()
doStartSignal(t, true)
}
@@ -477,8 +467,6 @@ func TestCreateMountNamespace(t *testing.T) {
func TestCreateMountNamespaceVFS2(t *testing.T) {
for _, tc := range createMountTestcases(true /* vfs2 */) {
t.Run(tc.name, func(t *testing.T) {
- defer resetSyscallTable()
-
spec := testSpec()
spec.Mounts = tc.spec.Mounts
spec.Root = tc.spec.Root
diff --git a/runsc/cmd/syscalls.go b/runsc/cmd/syscalls.go
index 7072547be..a37d66139 100644
--- a/runsc/cmd/syscalls.go
+++ b/runsc/cmd/syscalls.go
@@ -32,9 +32,10 @@ import (
// Syscalls implements subcommands.Command for the "syscalls" command.
type Syscalls struct {
- output string
- os string
- arch string
+ format string
+ os string
+ arch string
+ filename string
}
// CompatibilityInfo is a map of system and architecture to compatibility doc.
@@ -95,16 +96,17 @@ func (*Syscalls) Usage() string {
// SetFlags implements subcommands.Command.SetFlags.
func (s *Syscalls) SetFlags(f *flag.FlagSet) {
- f.StringVar(&s.output, "o", "table", "Output format (table, csv, json).")
+ f.StringVar(&s.format, "format", "table", "Output format (table, csv, json).")
f.StringVar(&s.os, "os", osAll, "The OS (e.g. linux)")
f.StringVar(&s.arch, "arch", archAll, "The CPU architecture (e.g. amd64).")
+ f.StringVar(&s.filename, "filename", "", "Output filename (otherwise stdout).")
}
// Execute implements subcommands.Command.Execute.
func (s *Syscalls) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
- out, ok := outputMap[s.output]
+ out, ok := outputMap[s.format]
if !ok {
- Fatalf("Unsupported output format %q", s.output)
+ Fatalf("Unsupported output format %q", s.format)
}
// Build map of all supported architectures.
@@ -124,7 +126,14 @@ func (s *Syscalls) Execute(_ context.Context, f *flag.FlagSet, args ...interface
Fatalf("%v", err)
}
- if err := out(os.Stdout, info); err != nil {
+ w := os.Stdout // Default.
+ if s.filename != "" {
+ w, err = os.OpenFile(s.filename, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
+ if err != nil {
+ Fatalf("Error opening %q: %v", s.filename, err)
+ }
+ }
+ if err := out(w, info); err != nil {
Fatalf("Error writing output: %v", err)
}