Rate This Document
Findability
Accuracy
Completeness
Readability

openEuler 20.03

Installing the VM Software Packages

  1. Download the dependencies.
    yum install -y openssl-devel virt-install numactl numactl-devel libcap-ng-devel traceroute iperf3 python2-paramiko edk2 edk2-devel qemu-guest-agent
  2. Create a storage pool.
    systemctl start libvirtd
    mkdir -p /home/kvm/images
    chown root:root /home/kvm/images
    chmod 755 /home/kvm/images
    virsh pool-define-as StoragePool --type dir --target /home/kvm/images
    virsh pool-build StoragePool
    virsh pool-start StoragePool
    virsh pool-autostart StoragePool
    cd /home/kvm/images
    qemu-img create -f qcow2 1.img 50G

  3. (Optional) Modify the QEMU configuration file to configure the permission.
    If the system does not display a permission error, skip this step.
    1. Open the qemu.conf file.
      1
      vim /etc/libvirt/qemu.conf
      
    2. Press I to enter the insert mode, locate the content to be modified, and set user = "root" and group = "root", as shown in the following figure.

    3. Press Esc to exit the insert mode. Input :wq! and press Enter to save the file and exit.
    4. Restart the libvirtd service.
      1
      systemctl restart libvirtd
      

Creating VMs Running CentOS 7.6

  1. Create VM 1. Allocate four CPUs and 4 GB memory to it, and use 1.img as the drive space. Copy the .iso file to /home/iso/ and install CentOS 7.6.
    virt-install --name=vm1 --vcpus=4 --ram=4096 --disk path=/home/kvm/images/1.img,format=qcow2,size=20,bus=virtio --cdrom /home/iso/CentOS-7-aarch64-Everything-1810.iso --network bridge=virbr0,model=virtio --force  --autostart
  2. Install the VM OS.

  3. Configure all items that contain an exclamation mark (!). Enter the serial number corresponding to the option, configure the parameter as prompted, and press b to start the installation.

  4. After the installation is complete, the login prompt is displayed.

  5. Repeat 1 to 4 to create VM 2.

Configuring the VMs

  1. Modify the configuration of VM 1.
    1
    virsh edit vm1
    
    Delete <interface type='network'>xxx</interface>. Add the following content before </devices>:
    1
    2
    3
    4
    5
    <hostdev mode='subsystem' type='pci' managed='yes'>
    <source>
    <address domain='0x0000' bus='0x01' slot='0x01' function='0x2'/>
    </source>
    </hostdev>
    

    The values of domain, bus, slot, and function in <address domain='0x0000' bus='0x01' slot='0x01' function='0x2'/> correspond to PCI port 0000:01:01.2 of the VF.

  2. Modify the configuration of VM 2 in the same way.

    When configuring the PCI port numbers for the other VMs, bind the PCI port numbers to VF ports that are not in use.