openEuler 20.03
Installing the VM Software Packages
- 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
- 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

- (Optional) Modify the QEMU configuration file to configure the permission.If the system does not display a permission error, skip this step.
- Open the qemu.conf file.
1vim /etc/libvirt/qemu.conf - 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.

- Press Esc to exit the insert mode. Input :wq! and press Enter to save the file and exit.
- Restart the libvirtd service.
1systemctl restart libvirtd
- Open the qemu.conf file.
Creating VMs Running CentOS 7.6
- 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
- Install the VM OS.

- 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.

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

- Repeat 1 to 4 to create VM 2.
Configuring the VMs
- Modify the configuration of VM 1.
1virsh 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.
- 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.
Parent topic: Creating a VM