Skip to content

Commit

Permalink
utils: simplify newProcess
Browse files Browse the repository at this point in the history
This code is not in libcontainer, IOW it is only used by a short lived
binary (runc start/run/exec). Unlike libcontainer code, here we don't have
to care about copying the structures supplied as input, meaning we can
just reuse the pointers directly.

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Jun 26, 2024
1 parent 593fcf9 commit 075da0a
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions utils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,15 @@ func newProcess(p specs.Process) (*libcontainer.Process, error) {
Label: p.SelinuxLabel,
NoNewPrivileges: &p.NoNewPrivileges,
AppArmorProfile: p.ApparmorProfile,
Scheduler: p.Scheduler,
IOPriority: p.IOPriority,
}

if p.ConsoleSize != nil {
lp.ConsoleWidth = uint16(p.ConsoleSize.Width)
lp.ConsoleHeight = uint16(p.ConsoleSize.Height)
}

if p.Scheduler != nil {
s := *p.Scheduler
lp.Scheduler = &s
}

if p.IOPriority != nil {
ioPriority := *p.IOPriority
lp.IOPriority = &ioPriority
}

if p.Capabilities != nil {
lp.Capabilities = &configs.Capabilities{}
lp.Capabilities.Bounding = p.Capabilities.Bounding
Expand Down

0 comments on commit 075da0a

Please sign in to comment.