File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import (
2424 "github.com/opencontainers/runc/libcontainer/intelrdt"
2525 "github.com/opencontainers/runc/libcontainer/system"
2626 "github.com/opencontainers/runc/libcontainer/utils"
27+ "github.com/opencontainers/runc/libcontainer/vtpm/vtpm-helper"
2728 "github.com/opencontainers/runtime-spec/specs-go"
2829
2930 "github.com/checkpoint-restore/go-criu/v4"
@@ -391,6 +392,11 @@ func (c *linuxContainer) start(process *Process) error {
391392 return err
392393 }
393394 }
395+ if len (c .config .VTPMs ) > 0 {
396+ if err := vtpmhelper .ApplyCGroupVTPMs (c .config .VTPMs , c .cgroupManager ); err != nil {
397+ return err
398+ }
399+ }
394400 }
395401 return nil
396402}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
1010 "strings"
1111 "syscall"
1212
13+ "github.com/opencontainers/runc/libcontainer/cgroups"
1314 "github.com/opencontainers/runc/libcontainer/configs"
1415 "github.com/opencontainers/runc/libcontainer/vtpm"
1516
@@ -153,3 +154,13 @@ func DestroyVTPMs(vtpms []*vtpm.VTPM) {
153154 vtpm .Stop (vtpm .CreatedStatepath )
154155 }
155156}
157+
158+ // ApplyCGroupVTPMs puts all VTPMs into the given Cgroup manager's cgroup
159+ func ApplyCGroupVTPMs (vtpms []* vtpm.VTPM , cgroupManager cgroups.Manager ) error {
160+ for _ , vtpm := range vtpms {
161+ if err := cgroupManager .Apply (vtpm .Pid ); err != nil {
162+ return fmt .Errorf ("cGroupManager failed to apply vtpm with pid %d: %v" , vtpm .Pid , err )
163+ }
164+ }
165+ return nil
166+ }
You can’t perform that action at this time.
0 commit comments