CentOS 7.6
Installing the VM Software Packages
- Install the VM dependencies.
1 2
yum install centos-release-qemu-ev yum install -y libvirt AAVMF virt-install qemu-guest-agent
- Upload the qemu-2.12.0 software packages obtained in OS and Software to the server and install them.
1yum localinstall -y *.rpm
Software packages:

- Modify the QEMU configuration file.
- Open the qemu.conf file.
1vim /etc/libvirt/qemu.conf - Locate the content that needs to be modified. Change user = "root" and group = "root".
user = "root" # The group for QEMU processes run by the system instance. It can be # specified in a similar way to user. group = "root" # Whether libvirt should dynamically change file ownership
- Open the qemu.conf file.
Creating VMs
- Start the libvirtd service and enable the libvirtd service to automatically start upon system startup.
1 2
systemctl start libvirtd systemctl enable libvirtd
- Create a storage pool.
- Create a storage pool directory and configure the directory permission.
1 2 3
mkdir -p /home/kvm/images chown root:root /home/kvm/images chmod 755 /home/kvm/images
- Define a storage pool and bind it to the storage pool directory. Create a folder-based storage pool, activate it, and set it to start upon system boot.
1 2 3 4
virsh pool-define-as StoragePool --type dir --target /home/kvm/images virsh pool-build StoragePool virsh pool-start StoragePool virsh pool-autostart StoragePool
- View the storage pool information.
1 2
virsh pool-info StoragePool virsh pool-list
- Create a storage pool directory and configure the directory permission.
- Create a drive space for the VM.
- Create a volume.
For example, the volume name is 1.img, the storage pool is StoragePool, the volume capacity is 50 GB, the initially allocated capacity is 1 GB, the file format is qcow2, and the drive file format is qcow2.
1virsh vol-create-as --pool StoragePool --name 1.img --capacity 50G --allocation 1G --format qcow2
- View the volume information.
1virsh vol-info /home/kvm/images/1.img

- Create a volume.
- Create VMs.
- Create VM 1. Allocate four CPUs and 8 GB memory to it, and use 1.img as the drive space. Copy the .iso file to /home/iso/ and install CentOS 7.6.
1 2 3
virt-install --name=vm1 --vcpus=4 --ram=8192 \ --disk path=/home/kvm/images/1.img,format=qcow2,size=50,bus=virtio \ --cdrom /home/iso/CentOS-7-aarch64-Everything-1810.iso
- 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.
- Create VM 1. Allocate four CPUs and 8 GB memory to it, and use 1.img as the drive space. Copy the .iso file to /home/iso/ and install CentOS 7.6.
- 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.
The following figure shows the VM settings after modification:

- 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

