From 2946db890374710e3efbb922354d0f77a02f5cb7 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Wed, 7 Apr 2021 10:51:42 +0300 Subject: [PATCH] oci: implement WithRdt Helper for setting the (Linux) container's RDT parameters. Signed-off-by: Markus Lehtonen --- oci/spec_opts_linux.go | 12 ++++++++++++ oci/spec_opts_nonlinux.go | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/oci/spec_opts_linux.go b/oci/spec_opts_linux.go index ecf7b022a..4d8841ee1 100644 --- a/oci/spec_opts_linux.go +++ b/oci/spec_opts_linux.go @@ -141,3 +141,15 @@ var WithAllKnownCapabilities = func(ctx context.Context, client Client, c *conta func WithoutRunMount(ctx context.Context, client Client, c *containers.Container, s *Spec) error { return WithoutMounts("/run")(ctx, client, c, s) } + +// WithRdt sets the container's RDT parameters +func WithRdt(closID, l3CacheSchema, memBwSchema string) SpecOpts { + return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error { + s.Linux.IntelRdt = &specs.LinuxIntelRdt{ + ClosID: closID, + L3CacheSchema: l3CacheSchema, + MemBwSchema: memBwSchema, + } + return nil + } +} diff --git a/oci/spec_opts_nonlinux.go b/oci/spec_opts_nonlinux.go index db37651b3..b241e384f 100644 --- a/oci/spec_opts_nonlinux.go +++ b/oci/spec_opts_nonlinux.go @@ -23,6 +23,7 @@ import ( "context" "github.com/containerd/containerd/containers" + "github.com/pkg/errors" ) // WithAllCurrentCapabilities propagates the effective capabilities of the caller process to the container process. @@ -45,3 +46,10 @@ func WithCPUShares(shares uint64) SpecOpts { return nil } } + +// WithRdt sets the container's RDT parameters +func WithRdt(closID, l3CacheSchema, memBwSchema string) SpecOpts { + return func(_ context.Context, _ Client, _ *containers.Container, _ *Spec) error { + return errors.New("RDT not supported") + } +}