From 0916bb6fe382e4d1ed44673aa92ac1b0f611436e Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Fri, 16 Mar 2018 15:38:24 -0600 Subject: [PATCH] virtcontainers: agent: use onlineCPUMem to online vCPUs After hot adding vCPUs in the POD, agent's funtion `onlineCPUMem` must be called to request the agent to online the vCPUs fixes #67 Signed-off-by: Julio Montes --- virtcontainers/agent.go | 4 ++++ virtcontainers/container.go | 2 ++ virtcontainers/hyperstart_agent.go | 5 +++++ virtcontainers/kata_agent.go | 9 +++++++++ virtcontainers/noop_agent.go | 5 +++++ 5 files changed, 25 insertions(+) diff --git a/virtcontainers/agent.go b/virtcontainers/agent.go index 2a0acc457..a25e4d484 100644 --- a/virtcontainers/agent.go +++ b/virtcontainers/agent.go @@ -172,4 +172,8 @@ type agent interface { // processListContainer will list the processes running inside the container processListContainer(pod Pod, c Container, options ProcessListOptions) (ProcessList, error) + + // onlineCPUMem will online CPUs and Memory inside the Pod. + // This function should be called after hot adding vCPUs or Memory. + onlineCPUMem() error } diff --git a/virtcontainers/container.go b/virtcontainers/container.go index c91fbba0d..53053bd02 100644 --- a/virtcontainers/container.go +++ b/virtcontainers/container.go @@ -791,6 +791,8 @@ func (c *Container) addResources() error { if err := c.pod.hypervisor.hotplugAddDevice(uint32(vCPUs), cpuDev); err != nil { return err } + + return c.pod.agent.onlineCPUMem() } return nil diff --git a/virtcontainers/hyperstart_agent.go b/virtcontainers/hyperstart_agent.go index 251e705ea..715d9cdd1 100644 --- a/virtcontainers/hyperstart_agent.go +++ b/virtcontainers/hyperstart_agent.go @@ -798,3 +798,8 @@ func (h *hyper) sendCmd(proxyCmd hyperstartProxyCmd) (interface{}, error) { return h.client.HyperWithTokens(proxyCmd.cmd, tokens, proxyCmd.message) } + +func (h *hyper) onlineCPUMem() error { + // cc-agent uses udev to online CPUs automatically + return nil +} diff --git a/virtcontainers/kata_agent.go b/virtcontainers/kata_agent.go index 5df14e9d4..39e147ce8 100644 --- a/virtcontainers/kata_agent.go +++ b/virtcontainers/kata_agent.go @@ -792,6 +792,13 @@ func (k *kataAgent) processListContainer(pod Pod, c Container, options ProcessLi return nil, nil } +func (k *kataAgent) onlineCPUMem() error { + req := &grpc.OnlineCPUMemRequest{} + + _, err := k.sendReq(req) + return err +} + func (k *kataAgent) connect() error { if k.client != nil { return nil @@ -855,6 +862,8 @@ func (k *kataAgent) sendReq(request interface{}) (interface{}, error) { case *grpc.UpdateInterfaceRequest: ifc, err := k.client.UpdateInterface(context.Background(), req) return ifc, err + case *grpc.OnlineCPUMemRequest: + return k.client.OnlineCPUMem(context.Background(), req) default: return nil, fmt.Errorf("Unknown gRPC type %T", req) } diff --git a/virtcontainers/noop_agent.go b/virtcontainers/noop_agent.go index 136831fc0..13d7a2e78 100644 --- a/virtcontainers/noop_agent.go +++ b/virtcontainers/noop_agent.go @@ -79,3 +79,8 @@ func (n *noopAgent) killContainer(pod Pod, c Container, signal syscall.Signal, a func (n *noopAgent) processListContainer(pod Pod, c Container, options ProcessListOptions) (ProcessList, error) { return nil, nil } + +// onlineCPUMem is the Noop agent Container online CPU and Memory implementation. It does nothing. +func (n *noopAgent) onlineCPUMem() error { + return nil +}