summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2019-04-22 18:17:25 -0700
committerShentubot <shentubot@google.com>2019-04-22 18:20:51 -0700
commitf86c35a51ff92718e36ff6075339300be11e09b3 (patch)
treea539a750dabc61a19d47740c8b4f770f67977d97 /pkg/sentry
parent56927e5317151d5775366c6315f2054e0ae0e23a (diff)
Clean up state error handling
PiperOrigin-RevId: 244773836 Change-Id: I32223f79d2314fe1ac4ddfc63004fc22ff634adf
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/control/state.go2
-rw-r--r--pkg/sentry/kernel/kernel.go23
2 files changed, 13 insertions, 12 deletions
diff --git a/pkg/sentry/control/state.go b/pkg/sentry/control/state.go
index 0a480c84a..b6bbf69fa 100644
--- a/pkg/sentry/control/state.go
+++ b/pkg/sentry/control/state.go
@@ -64,7 +64,7 @@ func (s *State) Save(o *SaveOpts, _ *struct{}) error {
log.Infof("Save succeeded: exiting...")
} else {
log.Warningf("Save failed: exiting...")
- s.Kernel.SetExitError(err)
+ s.Kernel.SetSaveError(err)
}
s.Kernel.Kill(kernel.ExitStatus{})
},
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
}
}