From: Arnaud Rebillout <arnaud.rebillout@collabora.com>
Date: Thu, 24 Jan 2019 09:55:02 +0700
Subject: Allow build of runc 1.0.0-rc6

This patch basically imports the upstream commit "Add Intel RDT/MBA
Linux support", minus the documentation changes. See the full commit at:
<https://github.com/opencontainers/runtime-spec/commit/5d9aa69b>

This is needed to build runc 1.0.0-rc6, and more specifically for the
series of commits "Intel RDT/MBA support for OCI/runc and Docker". For
more details:
- Proposal: <https://github.com/opencontainers/runc/issues/1596>
- Pull req: <https://github.com/opencontainers/runc/pull/1632>

As usual, we're doing our best to preserve integrity of major releases
of dependency packages. In this particular case, this new feature is
included in runc 1.0.0-rc6, but depends on an unreleased change in
runtime-spec. The best solution would be to patch the feature out of
runc, but it doesn't seem to be an easy patch. So instead, we prefer to
import the particular commit that adds this feature to runtime-spec, as
it seems to be easier.

Even though, the patch doesn't apply "as is", due to other changes that
were made upstream before 5d9aa69b:
- config-linux.json: 4e5a137f (Jan. 2018)
  "Completely drop our JSON Schema 'id' properties"
- config.go: 06cf8993 (Aug. 2018)
  "add Intel RDT CLOS name sharing support"

Origin: vendor, Debian
Forwarded: not-needed, Debian-specific
--- a/schema/config-linux.json
+++ b/schema/config-linux.json
@@ -273,6 +273,11 @@
                     "l3CacheSchema": {
                         "id": "https://opencontainers.org/schema/bundle/linux/intelRdt/l3CacheSchema",
                         "type": "string"
+                    },
+                    "memBwSchema": {
+                        "id": "https://opencontainers.org/schema/bundle/linux/intelRdt/memBwSchema",
+                        "type": "string",
+                        "pattern": "^MB:[^\\n]*$"
                     }
                 }
             }
--- a/specs-go/config.go
+++ b/specs-go/config.go
@@ -158,8 +158,8 @@
 	ReadonlyPaths []string `json:"readonlyPaths,omitempty"`
 	// MountLabel specifies the selinux context for the mounts in the container.
 	MountLabel string `json:"mountLabel,omitempty"`
-	// IntelRdt contains Intel Resource Director Technology (RDT) information
-	// for handling resource constraints (e.g., L3 cache) for the container
+	// IntelRdt contains Intel Resource Director Technology (RDT) information for
+	// handling resource constraints (e.g., L3 cache, memory bandwidth) for the container
 	IntelRdt *LinuxIntelRdt `json:"intelRdt,omitempty"`
 }
 
@@ -561,10 +561,14 @@
 	Args   []LinuxSeccompArg  `json:"args,omitempty"`
 }
 
-// LinuxIntelRdt has container runtime resource constraints
-// for Intel RDT/CAT which introduced in Linux 4.10 kernel
+// LinuxIntelRdt has container runtime resource constraints for Intel RDT
+// CAT and MBA features which introduced in Linux 4.10 and 4.12 kernel
 type LinuxIntelRdt struct {
 	// The schema for L3 cache id and capacity bitmask (CBM)
 	// Format: "L3:<cache_id0>=<cbm0>;<cache_id1>=<cbm1>;..."
 	L3CacheSchema string `json:"l3CacheSchema,omitempty"`
+
+	// The schema of memory bandwidth percentage per L3 cache id
+	// Format: "MB:<cache_id0>=bandwidth0;<cache_id1>=bandwidth1;..."
+	MemBwSchema string `json:"memBwSchema,omitempty"`
 }
