diff --git a/runsc/cli/main.go b/runsc/cli/main.go index 63f1e76ed..c44ad0cb5 100644 --- a/runsc/cli/main.go +++ b/runsc/cli/main.go @@ -178,16 +178,6 @@ func Main() { if ulEmittter, add := userLogEmitter(conf, subcommand); add { emitters = append(emitters, ulEmittter) } - if *coverageFD >= 0 { - f := os.NewFile(uintptr(*coverageFD), "coverage file") - coverage.EnableReport(f) - } - if *profilingMetricsFD >= 0 { - metric.ProfilingMetricWriter = os.NewFile(uintptr(*profilingMetricsFD), "metrics file") - if metric.ProfilingMetricWriter == nil { - log.Warningf("Failed to use -profiling-metrics-fd") - } - } switch len(emitters) { case 0: @@ -200,26 +190,24 @@ func Main() { log.SetTarget(&emitters) } - log.Infof("***************************") - log.Infof("Args: %s", os.Args) - log.Infof("Version %s", version.Version()) - log.Infof("GOOS: %s", runtime.GOOS) - log.Infof("GOARCH: %s", runtime.GOARCH) - log.Infof("PID: %d", os.Getpid()) - log.Infof("UID: %d, GID: %d", os.Getuid(), os.Getgid()) - log.Infof("Configuration:") - log.Infof("\t\tRootDir: %s", conf.RootDir) - log.Infof("\t\tPlatform: %v", conf.Platform) - log.Infof("\t\tFileAccess: %v", conf.FileAccess) - log.Infof("\t\tDirectfs: %t", conf.DirectFS) - log.Infof("\t\tOverlay: %s", conf.GetOverlay2()) - log.Infof("\t\tNetwork: %v, logging: %t", conf.Network, conf.LogPackets) - log.Infof("\t\tStrace: %t, max size: %d, syscalls: %s", conf.Strace, conf.StraceLogSize, conf.StraceSyscalls) - log.Infof("\t\tIOURING: %t", conf.IOUring) - log.Infof("\t\tDebug: %v", conf.Debug) - log.Infof("\t\tSystemd: %v", conf.SystemdCgroup) - log.Infof("***************************") + const delimString = `**************** gVisor ****************` + log.Infof(delimString) + log.Infof("Version %s, %s, %s, %d CPUs, %s, PID %d, PPID %d, UID %d, GID %d", version.Version(), runtime.Version(), runtime.GOARCH, runtime.NumCPU(), runtime.GOOS, os.Getpid(), os.Getppid(), os.Getuid(), os.Getgid()) + log.Debugf("Page size: 0x%x (%d bytes)", os.Getpagesize(), os.Getpagesize()) + log.Infof("Args: %v", os.Args) + conf.Log() + log.Infof(delimString) + if *coverageFD >= 0 { + f := os.NewFile(uintptr(*coverageFD), "coverage file") + coverage.EnableReport(f) + } + if *profilingMetricsFD >= 0 { + metric.ProfilingMetricWriter = os.NewFile(uintptr(*profilingMetricsFD), "metrics file") + if metric.ProfilingMetricWriter == nil { + log.Warningf("Failed to use -profiling-metrics-fd") + } + } if conf.TestOnlyAllowRunAsCurrentUserWithoutChroot { // SIGTERM is sent to all processes if a test exceeds its // timeout and this case is handled by syscall_test_runner. diff --git a/runsc/config/config.go b/runsc/config/config.go index a47d63f21..856a8e5cc 100644 --- a/runsc/config/config.go +++ b/runsc/config/config.go @@ -20,11 +20,13 @@ package config import ( "fmt" "path/filepath" + "reflect" "runtime" "strconv" "strings" "time" + "gvisor.dev/gvisor/pkg/log" "gvisor.dev/gvisor/pkg/refs" "gvisor.dev/gvisor/pkg/sentry/watchdog" "gvisor.dev/gvisor/runsc/flag" @@ -393,6 +395,33 @@ func (c *Config) validate() error { return nil } +// Log logs important aspects of the configuration to the given log function. +func (c *Config) Log() { + log.Infof("Platform: %v", c.Platform) + log.Infof("RootDir: %s", c.RootDir) + log.Infof("FileAccess: %v / Directfs: %t / Overlay: %v", c.FileAccess, c.DirectFS, c.GetOverlay2()) + log.Infof("Network: %v", c.Network) + if c.Debug || c.Strace { + log.Infof("Debug: %t. Strace: %t, max size: %d, syscalls: %s", c.Debug, c.Strace, c.StraceLogSize, c.StraceSyscalls) + } + if c.Debug { + obj := reflect.ValueOf(c).Elem() + st := obj.Type() + for i := 0; i < st.NumField(); i++ { + f := st.Field(i) + val := obj.Field(i).String() + if val == "" { + val = "(empty)" + } + if flagName, hasFlag := f.Tag.Lookup("flag"); hasFlag { + log.Debugf("Config.%s (--%s): %v", f.Name, flagName, val) + } else { + log.Debugf("Config.%s: %v", f.Name, val) + } + } + } +} + // GetHostUDS returns the FS gofer communication that is allowed, taking into // consideration all flags what affect the result. func (c *Config) GetHostUDS() HostUDS {