Rate This Document
Findability
Accuracy
Completeness
Readability

Modifying XML Settings of a VM

Procedure

  • The name of a VM's XML file inherits the name of the VM created in Installing a VM. For example, if the name of the VM is openEuler, the XML file name is openEuler.xml.
  • Modify the VM's XML file based on your requirements. Note that vhost.* must correspond to the FD file of the device in use.
  1. Open the VM's XML file and add the following content to the end of the <disk> code block:
    1
    2
    3
    4
    5
    6
    7
        <disk type='vhostuser' device='disk' snapshot='no'>
          <driver name='qemu' type='raw' queues='4'/>
          <source type='unix' path='/var/tmp/vhost.0'>
            <reconnect enabled='yes' timeout='10'/>
          </source>
          <target dev='vdb' bus='virtio'/>
        </disk>
    

    Modify the XML settings of a single VM or multiple VMs as required to mount devices.

    • The value of queues cannot exceed the number of CPUs on the VM. Otherwise, the VM cannot be started.
    • If you run the virsh edit command to modify the VM XML file and add the vhostuser disk function block, the modification may fail to be saved. You can add the vhostuser disk function block by redefining the VM.
  2. Open the XML file and add the following content to the end of the </currentMemory> code block:
    1
    2
    3
    4
    5
    6
      <memoryBacking>
        <hugepages/>
        <source type='file'/>
        <access mode='shared'/>
        <allocation mode='immediate'/>
      </memoryBacking>
    
  3. Open the XML file and modify the <cpu mode...> code block as follows:
    1
    2
    3
    4
    5
      <cpu mode='host-passthrough' check='none'>
        <numa>
          <cell id='0' memory='8388608' unit='KiB' memAccess='shared'/>
        </numa>
      </cpu>