Chapter 2. Enabling virtualization
Chapter 2. Enabling virtualization To use virtualization in RHEL 9, you must install virtualization packages and ensure your system is configured to host virtual machines (VMs). The specific steps to do this vary based on your CPU architecture. 2.1. Enabling virtualization on AMD64 and Intel 64 To set up a KVM hypervisor and create virtual machines (VMs) on an AMD64 or Intel 64 system running RHEL 9, follow the instructions below. Prerequisites Red Hat Enterprise Linux 9 is installed and registered on your host machine. Your system meets the following hardware requirements to work as a virtualization host: The architecture of your host machine supports KVM virtualization . The following minimum system resources are available: 6 GB free disk space for the host, plus another 6 GB for each intended VM. 2 GB of RAM for the host, plus another 2 GB for each intended VM. Procedure Install the virtualization hypervisor packages. Start the virtualization services: # for drv in qemu network nodedev nwfilter secret storage interface; do systemctl start virtUSD{drv}d{,-ro,-admin}.socket; done Verification Verify that your system is prepared to be a virtualization host: # virt-host-validate [...] QEMU: Checking for device assignment IOMMU support : PASS QEMU: Checking if IOMMU is enabled by kernel : WARN (IOMMU appears to be disabled in kernel. Add intel_iommu=on to kernel cmdline arguments) LXC: Checking for Linux >= 2.6.26 : PASS [...] LXC: Checking for cgroup 'blkio' controller mount-point : PASS LXC: Checking if device /sys/fs/fuse/connections exists : FAIL (Load the 'fuse' module to enable /proc/ overrides) If all virt-host-validate checks return a PASS value, your system is prepared for creating VMs . If any of the checks return a FAIL value, follow the displayed instructions to fix the problem. If any of the checks return a WARN value, consider following the displayed instructions to improve virtualization capabilities. Troubleshooting If KVM virtualization is not supported by your host CPU, virt-host-validate generates the following output: QEMU: Checking for hardware virtualization: FAIL (Only emulated CPUs are available, performance will be significantly limited) However, VMs on such a host system will fail to boot, rather than have performance problems. To work around this, you can change the <domain type> value in the XML configuration of the VM to qemu . Note, however, that Red Hat does not support VMs that use the qemu domain type, and setting this is highly discouraged in production environments. steps Create a virtual machine on your RHEL 9 host 2.2. Enabling virtualization on IBM Z To set up a KVM hypervisor and create virtual machines (VMs) on an IBM Z system running RHEL 9, follow the instructions below. Prerequisites The following minimum system resources are available: 6 GB free disk space for the host, plus another 6 GB for each intended VM. 2 GB of RAM for the host, plus another 2 GB for each intended VM. 4 CPUs on the host. VMs can generally run with a single assigned vCPU, but Red Hat recommends assigning 2 or more vCPUs per VM to avoid VMs becoming unresponsive during high load. Your IBM Z host system is using a z13 CPU or later. RHEL 9 is installed on a logical partition (LPAR). In addition, the LPAR supports the start-interpretive execution (SIE) virtualization functions. To verify this, search for sie in your /proc/cpuinfo file. Procedure Install the virtualization packages: Start the virtualization services: Verification Verify that your system is prepared to be a virtualization host. If all virt-host-validate checks return a PASS value, your system is prepared for creating VMs . If any of the checks return a FAIL value, follow the displayed instructions to fix the problem. If any of the checks return a WARN value, consider following the displayed instructions to improve virtualization capabilities. Troubleshooting If KVM virtualization is not supported by your host CPU, virt-host-validate generates the following output: However, VMs on such a host system will fail to boot, rather than have performance problems. To work around this, you can change the <domain type> value in the XML configuration of the VM to qemu . Note, however, that Red Hat does not support VMs that use the qemu domain type, and setting this is highly discouraged in production environments. Additional resources How virtualization on IBM Z differs from AMD64 and Intel 64 2.3. Enabling virtualization on ARM 64 To set up a KVM hypervisor for creating virtual machines (VMs) on an ARM 64 system (also known as AArch64 ) that runs RHEL 9, follow the instructions below. Prerequisites The following minimum system resources are available: 6 GB free disk space for the host, plus another 6 GB for each intended guest. 4 GB of RAM for the host, plus another 4 GB for each intended guest. Procedure Install the virtualization packages: Start the virtualization services: Verification Verify that your system is prepared to be a virtualization host: If all virt-host-validate checks return a PASS value, your system is prepared for creating virtual machines . If any of the checks return a FAIL value, follow the displayed instructions to fix the problem. If any of the checks return a WARN value, consider following the displayed instructions to improve virtualization capabilities. steps Creating virtual machines Additional resources How virtualization on ARM 64 differs from AMD64 and Intel 64 2.4. Enabling QEMU Guest Agent features on your virtual machines To use certain features on a virtual machine (VM) hosted on your RHEL 9 system, you must first configure the VM to use the QEMU Guest Agent (GA). For a complete list of these features, see Virtualization features that require QEMU Guest Agent . The specific steps required to configure QEMU GA on a VM differ based on the guest operating system used by the VM: For Linux VMs, see Enabling QEMU Guest Agent on Linux guests . For Windows VMs, see Enabling QEMU Guest Agent on Windows guests . 2.4.1. Enabling QEMU Guest Agent on Linux guests To allow a RHEL host to perform a certain subset of operations on a Linux virtual machine (VM), you must enable the QEMU Guest Agent (GA). You can enable QEMU GA both on running and shut-down VMs. Procedure Create an XML configuration file for the QEMU GA, for example named qemuga.xml : Add the following lines to the file: <channel type='unix'> <source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/> <target type='virtio' name='org.qemu.guest_agent.0'/> </channel> Use the XML file to add QEMU GA to the configuration of the VM. If the VM is running, use the following command: If the VM is shut-down, use the following command: In the Linux guest operating system, install the QEMU GA: Start the QEMU GA service on the guest: Verification To ensure that QEMU GA is enabled and running on the Linux VM, do any of the following: In the guest operating system, use the systemctl status qemu-guest-agent | grep Loaded command. If the output includes enabled , QEMU GA is active on the VM. Use the virsh domfsinfo <vm-name> command on the host. If it displays any output, QEMU GA is active on the specified VM. Additional resources Virtualization features that require QEMU Guest Agent 2.4.2. Enabling QEMU Guest Agent on Windows guests To allow a RHEL host to perform a certain subset of operations on a Windows virtual machine (VM), you must enable the QEMU Guest Agent (GA). To do so, add a storage device that contains the QEMU Guest Agent installer to an existing VM or when creating a new VM, and install the drivers on the Windows guest operating system. To install the Guest Agent (GA) by using the graphical interface, see the procedure below. To install the GA on the command line, use the Microsoft Windows Installer (MSI) . Prerequisites An installation medium with the Guest Agent is attached to the VM. For instructions on preparing the medium, see Preparing virtio driver installation media on a host machine . Procedure In the Windows guest operating system, open the File Explorer application. Click This PC . In the Devices and drives pane, open the virtio-win medium. Open the guest-agent folder. Based on the operating system installed on the VM, run one of the following installers: If using a 32-bit operating system, run the qemu-ga-i386.msi installer. If using a 64-bit operating system, run the qemu-ga-x86_64.msi installer. Optional: If you want to use the para-virtualized serial driver ( virtio-serial ) as the communication interface between the host and the Windows guest, verify that the virtio-serial driver is installed on the Windows guest. For more information about installing virtio drivers, see: Installing virtio drivers on a Windows guest . Verification On your Windows VM, navigate to the Services window. Computer Management > Services Ensure that the status of the QEMU Guest Agent service is Running . Additional resources Virtualization features that require QEMU Guest Agent 2.4.3. Virtualization features that require QEMU Guest Agent If you enable QEMU Guest Agent (GA) on a virtual machine (VM), you can use the following commands on your host to manage the VM: virsh shutdown --mode=agent This shutdown method is more reliable than virsh shutdown --mode=acpi , because virsh shutdown used with QEMU GA is guaranteed to shut down a cooperative guest in a clean state. virsh domfsfreeze and virsh domfsthaw Freezes the guest file system in isolation. virsh domfstrim Instructs the guest to trim its file system, which helps to reduce the data that needs to be transferred during migrations. Important If you want to use this command to manage a Linux VM, you must also set the following SELinux boolean in the guest operating system: virsh domtime Queries or sets the guest's clock. virsh setvcpus --guest Instructs the guest to take CPUs offline, which is useful when CPUs cannot be hot-unplugged. virsh domifaddr --source agent Queries the guest operating system's IP address by using QEMU GA. For example, this is useful when the guest interface is directly attached to a host interface. virsh domfsinfo Shows a list of mounted file systems in the running guest. virsh set-user-password Sets the password for a given user account in the guest. virsh set-user-sshkeys Edits the authorized SSH keys file for a given user in the guest. Important If you want to use this command to manage a Linux VM, you must also set the following SELinux boolean in the guest operating system: Additional resources Enabling QEMU Guest Agent on Linux guests Enabling QEMU Guest Agent on Windows guests
dnf install qemu-kvm libvirt virt-install virt-viewer for drv in qemu network nodedev nwfilter secret storage interface; do systemctl start virtUSD{drv}d{,-ro,-admin}.socket; done virt-host-validate [...] QEMU: Checking for device assignment IOMMU support : PASS QEMU: Checking if IOMMU is enabled by kernel : WARN (IOMMU appears to be disabled in kernel. Add intel_iommu=on to kernel cmdline arguments) LXC: Checking for Linux >= 2.6.26 : PASS [...] LXC: Checking for cgroup 'blkio' controller mount-point : PASS LXC: Checking if device /sys/fs/fuse/connections exists : FAIL (Load the 'fuse' module to enable /proc/ overrides) QEMU: Checking for hardware virtualization: FAIL (Only emulated CPUs are available, performance will be significantly limited) grep sie /proc/cpuinfo features : esan3 zarch stfle msa ldisp eimm dfp edat etf3eh highgprs te sie dnf install qemu-kvm libvirt virt-install for drv in qemu network nodedev nwfilter secret storage interface; do systemctl start virtUSD{drv}d{,-ro,-admin}.socket; done virt-host-validate [...] QEMU: Checking if device /dev/kvm is accessible : PASS QEMU: Checking if device /dev/vhost-net exists : PASS QEMU: Checking if device /dev/net/tun exists : PASS QEMU: Checking for cgroup 'memory' controller support : PASS QEMU: Checking for cgroup 'memory' controller mount-point : PASS [...] QEMU: Checking for hardware virtualization: FAIL (Only emulated CPUs are available, performance will be significantly limited) dnf install qemu-kvm libvirt virt-install for drv in qemu network nodedev nwfilter secret storage interface; do systemctl start virtUSD{drv}d{,-ro,-admin}.socket; done virt-host-validate [...] QEMU: Checking if device /dev/vhost-net exists : PASS QEMU: Checking if device /dev/net/tun exists : PASS QEMU: Checking for cgroup 'memory' controller support : PASS QEMU: Checking for cgroup 'memory' controller mount-point : PASS [...] QEMU: Checking for cgroup 'blkio' controller support : PASS QEMU: Checking for cgroup 'blkio' controller mount-point : PASS QEMU: Checking if IOMMU is enabled by kernel : WARN (Unknown if this platform has IOMMU support) touch qemuga.xml <channel type='unix'> <source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/> <target type='virtio' name='org.qemu.guest_agent.0'/> </channel> virsh attach-device <vm-name> qemuga.xml --live --config virsh attach-device <vm-name> qemuga.xml --config dnf install qemu-guest-agent systemctl start qemu-guest-agent setsebool virt_qemu_ga_read_nonsecurity_files on setsebool virt_qemu_ga_manage_ssh on