mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Merge pull request #4459 from kolyshkin/prio-nits
Fixups to scheduler/priority settings
This commit is contained in:
@@ -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 (
|
||||
|
||||
@@ -406,5 +406,13 @@ func ioPriority(config *configs.Config) error {
|
||||
if priority < 0 || priority > 7 {
|
||||
return fmt.Errorf("invalid ioPriority.Priority: %d", priority)
|
||||
}
|
||||
|
||||
switch class := config.IOPriority.Class; class {
|
||||
case specs.IOPRIO_CLASS_RT, specs.IOPRIO_CLASS_BE, specs.IOPRIO_CLASS_IDLE:
|
||||
// Valid class, do nothing.
|
||||
default:
|
||||
return fmt.Errorf("invalid ioPriority.Class: %q", class)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -847,15 +847,21 @@ func TestValidateIOPriority(t *testing.T) {
|
||||
testCases := []struct {
|
||||
isErr bool
|
||||
priority int
|
||||
class specs.IOPriorityClass
|
||||
}{
|
||||
{isErr: false, priority: 0},
|
||||
{isErr: false, priority: 7},
|
||||
{isErr: true, priority: -1},
|
||||
{isErr: false, priority: 0, class: specs.IOPRIO_CLASS_IDLE},
|
||||
{isErr: false, priority: 7, class: specs.IOPRIO_CLASS_RT},
|
||||
{isErr: false, priority: 3, class: specs.IOPRIO_CLASS_BE},
|
||||
// Invalid priority.
|
||||
{isErr: true, priority: -1, class: specs.IOPRIO_CLASS_BE},
|
||||
// Invalid class.
|
||||
{isErr: true, priority: 3, class: specs.IOPriorityClass("IOPRIO_CLASS_WOW")},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
ioPriroty := configs.IOPriority{
|
||||
Priority: tc.priority,
|
||||
Class: tc.class,
|
||||
}
|
||||
config := &configs.Config{
|
||||
Rootfs: "/var",
|
||||
|
||||
Reference in New Issue
Block a user