From d89217515b4b35db2ad6c2000f36840a7c1dcb06 Mon Sep 17 00:00:00 2001 From: Xiaochen Shen Date: Tue, 17 Oct 2017 16:08:48 +0800 Subject: [PATCH] libcontainer: intelrdt: fix a GetStats() issue This fixes a GetStats() issue introduced in #1590: If Intel RDT is enabled by hardware and kernel, but intelRdt is not specified in original config, GetStats() will return error unexpectedly because we haven't called Apply() to create intelrdt group or attach tasks for this container. As a result, runc events command will have no output. Signed-off-by: Xiaochen Shen --- libcontainer/intelrdt/intelrdt.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libcontainer/intelrdt/intelrdt.go b/libcontainer/intelrdt/intelrdt.go index ebb68f948c6..487c630af61 100644 --- a/libcontainer/intelrdt/intelrdt.go +++ b/libcontainer/intelrdt/intelrdt.go @@ -443,6 +443,11 @@ func (m *IntelRdtManager) GetPath() string { // Returns statistics for Intel RDT func (m *IntelRdtManager) GetStats() (*Stats, error) { + // If intelRdt is not specified in config + if m.Config.IntelRdt == nil { + return nil, nil + } + m.mu.Lock() defer m.mu.Unlock() stats := NewStats()