mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Store container specs for all containers in runsc loader.
Before this we were only saving the root/first container's spec in Loader.root.spec. We want to also save the sub container's specs. This will be helpful in doing spec validation on restore for multi-container sandboxes. PiperOrigin-RevId: 663737065
This commit is contained in:
+23
-9
@@ -231,9 +231,15 @@ type Loader struct {
|
||||
// naming when user didn't provide one.
|
||||
//
|
||||
// Mapping: name -> cid.
|
||||
// processes is guarded by mu.
|
||||
// containerIDs is guarded by mu.
|
||||
containerIDs map[string]string
|
||||
|
||||
// containerSpecs stores container specs for each container in sandbox.
|
||||
//
|
||||
// Mapping: cid -> spec.
|
||||
// containerSpecs is guarded by mu.
|
||||
containerSpecs map[string]*specs.Spec
|
||||
|
||||
// portForwardProxies is a list of active port forwarding connections.
|
||||
//
|
||||
// portForwardProxies is guarded by mu.
|
||||
@@ -412,14 +418,15 @@ func New(args Args) (*Loader, error) {
|
||||
|
||||
eid := execID{cid: args.ID}
|
||||
l := &Loader{
|
||||
sandboxID: args.ID,
|
||||
processes: map[execID]*execProcess{eid: {}},
|
||||
sharedMounts: make(map[string]*vfs.Mount),
|
||||
stopProfiling: stopProfiling,
|
||||
productName: args.ProductName,
|
||||
hostShmemHuge: args.HostShmemHuge,
|
||||
containerIDs: map[string]string{},
|
||||
saveFDs: args.SaveFDs,
|
||||
sandboxID: args.ID,
|
||||
processes: map[execID]*execProcess{eid: {}},
|
||||
sharedMounts: make(map[string]*vfs.Mount),
|
||||
stopProfiling: stopProfiling,
|
||||
productName: args.ProductName,
|
||||
hostShmemHuge: args.HostShmemHuge,
|
||||
containerIDs: make(map[string]string),
|
||||
containerSpecs: make(map[string]*specs.Spec),
|
||||
saveFDs: args.SaveFDs,
|
||||
}
|
||||
|
||||
containerName := l.registerContainerLocked(args.Spec, args.ID)
|
||||
@@ -1885,9 +1892,16 @@ func (l *Loader) registerContainerLocked(spec *specs.Spec, cid string) string {
|
||||
}
|
||||
|
||||
l.containerIDs[containerName] = cid
|
||||
l.containerSpecs[cid] = spec
|
||||
return containerName
|
||||
}
|
||||
|
||||
func (l *Loader) getContainerSpec(cid string) *specs.Spec {
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
return l.containerSpecs[cid]
|
||||
}
|
||||
|
||||
func (l *Loader) containerRuntimeState(cid string) ContainerRuntimeState {
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user