summaryrefslogtreecommitdiffhomepage
path: root/runsc/boot/controller.go
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@gmail.com>2019-05-03 21:40:48 -0700
committerShentubot <shentubot@google.com>2019-05-03 21:41:45 -0700
commitbf0ac565d2873069799082ad7bc3e3c43acbc593 (patch)
tree398abb381e328568809e6e6b46a3a3a2d4034e25 /runsc/boot/controller.go
parentb4a9f186872d6687f34e609a39aa10eb33cce1d2 (diff)
Fix runsc restore to be compatible with docker start --checkpoint ...
Change-Id: I02b30de13f1393df66edf8829fedbf32405d18f8 PiperOrigin-RevId: 246621192
Diffstat (limited to 'runsc/boot/controller.go')
-rw-r--r--runsc/boot/controller.go21
1 files changed, 12 insertions, 9 deletions
diff --git a/runsc/boot/controller.go b/runsc/boot/controller.go
index ab7c58838..86f06bff1 100644
--- a/runsc/boot/controller.go
+++ b/runsc/boot/controller.go
@@ -19,6 +19,7 @@ import (
"fmt"
"os"
"path"
+ "syscall"
specs "github.com/opencontainers/runtime-spec/specs-go"
"gvisor.googlesource.com/gvisor/pkg/control/server"
@@ -304,12 +305,17 @@ type RestoreOpts struct {
func (cm *containerManager) Restore(o *RestoreOpts, _ *struct{}) error {
log.Debugf("containerManager.Restore")
- var specFile, deviceFile *os.File
+ var specFile *os.File
+ deviceFD := -1
switch numFiles := len(o.FilePayload.Files); numFiles {
case 2:
- // The device file is donated to the platform, so don't Close
- // it here.
- deviceFile = o.FilePayload.Files[1]
+ var err error
+ // The device file is donated to the platform.
+ // Can't take ownership away from os.File. dup them to get a new FD.
+ deviceFD, err = syscall.Dup(int(o.FilePayload.Files[1].Fd()))
+ if err != nil {
+ return fmt.Errorf("failed to dup file: %v", err)
+ }
fallthrough
case 1:
specFile = o.FilePayload.Files[0]
@@ -320,11 +326,12 @@ func (cm *containerManager) Restore(o *RestoreOpts, _ *struct{}) error {
return fmt.Errorf("at most two files may be passed to Restore")
}
+ networkStack := cm.l.k.NetworkStack()
// Destroy the old kernel and create a new kernel.
cm.l.k.Pause()
cm.l.k.Destroy()
- p, err := createPlatform(cm.l.conf, int(deviceFile.Fd()))
+ p, err := createPlatform(cm.l.conf, deviceFD)
if err != nil {
return fmt.Errorf("creating platform: %v", err)
}
@@ -347,10 +354,6 @@ func (cm *containerManager) Restore(o *RestoreOpts, _ *struct{}) error {
fs.SetRestoreEnvironment(*renv)
// Prepare to load from the state file.
- networkStack, err := newEmptyNetworkStack(cm.l.conf, k)
- if err != nil {
- return fmt.Errorf("creating network: %v", err)
- }
if eps, ok := networkStack.(*epsocket.Stack); ok {
stack.StackFromEnv = eps.Stack // FIXME(b/36201077)
}