mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
libcontainer/intelrdt: introduce NewManager()
Introduce NewManager() to wrap up IntelRdtManager initialization. And call it when required. Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com>
This commit is contained in:
@@ -149,11 +149,7 @@ func RootlessCgroupfs(l *LinuxFactory) error {
|
||||
// create and manage Intel RDT resources (e.g., L3 cache, memory bandwidth).
|
||||
func IntelRdtFs(l *LinuxFactory) error {
|
||||
l.NewIntelRdtManager = func(config *configs.Config, id string, path string) intelrdt.Manager {
|
||||
return &intelrdt.IntelRdtManager{
|
||||
Config: config,
|
||||
Id: id,
|
||||
Path: path,
|
||||
}
|
||||
return intelrdt.NewManager(config, id, path)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -172,6 +172,14 @@ type IntelRdtManager struct {
|
||||
Path string
|
||||
}
|
||||
|
||||
func NewManager(config *configs.Config, id string, path string) Manager {
|
||||
return &IntelRdtManager{
|
||||
Config: config,
|
||||
Id: id,
|
||||
Path: path,
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
IntelRdtTasks = "tasks"
|
||||
)
|
||||
|
||||
@@ -26,10 +26,7 @@ func TestIntelRdtSetL3CacheSchema(t *testing.T) {
|
||||
})
|
||||
|
||||
helper.IntelRdtData.config.IntelRdt.L3CacheSchema = l3CacheSchemeAfter
|
||||
intelrdt := &IntelRdtManager{
|
||||
Config: helper.IntelRdtData.config,
|
||||
Path: helper.IntelRdtPath,
|
||||
}
|
||||
intelrdt := NewManager(helper.IntelRdtData.config, "", helper.IntelRdtPath)
|
||||
if err := intelrdt.Set(helper.IntelRdtData.config); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -64,10 +61,7 @@ func TestIntelRdtSetMemBwSchema(t *testing.T) {
|
||||
})
|
||||
|
||||
helper.IntelRdtData.config.IntelRdt.MemBwSchema = memBwSchemeAfter
|
||||
intelrdt := &IntelRdtManager{
|
||||
Config: helper.IntelRdtData.config,
|
||||
Path: helper.IntelRdtPath,
|
||||
}
|
||||
intelrdt := NewManager(helper.IntelRdtData.config, "", helper.IntelRdtPath)
|
||||
if err := intelrdt.Set(helper.IntelRdtData.config); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -102,10 +96,7 @@ func TestIntelRdtSetMemBwScSchema(t *testing.T) {
|
||||
})
|
||||
|
||||
helper.IntelRdtData.config.IntelRdt.MemBwSchema = memBwScSchemeAfter
|
||||
intelrdt := &IntelRdtManager{
|
||||
Config: helper.IntelRdtData.config,
|
||||
Path: helper.IntelRdtPath,
|
||||
}
|
||||
intelrdt := NewManager(helper.IntelRdtData.config, "", helper.IntelRdtPath)
|
||||
if err := intelrdt.Set(helper.IntelRdtData.config); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -317,11 +317,7 @@ other options are ignored.
|
||||
return err
|
||||
}
|
||||
config.IntelRdt = &configs.IntelRdt{}
|
||||
intelRdtManager := intelrdt.IntelRdtManager{
|
||||
Config: &config,
|
||||
Id: container.ID(),
|
||||
Path: state.IntelRdtPath,
|
||||
}
|
||||
intelRdtManager := intelrdt.NewManager(&config, container.ID(), state.IntelRdtPath)
|
||||
if err := intelRdtManager.Apply(state.InitProcessPid); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user