virtcontainers: agent: fix CPU hot plug race condition

Communicate to the agent the number of vCPUs that were hot added,
allowing to the agent wait for the creation of all vCPUs.

fixes #90

Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
Julio Montes 2018-03-20 15:28:12 -06:00
parent 9db9b286e3
commit 8c9c7ddef8
5 changed files with 10 additions and 6 deletions

View File

@ -175,5 +175,6 @@ type agent interface {
// onlineCPUMem will online CPUs and Memory inside the Sandbox.
// This function should be called after hot adding vCPUs or Memory.
onlineCPUMem() error
// cpus specifies the number of CPUs that were added and the agent should online
onlineCPUMem(cpus uint32) error
}

View File

@ -856,7 +856,7 @@ func (c *Container) addResources() error {
return err
}
return c.sandbox.agent.onlineCPUMem()
return c.sandbox.agent.onlineCPUMem(uint32(vCPUs))
}
return nil

View File

@ -808,7 +808,7 @@ func (h *hyper) sendCmd(proxyCmd hyperstartProxyCmd) (interface{}, error) {
return h.client.HyperWithTokens(proxyCmd.cmd, tokens, proxyCmd.message)
}
func (h *hyper) onlineCPUMem() error {
func (h *hyper) onlineCPUMem(cpus uint32) error {
// cc-agent uses udev to online CPUs automatically
return nil
}

View File

@ -877,8 +877,11 @@ func (k *kataAgent) processListContainer(sandbox Sandbox, c Container, options P
return nil, nil
}
func (k *kataAgent) onlineCPUMem() error {
req := &grpc.OnlineCPUMemRequest{}
func (k *kataAgent) onlineCPUMem(cpus uint32) error {
req := &grpc.OnlineCPUMemRequest{
Wait: false,
NbCpus: cpus,
}
_, err := k.sendReq(req)
return err

View File

@ -81,6 +81,6 @@ func (n *noopAgent) processListContainer(sandbox Sandbox, c Container, options P
}
// onlineCPUMem is the Noop agent Container online CPU and Memory implementation. It does nothing.
func (n *noopAgent) onlineCPUMem() error {
func (n *noopAgent) onlineCPUMem(cpus uint32) error {
return nil
}