From ec465d39f5b97ffb3b52539659f536fdf09027be Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 26 Jun 2024 16:17:36 -0700 Subject: [PATCH] utils: simplify newProcess This code is not in libcontainer, meaning it is only used by a short lived binary (runc start/run/exec). Unlike code in libcontainer (see CreateLibcontainerConfig), here we don't have to care about copying the structures supplied as input, meaning we can just reuse the pointers directly. Fixes: bfbd0305 ("Add I/O priority") Fixes: 770728e1 ("Support `process.scheduler`") Signed-off-by: Kir Kolyshkin --- utils_linux.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/utils_linux.go b/utils_linux.go index feb6ef80c..eef78ea38 100644 --- a/utils_linux.go +++ b/utils_linux.go @@ -55,6 +55,8 @@ 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 { @@ -62,16 +64,6 @@ func newProcess(p specs.Process) (*libcontainer.Process, error) { 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