cpupin in openstack memo

As we tested, when VCPU is less than CPU, if we bind vcpu to cpu, the perfromance of VM will be better. So we want to add this into Openstack as extended API.
The following memo is what in my mind now:

API :
1. Set instance vcpupin api:
PUT    v2/{tenant_id}/vcpupin/{instance_id}       Set instance vcpupin

Request parameters JSON:
{
    "vcpupin" : [
        {
             vcpu     : 0                  # VCPU    
             cpulist  : "1,2"              # CPU List , This sample means VCPU0 can run in CPU1 and CPU2
        },
        {
             vcpu     : 1                  # VCPU    
             cpulist  : "3"                # CPU List , This sample means VCPU1 can run in CPU3
        }       
    ]
}


2. Get instance vcpupin api:
GET    v2/{tenant_id}/vcpupin/{instance_id}       Get instance vcpupin status

Response parameters JSON:
{
    "vcpupin" : [
        {
             vcpu       : 0                # VCPU    
             currentcpu : 1                # VCPU is running on which CPU
             state      : "running"        # State
             cputime    : "946.4"          # cpu time, 946.4 means 946.4sec
             cpulist    : "1,2"            # CPU List , This sample means VCPU0 can run in CPU1 and CPU2
        },
        {
             vcpu       : 1                # VCPU    
             currentcpu : 3                # VCPU is running on which CPU
             state      : "running"        # State
             cputime    : "1001.2"         # cpu time, 1001.2 means 1001.2sec
             cpulist    : "3"              # CPU List , This sample means VCPU1 can run in CPU3
        }       
    ]
}


Function:
1. Basic call flow:
api/CLI client ----HTTP call----> nova-api  ----MQ:asyc call----> nova-compute

2. Set instance vcpupin :
In nova-compute, call API/CLI do the thing like following:
Before cpupin:
[root@ci13sjcmp03 ~]# virsh vcpuinfo 1  <---1 is instance domain
VCPU:           0     
CPU:            1   
State:          running 
CPU time:       1.3s
CPU Affinity:   yyyyyyyy      <-- VCPU0 can run on CPU0-CPU8

Run cpupin:
[root@ci13sjcmp03 ~]# virsh  vcpupin 1  0 1  

After cpupin:
[root@ci13sjcmp03 ~]# virsh vcpuinfo 1
VCPU:           0     
CPU:            1   
State:          running 
CPU time:       1.3s
CPU Affinity:   -y------      <-- VCPU0 can only run on CPU1

3. Get instance vcpupin :
In nova-compute, call API/CLI do the thing like following:
[root@ci13sjcmp03 ~]# virsh vcpuinfo 1
VCPU:           0     
CPU:            1   
State:          running 
CPU time:       1.3s
CPU Affinity:   -y------ 






你可能感兴趣的:(api,openstack,performance,Extended,cpu绑定)