diff options
author | Michael Pratt <mpratt@google.com> | 2019-04-22 18:17:25 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-04-22 18:20:51 -0700 |
commit | f86c35a51ff92718e36ff6075339300be11e09b3 (patch) | |
tree | a539a750dabc61a19d47740c8b4f770f67977d97 /pkg/sentry/kernel | |
parent | 56927e5317151d5775366c6315f2054e0ae0e23a (diff) |
Clean up state error handling
PiperOrigin-RevId: 244773836
Change-Id: I32223f79d2314fe1ac4ddfc63004fc22ff634adf
Diffstat (limited to 'pkg/sentry/kernel')
-rw-r--r-- | pkg/sentry/kernel/kernel.go | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/pkg/sentry/kernel/kernel.go b/pkg/sentry/kernel/kernel.go index 290c4a53c..ee6334509 100644 --- a/pkg/sentry/kernel/kernel.go +++ b/pkg/sentry/kernel/kernel.go @@ -175,9 +175,9 @@ type Kernel struct { // netlinkPorts manages allocation of netlink socket port IDs. netlinkPorts *port.Manager - // exitErr is the error causing the sandbox to exit, if any. It is - // protected by extMu. - exitErr error `state:"nosave"` + // saveErr is the error causing the sandbox to exit during save, if + // any. It is protected by extMu. + saveErr error `state:"nosave"` // danglingEndpoints is used to save / restore tcpip.DanglingEndpoints. danglingEndpoints struct{} `state:".([]tcpip.Endpoint)"` @@ -1029,20 +1029,21 @@ func (k *Kernel) NetlinkPorts() *port.Manager { return k.netlinkPorts } -// ExitError returns the sandbox error that caused the kernel to exit. -func (k *Kernel) ExitError() error { +// SaveError returns the sandbox error that caused the kernel to exit during +// save. +func (k *Kernel) SaveError() error { k.extMu.Lock() defer k.extMu.Unlock() - return k.exitErr + return k.saveErr } -// SetExitError sets the sandbox error that caused the kernel to exit, if one is -// not already set. -func (k *Kernel) SetExitError(err error) { +// SetSaveError sets the sandbox error that caused the kernel to exit during +// save, if one is not already set. +func (k *Kernel) SetSaveError(err error) { k.extMu.Lock() defer k.extMu.Unlock() - if k.exitErr == nil { - k.exitErr = err + if k.saveErr == nil { + k.saveErr = err } } |