From a21d1e693f2141fc323722f0bd15c576e6e4d18f Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 19 Dec 2018 14:06:40 -0800 Subject: [PATCH] virtcontainers: cgroups: Don't error if no thread ID In case the hypervisor implementation does not return any thread ID, this should not issue any error since there is simply nothing to constrain. Fixes #1062 Signed-off-by: Sebastien Boeuf --- virtcontainers/cgroups.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/virtcontainers/cgroups.go b/virtcontainers/cgroups.go index 9ad0e8e2f6..20fa6b07bc 100644 --- a/virtcontainers/cgroups.go +++ b/virtcontainers/cgroups.go @@ -100,9 +100,15 @@ func (s *Sandbox) applyCPUCgroup(rc *specs.LinuxResources) error { // when new container joins, new CPU could be hotplugged, so we // have to query fresh vcpu info from hypervisor for every time. tids, err := s.hypervisor.getThreadIDs() - if err != nil || tids == nil { + if err != nil { return fmt.Errorf("failed to get thread ids from hypervisor: %v", err) } + if tids == nil { + // If there's no tid returned from the hypervisor, this is not + // a bug. It simply means there is nothing to constrain, hence + // let's return without any error from here. + return nil + } // use Add() to add vcpu thread to s.cgroup, it will write thread id to // `cgroup.procs` which will move all threads in qemu process to this cgroup