|
9 | 9 | "strconv" |
10 | 10 |
|
11 | 11 | "github.com/docker/go-units" |
| 12 | + "github.com/opencontainers/runc/libcontainer/configs" |
| 13 | + "github.com/opencontainers/runc/libcontainer/intelrdt" |
12 | 14 | "github.com/opencontainers/runtime-spec/specs-go" |
13 | 15 | "github.com/urfave/cli" |
14 | 16 | ) |
@@ -112,6 +114,10 @@ other options are ignored. |
112 | 114 | Name: "pids-limit", |
113 | 115 | Usage: "Maximum number of pids allowed in the container", |
114 | 116 | }, |
| 117 | + cli.StringFlag{ |
| 118 | + Name: "l3-cache-schema", |
| 119 | + Usage: "The string of Intel RDT/CAT L3 cache schema", |
| 120 | + }, |
115 | 121 | }, |
116 | 122 | Action: func(context *cli.Context) error { |
117 | 123 | if err := checkArgs(context, 1, exactArgs); err != nil { |
@@ -254,6 +260,34 @@ other options are ignored. |
254 | 260 | config.Cgroups.Resources.MemorySwap = *r.Memory.Swap |
255 | 261 | config.Cgroups.Resources.PidsLimit = r.Pids.Limit |
256 | 262 |
|
| 263 | + // Update Intel RDT/CAT |
| 264 | + if val := context.String("l3-cache-schema"); val != "" { |
| 265 | + if !intelrdt.IsEnabled() { |
| 266 | + return fmt.Errorf("Intel RDT: l3 cache schema is not enabled") |
| 267 | + } |
| 268 | + |
| 269 | + // If intelRdt is not specified in original configuration, we just don't |
| 270 | + // Apply() to create intelRdt group or attach tasks for this container. |
| 271 | + // In update command, we could re-enable through IntelRdtManager.Apply() |
| 272 | + // and then update intelrdt constraint. |
| 273 | + if config.IntelRdt == nil { |
| 274 | + state, err := container.State() |
| 275 | + if err != nil { |
| 276 | + return err |
| 277 | + } |
| 278 | + config.IntelRdt = &configs.IntelRdt{} |
| 279 | + intelRdtManager := intelrdt.IntelRdtManager{ |
| 280 | + Config: &config, |
| 281 | + Id: container.ID(), |
| 282 | + Path: state.IntelRdtPath, |
| 283 | + } |
| 284 | + if err := intelRdtManager.Apply(state.InitProcessPid); err != nil { |
| 285 | + return err |
| 286 | + } |
| 287 | + } |
| 288 | + config.IntelRdt.L3CacheSchema = val |
| 289 | + } |
| 290 | + |
257 | 291 | return container.Set(config) |
258 | 292 | }, |
259 | 293 | } |
0 commit comments