diff --git a/libcontainer/configs/config.go b/libcontainer/configs/config.go index 22fe0f9b4c1..4436aaa0cfa 100644 --- a/libcontainer/configs/config.go +++ b/libcontainer/configs/config.go @@ -286,12 +286,6 @@ func ToSchedAttr(scheduler *Scheduler) (*unix.SchedAttr, error) { }, nil } -var IOPrioClassMapping = map[specs.IOPriorityClass]int{ - specs.IOPRIO_CLASS_RT: 1, - specs.IOPRIO_CLASS_BE: 2, - specs.IOPRIO_CLASS_IDLE: 3, -} - type IOPriority = specs.LinuxIOPriority type ( diff --git a/libcontainer/init_linux.go b/libcontainer/init_linux.go index 2e1397d1e97..d712f005e45 100644 --- a/libcontainer/init_linux.go +++ b/libcontainer/init_linux.go @@ -684,8 +684,15 @@ func setIOPriority(ioprio *configs.IOPriority) error { if ioprio == nil { return nil } - class, ok := configs.IOPrioClassMapping[ioprio.Class] - if !ok { + class := 0 + switch ioprio.Class { + case specs.IOPRIO_CLASS_RT: + class = 1 + case specs.IOPRIO_CLASS_BE: + class = 2 + case specs.IOPRIO_CLASS_IDLE: + class = 3 + default: return fmt.Errorf("invalid io priority class: %s", ioprio.Class) }