summaryrefslogtreecommitdiffhomepage
path: root/runsc/boot/config.go
diff options
context:
space:
mode:
authorpraveensastry <sastry.praveen@gmail.com>2019-08-06 01:15:48 +1000
committerpraveensastry <sastry.praveen@gmail.com>2019-08-06 01:15:48 +1000
commit607be0585fdc659ec3c043c989a8a6f86fcc14db (patch)
tree14c86afd532de8dc16790ecc15acff926267c6f0 /runsc/boot/config.go
parentf0507e1db1574ff165000fa5e34b651413f37aae (diff)
Add option to configure reference leak checking
Diffstat (limited to 'runsc/boot/config.go')
-rw-r--r--runsc/boot/config.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/runsc/boot/config.go b/runsc/boot/config.go
index 7ae0dd05d..139eb1cce 100644
--- a/runsc/boot/config.go
+++ b/runsc/boot/config.go
@@ -19,6 +19,7 @@ import (
"strconv"
"strings"
+ "gvisor.dev/gvisor/pkg/refs"
"gvisor.dev/gvisor/pkg/sentry/watchdog"
)
@@ -112,6 +113,20 @@ func MakeWatchdogAction(s string) (watchdog.Action, error) {
}
}
+// MakeRefsLeakMode converts type from string
+func MakeRefsLeakMode(s string) (refs.LeakMode, error) {
+ switch strings.ToLower(s) {
+ case "nocheck":
+ return refs.NoLeakChecking, nil
+ case "warning":
+ return refs.LeaksLogWarning, nil
+ case "traces":
+ return refs.LeaksLogTraces, nil
+ default:
+ return 0, fmt.Errorf("invalid refs leakmode %q", s)
+ }
+}
+
// Config holds configuration that is not part of the runtime spec.
type Config struct {
// RootDir is the runtime root directory.
@@ -201,6 +216,9 @@ type Config struct {
// AlsoLogToStderr allows to send log messages to stderr.
AlsoLogToStderr bool
+
+ // ReferenceLeakMode sets reference leak check mode
+ ReferenceLeakMode refs.LeakMode
}
// ToFlags returns a slice of flags that correspond to the given Config.
@@ -227,6 +245,7 @@ func (c *Config) ToFlags() []string {
"--num-network-channels=" + strconv.Itoa(c.NumNetworkChannels),
"--rootless=" + strconv.FormatBool(c.Rootless),
"--alsologtostderr=" + strconv.FormatBool(c.AlsoLogToStderr),
+ "--refs-leak-mode=" + c.ReferenceLeakMode.String(),
}
if c.TestOnlyAllowRunAsCurrentUserWithoutChroot {
// Only include if set since it is never to be used by users.