diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-04-10 02:19:26 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-04-10 02:19:26 +0000 |
commit | 4fa86d8e40dd4bb595b7ed33290021acedb001d5 (patch) | |
tree | 32eecd1209588433b2e8ff29fb8f2fa5e6969d29 | |
parent | aec346f392a983687719a813ed58c6f8b54aede9 (diff) | |
parent | 78126611e61e26269d804dd18a5229820c4ddced (diff) |
Merge release-20200323.0-119-g7812661 (automated)
25 files changed, 122 insertions, 107 deletions
diff --git a/pkg/log/glog.go b/pkg/log/glog.go index b4f7bb5a4..f57c4427b 100644 --- a/pkg/log/glog.go +++ b/pkg/log/glog.go @@ -25,7 +25,7 @@ import ( // GoogleEmitter is a wrapper that emits logs in a format compatible with // package github.com/golang/glog. type GoogleEmitter struct { - Writer + *Writer } // pid is used for the threadid component of the header. @@ -46,7 +46,7 @@ var pid = os.Getpid() // line The line number // msg The user-supplied message // -func (g *GoogleEmitter) Emit(depth int, level Level, timestamp time.Time, format string, args ...interface{}) { +func (g GoogleEmitter) Emit(depth int, level Level, timestamp time.Time, format string, args ...interface{}) { // Log level. prefix := byte('?') switch level { @@ -81,5 +81,5 @@ func (g *GoogleEmitter) Emit(depth int, level Level, timestamp time.Time, format message := fmt.Sprintf(format, args...) // Emit the formatted result. - fmt.Fprintf(&g.Writer, "%c%02d%02d %02d:%02d:%02d.%06d % 7d %s:%d] %s\n", prefix, int(month), day, hour, minute, second, microsecond, pid, file, line, message) + fmt.Fprintf(g.Writer, "%c%02d%02d %02d:%02d:%02d.%06d % 7d %s:%d] %s\n", prefix, int(month), day, hour, minute, second, microsecond, pid, file, line, message) } diff --git a/pkg/log/json.go b/pkg/log/json.go index 0943db1cc..bdf9d691e 100644 --- a/pkg/log/json.go +++ b/pkg/log/json.go @@ -58,7 +58,7 @@ func (lv *Level) UnmarshalJSON(b []byte) error { // JSONEmitter logs messages in json format. type JSONEmitter struct { - Writer + *Writer } // Emit implements Emitter.Emit. diff --git a/pkg/log/json_k8s.go b/pkg/log/json_k8s.go index 6c6fc8b6f..5883e95e1 100644 --- a/pkg/log/json_k8s.go +++ b/pkg/log/json_k8s.go @@ -29,11 +29,11 @@ type k8sJSONLog struct { // K8sJSONEmitter logs messages in json format that is compatible with // Kubernetes fluent configuration. type K8sJSONEmitter struct { - Writer + *Writer } // Emit implements Emitter.Emit. -func (e *K8sJSONEmitter) Emit(_ int, level Level, timestamp time.Time, format string, v ...interface{}) { +func (e K8sJSONEmitter) Emit(_ int, level Level, timestamp time.Time, format string, v ...interface{}) { j := k8sJSONLog{ Log: fmt.Sprintf(format, v...), Level: level, diff --git a/pkg/log/log.go b/pkg/log/log.go index a794da1aa..37e0605ad 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -374,5 +374,5 @@ func CopyStandardLogTo(l Level) error { func init() { // Store the initial value for the log. - log.Store(&BasicLogger{Level: Info, Emitter: &GoogleEmitter{Writer{Next: os.Stderr}}}) + log.Store(&BasicLogger{Level: Info, Emitter: GoogleEmitter{&Writer{Next: os.Stderr}}}) } diff --git a/pkg/sentry/fs/fs_state_autogen.go b/pkg/sentry/fs/fs_state_autogen.go index f6d6286c2..502a90d71 100755 --- a/pkg/sentry/fs/fs_state_autogen.go +++ b/pkg/sentry/fs/fs_state_autogen.go @@ -190,11 +190,11 @@ func (x *Dirent) load(m state.Map) { func (x *DirentCache) beforeSave() {} func (x *DirentCache) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.currentSize) { - m.Failf("currentSize is %v, expected zero", x.currentSize) + if !state.IsZeroValue(&x.currentSize) { + m.Failf("currentSize is %#v, expected zero", &x.currentSize) } - if !state.IsZeroValue(x.list) { - m.Failf("list is %v, expected zero", x.list) + if !state.IsZeroValue(&x.list) { + m.Failf("list is %#v, expected zero", &x.list) } m.Save("maxSize", &x.maxSize) m.Save("limit", &x.limit) @@ -209,8 +209,8 @@ func (x *DirentCache) load(m state.Map) { func (x *DirentCacheLimiter) beforeSave() {} func (x *DirentCacheLimiter) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.count) { - m.Failf("count is %v, expected zero", x.count) + if !state.IsZeroValue(&x.count) { + m.Failf("count is %#v, expected zero", &x.count) } m.Save("max", &x.max) } diff --git a/pkg/sentry/fs/host/host_state_autogen.go b/pkg/sentry/fs/host/host_state_autogen.go index 8351ece3b..a6b97a154 100755 --- a/pkg/sentry/fs/host/host_state_autogen.go +++ b/pkg/sentry/fs/host/host_state_autogen.go @@ -56,8 +56,8 @@ func (x *inodeOperations) load(m state.Map) { func (x *inodeFileState) beforeSave() {} func (x *inodeFileState) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.queue) { - m.Failf("queue is %v, expected zero", x.queue) + if !state.IsZeroValue(&x.queue) { + m.Failf("queue is %#v, expected zero", &x.queue) } m.Save("descriptor", &x.descriptor) m.Save("sattr", &x.sattr) diff --git a/pkg/sentry/fs/lock/lock_state_autogen.go b/pkg/sentry/fs/lock/lock_state_autogen.go index aabf3d570..a5db62814 100755 --- a/pkg/sentry/fs/lock/lock_state_autogen.go +++ b/pkg/sentry/fs/lock/lock_state_autogen.go @@ -24,8 +24,8 @@ func (x *Lock) load(m state.Map) { func (x *Locks) beforeSave() {} func (x *Locks) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.blockedQueue) { - m.Failf("blockedQueue is %v, expected zero", x.blockedQueue) + if !state.IsZeroValue(&x.blockedQueue) { + m.Failf("blockedQueue is %#v, expected zero", &x.blockedQueue) } m.Save("locks", &x.locks) } diff --git a/pkg/sentry/fs/proc/sys_net.go b/pkg/sentry/fs/proc/sys_net.go index d4c4b533d..702fdd392 100644 --- a/pkg/sentry/fs/proc/sys_net.go +++ b/pkg/sentry/fs/proc/sys_net.go @@ -80,7 +80,7 @@ func newTCPMemInode(ctx context.Context, msrc *fs.MountSource, s inet.Stack, dir } // Truncate implements fs.InodeOperations.Truncate. -func (tcpMemInode) Truncate(context.Context, *fs.Inode, int64) error { +func (*tcpMemInode) Truncate(context.Context, *fs.Inode, int64) error { return nil } @@ -196,7 +196,7 @@ func newTCPSackInode(ctx context.Context, msrc *fs.MountSource, s inet.Stack) *f } // Truncate implements fs.InodeOperations.Truncate. -func (tcpSack) Truncate(context.Context, *fs.Inode, int64) error { +func (*tcpSack) Truncate(context.Context, *fs.Inode, int64) error { return nil } diff --git a/pkg/sentry/fs/timerfd/timerfd_state_autogen.go b/pkg/sentry/fs/timerfd/timerfd_state_autogen.go index b1335d3c7..955cf1d38 100755 --- a/pkg/sentry/fs/timerfd/timerfd_state_autogen.go +++ b/pkg/sentry/fs/timerfd/timerfd_state_autogen.go @@ -9,8 +9,8 @@ import ( func (x *TimerOperations) beforeSave() {} func (x *TimerOperations) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.events) { - m.Failf("events is %v, expected zero", x.events) + if !state.IsZeroValue(&x.events) { + m.Failf("events is %#v, expected zero", &x.events) } m.Save("timer", &x.timer) m.Save("val", &x.val) diff --git a/pkg/sentry/fs/tty/tty_state_autogen.go b/pkg/sentry/fs/tty/tty_state_autogen.go index 9963096dd..25d601072 100755 --- a/pkg/sentry/fs/tty/tty_state_autogen.go +++ b/pkg/sentry/fs/tty/tty_state_autogen.go @@ -61,11 +61,11 @@ func (x *superOperations) load(m state.Map) { func (x *lineDiscipline) beforeSave() {} func (x *lineDiscipline) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.masterWaiter) { - m.Failf("masterWaiter is %v, expected zero", x.masterWaiter) + if !state.IsZeroValue(&x.masterWaiter) { + m.Failf("masterWaiter is %#v, expected zero", &x.masterWaiter) } - if !state.IsZeroValue(x.slaveWaiter) { - m.Failf("slaveWaiter is %v, expected zero", x.slaveWaiter) + if !state.IsZeroValue(&x.slaveWaiter) { + m.Failf("slaveWaiter is %#v, expected zero", &x.slaveWaiter) } m.Save("size", &x.size) m.Save("inQueue", &x.inQueue) diff --git a/pkg/sentry/kernel/epoll/epoll_state_autogen.go b/pkg/sentry/kernel/epoll/epoll_state_autogen.go index afdea5bcf..da3150465 100755 --- a/pkg/sentry/kernel/epoll/epoll_state_autogen.go +++ b/pkg/sentry/kernel/epoll/epoll_state_autogen.go @@ -43,26 +43,26 @@ func (x *pollEntry) load(m state.Map) { func (x *EventPoll) beforeSave() {} func (x *EventPoll) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.FilePipeSeek) { - m.Failf("FilePipeSeek is %v, expected zero", x.FilePipeSeek) + if !state.IsZeroValue(&x.FilePipeSeek) { + m.Failf("FilePipeSeek is %#v, expected zero", &x.FilePipeSeek) } - if !state.IsZeroValue(x.FileNotDirReaddir) { - m.Failf("FileNotDirReaddir is %v, expected zero", x.FileNotDirReaddir) + if !state.IsZeroValue(&x.FileNotDirReaddir) { + m.Failf("FileNotDirReaddir is %#v, expected zero", &x.FileNotDirReaddir) } - if !state.IsZeroValue(x.FileNoFsync) { - m.Failf("FileNoFsync is %v, expected zero", x.FileNoFsync) + if !state.IsZeroValue(&x.FileNoFsync) { + m.Failf("FileNoFsync is %#v, expected zero", &x.FileNoFsync) } - if !state.IsZeroValue(x.FileNoopFlush) { - m.Failf("FileNoopFlush is %v, expected zero", x.FileNoopFlush) + if !state.IsZeroValue(&x.FileNoopFlush) { + m.Failf("FileNoopFlush is %#v, expected zero", &x.FileNoopFlush) } - if !state.IsZeroValue(x.FileNoIoctl) { - m.Failf("FileNoIoctl is %v, expected zero", x.FileNoIoctl) + if !state.IsZeroValue(&x.FileNoIoctl) { + m.Failf("FileNoIoctl is %#v, expected zero", &x.FileNoIoctl) } - if !state.IsZeroValue(x.FileNoMMap) { - m.Failf("FileNoMMap is %v, expected zero", x.FileNoMMap) + if !state.IsZeroValue(&x.FileNoMMap) { + m.Failf("FileNoMMap is %#v, expected zero", &x.FileNoMMap) } - if !state.IsZeroValue(x.Queue) { - m.Failf("Queue is %v, expected zero", x.Queue) + if !state.IsZeroValue(&x.Queue) { + m.Failf("Queue is %#v, expected zero", &x.Queue) } m.Save("files", &x.files) m.Save("readyList", &x.readyList) diff --git a/pkg/sentry/kernel/eventfd/eventfd_state_autogen.go b/pkg/sentry/kernel/eventfd/eventfd_state_autogen.go index 9cf0ac817..636d80ea9 100755 --- a/pkg/sentry/kernel/eventfd/eventfd_state_autogen.go +++ b/pkg/sentry/kernel/eventfd/eventfd_state_autogen.go @@ -9,8 +9,8 @@ import ( func (x *EventOperations) beforeSave() {} func (x *EventOperations) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.wq) { - m.Failf("wq is %v, expected zero", x.wq) + if !state.IsZeroValue(&x.wq) { + m.Failf("wq is %#v, expected zero", &x.wq) } m.Save("val", &x.val) m.Save("semMode", &x.semMode) diff --git a/pkg/sentry/kernel/futex/futex_state_autogen.go b/pkg/sentry/kernel/futex/futex_state_autogen.go index d5ed3466f..68aa69daa 100755 --- a/pkg/sentry/kernel/futex/futex_state_autogen.go +++ b/pkg/sentry/kernel/futex/futex_state_autogen.go @@ -21,8 +21,8 @@ func (x *AtomicPtrBucket) load(m state.Map) { func (x *bucket) beforeSave() {} func (x *bucket) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.waiters) { - m.Failf("waiters is %v, expected zero", x.waiters) + if !state.IsZeroValue(&x.waiters) { + m.Failf("waiters is %#v, expected zero", &x.waiters) } } @@ -33,8 +33,8 @@ func (x *bucket) load(m state.Map) { func (x *Manager) beforeSave() {} func (x *Manager) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.privateBuckets) { - m.Failf("privateBuckets is %v, expected zero", x.privateBuckets) + if !state.IsZeroValue(&x.privateBuckets) { + m.Failf("privateBuckets is %#v, expected zero", &x.privateBuckets) } m.Save("sharedBucket", &x.sharedBucket) } diff --git a/pkg/sentry/kernel/kernel_state_autogen.go b/pkg/sentry/kernel/kernel_state_autogen.go index 21a0bbf81..a5b00130c 100755 --- a/pkg/sentry/kernel/kernel_state_autogen.go +++ b/pkg/sentry/kernel/kernel_state_autogen.go @@ -511,17 +511,17 @@ func (x *socketEntry) load(m state.Map) { m.Load("prev", &x.prev) } -func (x *SyscallTable) beforeSave() {} -func (x *SyscallTable) save(m state.Map) { +func (x *syscallTableInfo) beforeSave() {} +func (x *syscallTableInfo) save(m state.Map) { x.beforeSave() m.Save("OS", &x.OS) m.Save("Arch", &x.Arch) } -func (x *SyscallTable) load(m state.Map) { - m.LoadWait("OS", &x.OS) - m.LoadWait("Arch", &x.Arch) - m.AfterLoad(x.afterLoad) +func (x *syscallTableInfo) afterLoad() {} +func (x *syscallTableInfo) load(m state.Map) { + m.Load("OS", &x.OS) + m.Load("Arch", &x.Arch) } func (x *syslog) beforeSave() {} @@ -538,8 +538,8 @@ func (x *syslog) load(m state.Map) { func (x *Task) beforeSave() {} func (x *Task) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.signalQueue) { - m.Failf("signalQueue is %v, expected zero", x.signalQueue) + if !state.IsZeroValue(&x.signalQueue) { + m.Failf("signalQueue is %#v, expected zero", &x.signalQueue) } var ptraceTracer *Task = x.savePtraceTracer() m.SaveValue("ptraceTracer", ptraceTracer) @@ -701,11 +701,12 @@ func (x *vforkStop) load(m state.Map) { func (x *TaskContext) beforeSave() {} func (x *TaskContext) save(m state.Map) { x.beforeSave() + var st syscallTableInfo = x.saveSt() + m.SaveValue("st", st) m.Save("Name", &x.Name) m.Save("Arch", &x.Arch) m.Save("MemoryManager", &x.MemoryManager) m.Save("fu", &x.fu) - m.Save("st", &x.st) } func (x *TaskContext) afterLoad() {} @@ -714,7 +715,7 @@ func (x *TaskContext) load(m state.Map) { m.Load("Arch", &x.Arch) m.Load("MemoryManager", &x.MemoryManager) m.Load("fu", &x.fu) - m.Load("st", &x.st) + m.LoadValue("st", new(syscallTableInfo), func(y interface{}) { x.loadSt(y.(syscallTableInfo)) }) } func (x *execStop) beforeSave() {} @@ -1194,7 +1195,7 @@ func init() { state.Register("pkg/sentry/kernel.SignalHandlers", (*SignalHandlers)(nil), state.Fns{Save: (*SignalHandlers).save, Load: (*SignalHandlers).load}) state.Register("pkg/sentry/kernel.socketList", (*socketList)(nil), state.Fns{Save: (*socketList).save, Load: (*socketList).load}) state.Register("pkg/sentry/kernel.socketEntry", (*socketEntry)(nil), state.Fns{Save: (*socketEntry).save, Load: (*socketEntry).load}) - state.Register("pkg/sentry/kernel.SyscallTable", (*SyscallTable)(nil), state.Fns{Save: (*SyscallTable).save, Load: (*SyscallTable).load}) + state.Register("pkg/sentry/kernel.syscallTableInfo", (*syscallTableInfo)(nil), state.Fns{Save: (*syscallTableInfo).save, Load: (*syscallTableInfo).load}) state.Register("pkg/sentry/kernel.syslog", (*syslog)(nil), state.Fns{Save: (*syslog).save, Load: (*syslog).load}) state.Register("pkg/sentry/kernel.Task", (*Task)(nil), state.Fns{Save: (*Task).save, Load: (*Task).load}) state.Register("pkg/sentry/kernel.runSyscallAfterPtraceEventClone", (*runSyscallAfterPtraceEventClone)(nil), state.Fns{Save: (*runSyscallAfterPtraceEventClone).save, Load: (*runSyscallAfterPtraceEventClone).load}) diff --git a/pkg/sentry/kernel/semaphore/semaphore_state_autogen.go b/pkg/sentry/kernel/semaphore/semaphore_state_autogen.go index db80a1490..ba1d073d9 100755 --- a/pkg/sentry/kernel/semaphore/semaphore_state_autogen.go +++ b/pkg/sentry/kernel/semaphore/semaphore_state_autogen.go @@ -53,8 +53,8 @@ func (x *Set) load(m state.Map) { func (x *sem) beforeSave() {} func (x *sem) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.waiters) { - m.Failf("waiters is %v, expected zero", x.waiters) + if !state.IsZeroValue(&x.waiters) { + m.Failf("waiters is %#v, expected zero", &x.waiters) } m.Save("value", &x.value) m.Save("pid", &x.pid) diff --git a/pkg/sentry/kernel/syscalls.go b/pkg/sentry/kernel/syscalls.go index 93c4fe969..c9a2321b8 100644 --- a/pkg/sentry/kernel/syscalls.go +++ b/pkg/sentry/kernel/syscalls.go @@ -218,56 +218,55 @@ type Stracer interface { SyscallExit(context interface{}, t *Task, sysno, rval uintptr, err error) } -// SyscallTable is a lookup table of system calls. Critically, a SyscallTable -// is *immutable*. In order to make supporting suspend and resume sane, they -// must be uniquely registered and may not change during operation. +// SyscallTable is a lookup table of system calls. // -// +stateify savable +// Note that a SyscallTable is not savable directly. Instead, they are saved as +// an OS/Arch pair and lookup happens again on restore. type SyscallTable struct { // OS is the operating system that this syscall table implements. - OS abi.OS `state:"wait"` + OS abi.OS // Arch is the architecture that this syscall table targets. - Arch arch.Arch `state:"wait"` + Arch arch.Arch // The OS version that this syscall table implements. - Version Version `state:"manual"` + Version Version // AuditNumber is a numeric constant that represents the syscall table. If // non-zero, auditNumber must be one of the AUDIT_ARCH_* values defined by // linux/audit.h. - AuditNumber uint32 `state:"manual"` + AuditNumber uint32 // Table is the collection of functions. - Table map[uintptr]Syscall `state:"manual"` + Table map[uintptr]Syscall // lookup is a fixed-size array that holds the syscalls (indexed by // their numbers). It is used for fast look ups. - lookup []SyscallFn `state:"manual"` + lookup []SyscallFn // Emulate is a collection of instruction addresses to emulate. The // keys are addresses, and the values are system call numbers. - Emulate map[usermem.Addr]uintptr `state:"manual"` + Emulate map[usermem.Addr]uintptr // The function to call in case of a missing system call. - Missing MissingFn `state:"manual"` + Missing MissingFn // Stracer traces this syscall table. - Stracer Stracer `state:"manual"` + Stracer Stracer // External is used to handle an external callback. - External func(*Kernel) `state:"manual"` + External func(*Kernel) // ExternalFilterBefore is called before External is called before the syscall is executed. // External is not called if it returns false. - ExternalFilterBefore func(*Task, uintptr, arch.SyscallArguments) bool `state:"manual"` + ExternalFilterBefore func(*Task, uintptr, arch.SyscallArguments) bool // ExternalFilterAfter is called before External is called after the syscall is executed. // External is not called if it returns false. - ExternalFilterAfter func(*Task, uintptr, arch.SyscallArguments) bool `state:"manual"` + ExternalFilterAfter func(*Task, uintptr, arch.SyscallArguments) bool // FeatureEnable stores the strace and one-shot enable bits. - FeatureEnable SyscallFlagsTable `state:"manual"` + FeatureEnable SyscallFlagsTable } // allSyscallTables contains all known tables. diff --git a/pkg/sentry/kernel/syscalls_state.go b/pkg/sentry/kernel/syscalls_state.go index 00358326b..90f890495 100644 --- a/pkg/sentry/kernel/syscalls_state.go +++ b/pkg/sentry/kernel/syscalls_state.go @@ -14,16 +14,34 @@ package kernel -import "fmt" +import ( + "fmt" -// afterLoad is invoked by stateify. -func (s *SyscallTable) afterLoad() { - otherTable, ok := LookupSyscallTable(s.OS, s.Arch) - if !ok { - // Couldn't find a reference? - panic(fmt.Sprintf("syscall table not found for OS %v Arch %v", s.OS, s.Arch)) + "gvisor.dev/gvisor/pkg/abi" + "gvisor.dev/gvisor/pkg/sentry/arch" +) + +// syscallTableInfo is used to reload the SyscallTable. +// +// +stateify savable +type syscallTableInfo struct { + OS abi.OS + Arch arch.Arch +} + +// saveSt saves the SyscallTable. +func (tc *TaskContext) saveSt() syscallTableInfo { + return syscallTableInfo{ + OS: tc.st.OS, + Arch: tc.st.Arch, } +} - // Copy the table. - *s = *otherTable +// loadSt loads the SyscallTable. +func (tc *TaskContext) loadSt(sti syscallTableInfo) { + st, ok := LookupSyscallTable(sti.OS, sti.Arch) + if !ok { + panic(fmt.Sprintf("syscall table not found for OS %v, Arch %v", sti.OS, sti.Arch)) + } + tc.st = st // Save the table reference. } diff --git a/pkg/sentry/kernel/task_context.go b/pkg/sentry/kernel/task_context.go index 0158b1788..c115e8d1f 100644 --- a/pkg/sentry/kernel/task_context.go +++ b/pkg/sentry/kernel/task_context.go @@ -49,7 +49,7 @@ type TaskContext struct { fu *futex.Manager // st is the task's syscall table. - st *SyscallTable + st *SyscallTable `state:".(syscallTableInfo)"` } // release releases all resources held by the TaskContext. release is called by diff --git a/pkg/sentry/kernel/time/time.go b/pkg/sentry/kernel/time/time.go index 706de83ef..e959700f2 100644 --- a/pkg/sentry/kernel/time/time.go +++ b/pkg/sentry/kernel/time/time.go @@ -245,7 +245,7 @@ type Clock interface { type WallRateClock struct{} // WallTimeUntil implements Clock.WallTimeUntil. -func (WallRateClock) WallTimeUntil(t, now Time) time.Duration { +func (*WallRateClock) WallTimeUntil(t, now Time) time.Duration { return t.Sub(now) } @@ -254,16 +254,16 @@ func (WallRateClock) WallTimeUntil(t, now Time) time.Duration { type NoClockEvents struct{} // Readiness implements waiter.Waitable.Readiness. -func (NoClockEvents) Readiness(mask waiter.EventMask) waiter.EventMask { +func (*NoClockEvents) Readiness(mask waiter.EventMask) waiter.EventMask { return 0 } // EventRegister implements waiter.Waitable.EventRegister. -func (NoClockEvents) EventRegister(e *waiter.Entry, mask waiter.EventMask) { +func (*NoClockEvents) EventRegister(e *waiter.Entry, mask waiter.EventMask) { } // EventUnregister implements waiter.Waitable.EventUnregister. -func (NoClockEvents) EventUnregister(e *waiter.Entry) { +func (*NoClockEvents) EventUnregister(e *waiter.Entry) { } // ClockEventsQueue implements waiter.Waitable by wrapping waiter.Queue and @@ -273,7 +273,7 @@ type ClockEventsQueue struct { } // Readiness implements waiter.Waitable.Readiness. -func (ClockEventsQueue) Readiness(mask waiter.EventMask) waiter.EventMask { +func (*ClockEventsQueue) Readiness(mask waiter.EventMask) waiter.EventMask { return 0 } diff --git a/pkg/sentry/mm/mm_state_autogen.go b/pkg/sentry/mm/mm_state_autogen.go index ef95c2836..2d0e5f5f7 100755 --- a/pkg/sentry/mm/mm_state_autogen.go +++ b/pkg/sentry/mm/mm_state_autogen.go @@ -33,8 +33,8 @@ func (x *ioResult) load(m state.Map) { func (x *AIOContext) beforeSave() {} func (x *AIOContext) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.dead) { - m.Failf("dead is %v, expected zero", x.dead) + if !state.IsZeroValue(&x.dead) { + m.Failf("dead is %#v, expected zero", &x.dead) } m.Save("results", &x.results) m.Save("maxOutstanding", &x.maxOutstanding) @@ -141,11 +141,11 @@ func (x *ioEntry) load(m state.Map) { func (x *MemoryManager) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.active) { - m.Failf("active is %v, expected zero", x.active) + if !state.IsZeroValue(&x.active) { + m.Failf("active is %#v, expected zero", &x.active) } - if !state.IsZeroValue(x.captureInvalidations) { - m.Failf("captureInvalidations is %v, expected zero", x.captureInvalidations) + if !state.IsZeroValue(&x.captureInvalidations) { + m.Failf("captureInvalidations is %#v, expected zero", &x.captureInvalidations) } m.Save("p", &x.p) m.Save("mfp", &x.mfp) diff --git a/pkg/state/state.go b/pkg/state/state.go index dbe507ab4..03ae2dbb0 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -241,10 +241,7 @@ func Register(name string, instance interface{}, fns Fns) { // // This function is used by the stateify tool. func IsZeroValue(val interface{}) bool { - if val == nil { - return true - } - return reflect.DeepEqual(val, reflect.Zero(reflect.TypeOf(val)).Interface()) + return val == nil || reflect.ValueOf(val).Elem().IsZero() } // step captures one encoding / decoding step. On each step, there is up to one diff --git a/pkg/tcpip/link/fdbased/endpoint.go b/pkg/tcpip/link/fdbased/endpoint.go index 7198742b7..b857ce9d0 100644 --- a/pkg/tcpip/link/fdbased/endpoint.go +++ b/pkg/tcpip/link/fdbased/endpoint.go @@ -91,7 +91,7 @@ func (p PacketDispatchMode) String() string { case PacketMMap: return "PacketMMap" default: - return fmt.Sprintf("unknown packet dispatch mode %v", p) + return fmt.Sprintf("unknown packet dispatch mode '%d'", p) } } diff --git a/pkg/waiter/waiter_state_autogen.go b/pkg/waiter/waiter_state_autogen.go index 93acec042..cf7f5fc2c 100755 --- a/pkg/waiter/waiter_state_autogen.go +++ b/pkg/waiter/waiter_state_autogen.go @@ -26,8 +26,8 @@ func (x *Entry) load(m state.Map) { func (x *Queue) beforeSave() {} func (x *Queue) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.list) { - m.Failf("list is %v, expected zero", x.list) + if !state.IsZeroValue(&x.list) { + m.Failf("list is %#v, expected zero", &x.list) } } diff --git a/runsc/boot/compat.go b/runsc/boot/compat.go index 8995d678e..b7cfb35bf 100644 --- a/runsc/boot/compat.go +++ b/runsc/boot/compat.go @@ -65,7 +65,7 @@ func newCompatEmitter(logFD int) (*compatEmitter, error) { if logFD > 0 { f := os.NewFile(uintptr(logFD), "user log file") - target := &log.MultiEmitter{c.sink, &log.K8sJSONEmitter{log.Writer{Next: f}}} + target := &log.MultiEmitter{c.sink, log.K8sJSONEmitter{&log.Writer{Next: f}}} c.sink = &log.BasicLogger{Level: log.Info, Emitter: target} } return c, nil diff --git a/runsc/main.go b/runsc/main.go index 62e184ec9..c1c78529c 100644 --- a/runsc/main.go +++ b/runsc/main.go @@ -342,11 +342,11 @@ func main() { func newEmitter(format string, logFile io.Writer) log.Emitter { switch format { case "text": - return &log.GoogleEmitter{log.Writer{Next: logFile}} + return log.GoogleEmitter{&log.Writer{Next: logFile}} case "json": - return &log.JSONEmitter{log.Writer{Next: logFile}} + return log.JSONEmitter{&log.Writer{Next: logFile}} case "json-k8s": - return &log.K8sJSONEmitter{log.Writer{Next: logFile}} + return log.K8sJSONEmitter{&log.Writer{Next: logFile}} } cmd.Fatalf("invalid log format %q, must be 'text', 'json', or 'json-k8s'", format) panic("unreachable") |