Merge pull request #68 from devimc/agent/onlineCPUs

virtcontainers: agent: use onlineCPUMem to online vCPUs
This commit is contained in:
Peng Tao 2018-03-21 10:42:25 +08:00 committed by GitHub
commit 6d05197625
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 0 deletions

View File

@ -172,4 +172,8 @@ type agent interface {
// processListContainer will list the processes running inside the container // processListContainer will list the processes running inside the container
processListContainer(pod Pod, c Container, options ProcessListOptions) (ProcessList, error) 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
} }

View File

@ -787,6 +787,8 @@ func (c *Container) addResources() error {
if err := c.pod.hypervisor.hotplugAddDevice(uint32(vCPUs), cpuDev); err != nil { if err := c.pod.hypervisor.hotplugAddDevice(uint32(vCPUs), cpuDev); err != nil {
return err return err
} }
return c.pod.agent.onlineCPUMem()
} }
return nil return nil

View File

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

View File

@ -773,6 +773,13 @@ func (k *kataAgent) processListContainer(pod Pod, c Container, options ProcessLi
return nil, nil return nil, nil
} }
func (k *kataAgent) onlineCPUMem() error {
req := &grpc.OnlineCPUMemRequest{}
_, err := k.sendReq(req)
return err
}
func (k *kataAgent) connect() error { func (k *kataAgent) connect() error {
if k.client != nil { if k.client != nil {
return nil return nil
@ -836,6 +843,8 @@ func (k *kataAgent) sendReq(request interface{}) (interface{}, error) {
case *grpc.UpdateInterfaceRequest: case *grpc.UpdateInterfaceRequest:
ifc, err := k.client.UpdateInterface(context.Background(), req) ifc, err := k.client.UpdateInterface(context.Background(), req)
return ifc, err return ifc, err
case *grpc.OnlineCPUMemRequest:
return k.client.OnlineCPUMem(context.Background(), req)
default: default:
return nil, fmt.Errorf("Unknown gRPC type %T", req) return nil, fmt.Errorf("Unknown gRPC type %T", req)
} }

View File

@ -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) { func (n *noopAgent) processListContainer(pod Pod, c Container, options ProcessListOptions) (ProcessList, error) {
return nil, nil return nil, nil
} }
// onlineCPUMem is the Noop agent Container online CPU and Memory implementation. It does nothing.
func (n *noopAgent) onlineCPUMem() error {
return nil
}