Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainer/cgroup: create cgroup manager after creating the network
Browse files Browse the repository at this point in the history
Create the cgroup manager once the network has been created, this way the
list of device will include the network VFIO devices attached to the sandbox,
when the physical enpoint is the network driver.

fixes #2774

Signed-off-by: Julio Montes <[email protected]>
  • Loading branch information
Julio Montes committed Jun 16, 2020
1 parent 3c8c650 commit 5fccab7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions virtcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, f

// Move runtime to sandbox cgroup so all process are created there.
if s.config.SandboxCgroupOnly {
if err := s.createCgroupManager(); err != nil {
return nil, err
}

if err := s.setupSandboxCgroup(); err != nil {
return nil, err
}
Expand Down
10 changes: 6 additions & 4 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,6 @@ func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factor
}
}

if err := s.createCgroupManager(); err != nil {
return nil, err
}

agentConfig, err := newAgentConfig(sandboxConfig.AgentType, sandboxConfig.AgentConfig)
if err != nil {
return nil, err
Expand Down Expand Up @@ -739,6 +735,12 @@ func fetchSandbox(ctx context.Context, sandboxID string) (sandbox *Sandbox, err
return nil, fmt.Errorf("failed to create sandbox with config %+v: %v", config, err)
}

if sandbox.config.SandboxCgroupOnly {
if err := sandbox.createCgroupManager(); err != nil {
return nil, err
}
}

// This sandbox already exists, we don't need to recreate the containers in the guest.
// We only need to fetch the containers from storage and create the container structs.
if err := sandbox.fetchContainers(); err != nil {
Expand Down

0 comments on commit 5fccab7

Please sign in to comment.