Rate This Document
Findability
Accuracy
Completeness
Readability

Modifying the VM Configuration File

This section describes how to tune Nginx VM scenarios. Skip this section in other scenarios.

Purpose

Configure the CPU, memory, and network of a VM.

Procedure

  1. Edit the VM configuration file.

    The following uses vm1 as an example.

    1
    virsh edit vm1
    
  2. Bind the vCPU to the physical CPU.
    <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>

    Table 1 describes the parameters.

    Table 1 Parameters for binding a vCPU to a physical CPU

    Parameter

    Description

    cpuset

    Specifies the physical core.

    vcpu

    Specifies the virtual core.

  3. Configure NUMA binding.
    <numatune>
    <memory mode='strict' nodeset='0'/>
    </numatune>

    Table 1 describes the parameters.

    nodeset: specifies the NUMA node of the physical machine.

  4. Configure PCIe NIC passthrough.
    <hostdev mode='subsystem' type='pci' managed='yes'>
    <source>
    <address domain='0x0000' bus='0x82' slot='0x00' function='0x0'/>
    </source>
    </hostdev>

    In the preceding command, domain, bus, slot, and function indicate the physical NIC information. You can run the lspci or ethtool -i NIC name command to view the information.

    1
    lspci
    

    Pay attention only to the leftmost number in the command output.

    "82:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (4*25GE) (rev 45)"

    In the preceding information, bus-info of the NIC is a hexadecimal number. According to 82:00.0, bus='0x82', slot='0x00', function='0x0', and domain='0x0000'.

    If the VM is started and has the OS installed before NIC passthrough is configured on the physical machine (host machine) for the VM, you need to install the NIC driver on the VM. For details, see the procedure of installing a physical machine.