Jump to: navigation, search

Nova/add-support-for-cpu-hotadd

CPU Hot-plug Support - API and Features

Background

Currently we can change the flavor and rebuilt the instance to add CPUs. It is not support adding CPUs to a running instance without of rebuilt it to effect. We should have the ability add CPUs immediately without the instance's state is changed.

User Case

In the communication scenario ,our mobile network is composed by mobile phone, wireless network, transfer network and core network.The core network is basically work for handling call request, call switch, value-add service and charge service. The most important of all is the charge service because is concern about money. During the call procession, the charge service begin a charge process when receive a charge request as a call begins, and plus every value-add service the caller used to the bill. As the call ends, the charge service will generate a bill of this call.This process could be very long (to several hours), and the charge service should not be paused. This service also cannot be load balanced by many services too because of some authentication reason.

Large number of people make telephone calls to each other when the New Years Day comes. This will generate huge number of call bills. If the charge requests exceed the capability of charge service could process, the new call request will be rejected, probably, and this will lose lot of incomes. To the worst situation ,the service might be blocked even cause reboot. I order to avoid this situation, currently there are two options to deal with this problem. First, we build multiple charge service in the core network, this will make the network more complicated. Another option is control the flow limit, this will reject many call request, a lot of people would not make a call, the network service provider lose many incomes, and people will lose their confidence to the network service provider.

For this scenario, if we got a vCPU hot plug feature, this could be no problem. During ordinary days, the charge service got CPUs it needs. In holidays and festival days, we hot plug more vCPUs to the charge service to enhance the capability of the service. After the holidays, this added CPUs could be idle, we could hot remove these vCPUs to other services.This operation will improve our CPU utilization.

CPU hotplug APIs Based on KVM

1. Add extra key to flavor to define the instance's current CPU.

For example:

key:"cpu:current"

value:"2"

Create VM with max VCPU in flavor.

The instance's XML looks like:

< vcpu current="2">4</vcpu>


2. Set metadata of the image if the image has installed qemu-guest-agent.

nova image-meta {image_id} set hw_qemu_guest_agent=yes


3. Provide the API of setting the new CPU of the instance.

For example:

POST v2/{tenant_id}/servers/{server_id}/action

{

   "cpu_hotplug": {
       "vcpus": 3
   }

}

The 'vcpus' stands the new CPU which the instance has.


4. Add hot-add VCPU in libvirt driver Add method use libvirt API of setVcpusFlags.

Note

For the hotplug to work,please make sure your QEMU version >= 1.5.0 and the version of libvirt >= 1.1.0.