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