Rate This Document
Findability
Accuracy
Completeness
Readability

CentOS 7.6

Installing the VM Software Packages

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

    Software packages:

  3. Modify the QEMU configuration file.
    1. Open the qemu.conf file.
      1
      vim /etc/libvirt/qemu.conf
      
    2. 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

Creating VMs

  1. Start the libvirtd service and enable the libvirtd service to automatically start upon system startup.
    1
    2
    systemctl start libvirtd
    systemctl enable libvirtd
    
  2. Create a storage pool.
    1. 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
      
    2. 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
      
    3. View the storage pool information.
      1
      2
      virsh pool-info StoragePool
      virsh pool-list
      
  3. Create a drive space for the VM.
    1. 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.

      1
      virsh vol-create-as --pool StoragePool --name 1.img --capacity 50G --allocation 1G --format qcow2
      
    2. View the volume information.
      1
      virsh vol-info /home/kvm/images/1.img
      

  4. Create VMs.
    1. 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
      
    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.

    The following figure shows the VM settings after modification:

  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.