我要评分
获取效率
正确性
完整性
易理解

Configuring the VM

Use the virsh edit vmx command to edit the VM configuration file. In the command, vmx indicates the VM name. Note that the modification takes effect after the VM is stopped and then started.

Binding VM CPUs

Bind the vCPUs of the VM to the physical CPUs of an NUMA node.

The following describes how to bind the four vCPUs of a VM to physical cores 0, 1, 2, and 3 respectively.

  1. Open the configuration file in edit mode.
    1
    virsh edit vmx
    
  2. Add the following CPU information to the file:
    1
    2
    3
    4
    5
    6
    7
    <cputune>
      <vcpupin vcpu='0' cpuset='0'/>
      <vcpupin vcpu='1' cpuset='1'/>
      <vcpupin vcpu='2' cpuset='2'/>
      <vcpupin vcpu='3' cpuset='3'/>
      <emulatorpin cpuset='0-3'/>
    </cputune>
    

    After the configuration, the vCPU threads of the VM run on the physical CPU of the specified host.

  3. Press Esc, type :wq!, and press Enter to save the file and exit.
  4. Check the CPU basic information.
    1
    virsh vcpuinfo vmx
    

Binding Memory

Bind the memory to the same NUMA node as the vCPUs.

  1. Open the configuration file in edit mode.
    1
    virsh edit vmx
    
  2. Add the following memory information to the file:
    1
    2
    3
    <numatune>
      <memory mode='strict' nodeset='0'/>
    </numatune>
    

  3. Press Esc, type :wq!, and press Enter to save the file and exit.