summaryrefslogtreecommitdiffhomepage
path: root/runsc/boot/loader.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-09-27 10:25:19 -0700
committerShentubot <shentubot@google.com>2018-09-27 10:26:34 -0700
commitb514ab05897bca53c1d4f71c912f2977b3134daf (patch)
treefd900cccf6d4f8d9fe9a54ec4ea1e8de13df1bb8 /runsc/boot/loader.go
parent6910ff36434f4bc5aa8c6b3094b617c7c92a9803 (diff)
Refactor 'runsc boot' to take container ID as argument
This makes the flow slightly simpler (no need to call Loader.SetRootContainer). And this is required change to tag tasks with container ID inside the Sentry. PiperOrigin-RevId: 214795210 Change-Id: I6ff4af12e73bb07157f7058bb15fd5bb88760884
Diffstat (limited to 'runsc/boot/loader.go')
-rw-r--r--runsc/boot/loader.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/runsc/boot/loader.go b/runsc/boot/loader.go
index 5867eec96..9a5d649ab 100644
--- a/runsc/boot/loader.go
+++ b/runsc/boot/loader.go
@@ -142,7 +142,7 @@ func init() {
// New initializes a new kernel loader configured by spec.
// New also handles setting up a kernel for restoring a container.
-func New(spec *specs.Spec, conf *Config, controllerFD, deviceFD int, goferFDs []int, console bool) (*Loader, error) {
+func New(id string, spec *specs.Spec, conf *Config, controllerFD, deviceFD int, goferFDs []int, console bool) (*Loader, error) {
if err := usage.Init(); err != nil {
return nil, fmt.Errorf("Error setting up memory usage: %v", err)
}
@@ -286,6 +286,9 @@ func New(spec *specs.Spec, conf *Config, controllerFD, deviceFD int, goferFDs []
spec: spec,
startSignalForwarding: startSignalForwarding,
rootProcArgs: procArgs,
+ sandboxID: id,
+ containerRootTGs: make(map[string]*kernel.ThreadGroup),
+ execProcesses: make(map[execID]*kernel.ThreadGroup),
}
ctrl.manager.l = l
return l, nil
@@ -420,10 +423,9 @@ func (l *Loader) run() error {
l.rootProcArgs.FDMap.DecRef()
}
- if l.execProcesses != nil {
- return fmt.Errorf("there shouldn't already be a cache of exec'd processes, but found: %v", l.execProcesses)
- }
- l.execProcesses = make(map[execID]*kernel.ThreadGroup)
+ l.mu.Lock()
+ l.containerRootTGs[l.sandboxID] = l.k.GlobalInit()
+ l.mu.Unlock()
// Start signal forwarding only after an init process is created.
l.stopSignalForwarding = l.startSignalForwarding()