From 99ac7a7714af5998039244b936b7a0ef3ecfcede Mon Sep 17 00:00:00 2001 From: Merlin Ran Date: Tue, 8 Nov 2022 07:35:32 -0500 Subject: [PATCH] add oci.WithCPURT to set realtime scheduling options. Signed-off-by: Merlin Ran --- oci/spec_opts_linux.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/oci/spec_opts_linux.go b/oci/spec_opts_linux.go index 9ff23519c..a479d4570 100644 --- a/oci/spec_opts_linux.go +++ b/oci/spec_opts_linux.go @@ -130,6 +130,16 @@ func WithCPUCFS(quota int64, period uint64) SpecOpts { } } +// WithCPURT sets the container's realtime scheduling (RT) runtime and period. +func WithCPURT(runtime int64, period uint64) SpecOpts { + return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error { + setCPU(s) + s.Linux.Resources.CPU.RealtimeRuntime = &runtime + s.Linux.Resources.CPU.RealtimePeriod = &period + return nil + } +} + // WithAllCurrentCapabilities propagates the effective capabilities of the caller process to the container process. // The capability set may differ from WithAllKnownCapabilities when running in a container. var WithAllCurrentCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {