Chapter 2. Getting started with virtualization
To start using virtualization in RHEL 8, follow the steps below. The default method for this is using the command-line interface (CLI), but for user convenience, some of the steps can be completed in the the web console GUI.
- Enable the virtualization module and install the virtualization packages - see Section 2.1, “Enabling virtualization”.
Create a virtual machine (VM):
Start the VM:
Connect to the VM:
The web console currently provides only a subset of VM management functions, so using the command line is recommended for advanced use of virtualization in RHEL 8.
2.1. Enabling virtualization
To use virtualization in RHEL 8, you must enable the virtualization module, install virtualization packages, and ensure your system is configured to host virtual machines (VMs).
Prerequisites
- Red Hat Enterprise Linux 8 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 packages in the RHEL 8 virtualization module:
# yum module install virt
Install the
virt-install
andvirt-viewer
packages:# yum install virt-install virt-viewer
Start the
libvirtd
service.# systemctl start libvirtd
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.
Additional information
Note that if 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, attempting to create VMs on such a host system will fail, rather than have performance problems.
2.2. Creating virtual machines
To create a virtual machine (VM) in RHEL 8, use the command line interface or the RHEL 8 web console.
Prerequisites
- Virtualization is installed and enabled on your system.
You have sufficient amount of system resources to allocate to your VMs, such as disk space, RAM, or CPUs. The recommended values may vary significantly depending on the intended tasks and workload of the VMs.
WarningInstalling from a host CD-ROM or DVD-ROM device is not possible in RHEL 8. If you select a CD-ROM or DVD-ROM as the installation source when using any VM installation method available in RHEL 8, the installation will fail. For more information, see the Red Hat Knowledgebase.
2.2.1. Creating virtual machines using the command-line interface
To create a virtual machine (VM) on your RHEL 8 host using the virt-install
utility, follow the instructions below.
Prerequisites
- Virtualization is enabled on your host system.
An operating system (OS) installation source is available locally or on a network. This can be one of the following:
- An ISO image of an installation medium
- A disk image of an existing VM installation
- Optional: A Kickstart file can be provided for faster and easier configuration of the installation.
Procedure
To create a VM and start its OS installation, use the virt-install
command, along with the following mandatory arguments:
- The name of the new machine
- The amount of allocated memory
- The number of allocated virtual CPUs (vCPUs)
- The type and size of the allocated storage
- The type and location of the OS installation source
Based on the chosen installation method, the necessary options and values can vary. See below for examples:
The following creates a VM named demo-guest1 that installs the Windows 10 OS from an ISO image locally stored in the /home/username/Downloads/Win10install.iso file. This VM is also allocated with 2048 MiB of RAM and 2 vCPUs, and an 80 GiB qcow2 virtual disk is automatically configured for the VM.
# virt-install --name demo-guest1 --memory 2048 --vcpus 2 --disk size=80 --os-variant win10 --cdrom /home/username/Downloads/Win10install.iso
The following creates a VM named demo-guest2 that uses the /home/username/Downloads/rhel8.iso image to run a RHEL 8 OS from a live CD. No disk space is assigned to this VM, so changes made during the session will not be preserved. In addition, the VM is allocated with 4096 MiB of RAM and 4 vCPUs.
# virt-install --name demo-guest2 --memory 4096 --vcpus 4 --disk none --livecd --os-variant rhel8.0 --cdrom /home/username/Downloads/rhel8.iso
The following creates a RHEL 8 VM named demo-guest3 that connects to an existing disk image, /home/username/backup/disk.qcow2. This is similar to physically moving a hard drive between machines, so the OS and data available to demo-guest3 are determined by how the image was handled previously. In addition, this VM is allocated with 2048 MiB of RAM and 2 vCPUs.
# virt-install --name demo-guest3 --memory 2048 --vcpus 2 --os-variant rhel8.0 --import --disk /home/username/backup/disk.qcow2
Note that the
--os-variant
option is highly recommended when importing a disk image. If it is not provided, the performance of the created VM will be negatively affected.The following creates a VM named demo-guest4 that installs from the
http://example.com/OS-install
URL. For the installation to start successfully, the URL must contain a working OS installation tree. In addition, the OS is automatically configured using the /home/username/ks.cfg kickstart file. This VM is also allocated with 2048 MiB of RAM, 2 vCPUs, and a 160 GiB qcow2 virtual disk.# virt-install --name demo-guest4 --memory 2048 --vcpus 2 --disk size=160 --os-variant rhel8.0 --location http://example.com/OS-install --initrd-inject /home/username/ks.cfg --extra-args="ks=file:/ks.cfg console=tty0 console=ttyS0,115200n8"
The following creates a VM named demo-guest5 that installs from a
RHEL8.iso
image file in text-only mode, without graphics. It connects the guest console to the serial console. The VM has 16384 MiB of memory, 16 vCPUs, and 280 GiB disk. This kind of installation is useful when connecting to a host over a slow network link.# virt-install --name demo-guest5 --memory 16384 --vcpus 16 --disk size=280 --os-variant rhel8.0 --location RHEL8.iso --graphics none --extra-args='console=ttyS0'
The following creates a VM named demo-guest6, which has the same configuration as demo-guest5, but resides on the 10.0.0.1 remote host.
# virt-install --connect qemu+ssh://root@10.0.0.1/system --name demo-guest6 --memory 16384 --vcpus 16 --disk size=280 --os-variant rhel8.0 --location RHEL8.iso --graphics none --extra-args='console=ttyS0'
If the VM is created successfully, a virt-viewer window opens with a graphical console of the VM and starts the guest OS installation.
Troubleshooting
If
virt-install
fails with acannot find default network
error:Ensure that the libvirt-daemon-config-network package is installed:
# yum info libvirt-daemon-config-network Installed Packages Name : libvirt-daemon-config-network [...]
Verify that the
libvirt
default network is active and configured to start automatically:# virsh net-list --all Name State Autostart Persistent -------------------------------------------- default active yes yes
If it is not, activate the default network and set it to auto-start:
# virsh net-autostart default Network default marked as autostarted # virsh net-start default Network default started
If activating the default network fails with the following error, the libvirt-daemon-config-network package has not been installed correctly.
error: failed to get network 'default' error: Network not found: no network with matching name 'default'
To fix this, re-install libvirt-daemon-config-network.
# yum reinstall libvirt-daemon-config-network
If activating the default network fails with an error similar to the following, a conflict has occurred between the default network’s subnet and an existing interface on the host.
error: Failed to start network default error: internal error: Network is already in use by interface ens2
To fix this, use the
virsh net-edit default
command and change the 192.168.122.* values in the configuration to a subnet not already in use on the host.
Additional resources
- A number of other options can be specified for virt-install to further configure the VM and its OS installation. For details, see the virt-install man page.
- If you already have a functional VM, you can clone it to quickly create a new VM with the same configuration and data. For details, see Chapter 8, Cloning virtual machines.
2.2.2. Creating virtual machines and installing guest operating systems using the web console
To manage virtual machines (VMs) in a GUI on a RHEL 8 host, use the web console. The following sections provide information on how to use the RHEL 8 web console to create VMs and install guest operating systems on them.
2.2.2.1. Creating virtual machines using the web console
To create a virtual machine (VM) on the host machine to which the web console is connected, follow the instructions below.
Prerequisites
- To use the web console to manage VMs, install the web console VM plug-in.
- You have sufficient amount of system resources to allocate to your VMs, such as disk space, RAM, or CPUs. The recommended values may vary significantly depending on the intended tasks and workload of the VMs.
Procedure
In the .
interface of the web console, clickThe Create New Virtual Machine dialog appears.
Enter the basic configuration of the VM you want to create.
- Name - The name of the VM.
- Installation Type - The installation can use a local installation medium, a URL, a PXE network boot, or download an OS from a limited set of operating systems.
- Operating System - The VM’s operating system. Note that Red Hat provides support only for a limited set of guest operating systems.
- Storage - The type of storage with which to configure the VM.
- Size - The amount of storage space with which to configure the VM.
- Memory - The amount of memory with which to configure the VM.
- Run unattended installation - Whether or not to run the installation unattended.
- Immediately Start VM - Whether or not the VM will start immediately after it is created.
Click
.The VM is created. If the Immediately Start VM checkbox is selected, the VM will immediately start and begin installing the guest operating system.
Additional resources
- For information on installing an operating system on a VM, see Section 2.2.2.3, “Installing guest operating systems using the web console”.
2.2.2.2. Creating virtual machines by importing disk images using the web console
To create a virtual machine (VM) by importing a disk image of an existing VM installation, follow the instructions below.
Prerequisites
- To use the web console to manage VMs, install the web console VM plug-in.
- You have sufficient amount of system resources to allocate to your VMs, such as disk space, RAM, or CPUs. The recommended values can vary significantly depending on the intended tasks and workload of the VMs.
- Make sure you have a disk image of an existing VM installation
Procedure
In the .
interface of the web console, clickThe Import A Virtual Machine dialog appears.
Enter the basic configuration of the VM you want to create.
- Name - The name of the VM.
- Connection - The type of libvirt connection, system or session.
- Installation Source - The existing disk image of a VM on the host system.
- Operating System - The VM’s operating system. Note that Red Hat provides support only for a limited set of guest operating systems.
- Memory - The amount of memory with which to configure the VM.
- Immediately Start VM - Whether or not the VM will start immediately after it is created.
- Click .
2.2.2.3. Installing guest operating systems using the web console
The first time a virtual machine (VM) loads, you must install an operating system on the VM.
If the Immediately Start VM checkbox in the Create New Virtual Machine dialog is checked, the installation routine of the operating system starts automatically when the VM is created.
Prerequisites
- To use the web console to manage VMs, install the web console VM plug-in.
- A VM on which to install an operating system must be available.
Procedure
In the
interface, click the row of the VM on which you want to install a guest OS.The row expands to reveal the Overview pane with basic information about the selected VM and controls for installing and deleting the VM.
Optional: Change the firmware.
NoteYou can change the firmware only if you had not selected the Immediately Start VM check box in the Create New Virtual Machine dialog, and the OS has not already been installed on the VM.
Click the highlighted firmware.
In the Change Firmware window, select the desired firmware.
- Click .
Click
.The installation routine of the operating system runs in the VM console.
Troubleshooting
- If the installation routine fails, the VM must be deleted and recreated.
2.3. Starting virtual machines
To start a virtual machine (VM) in RHEL 8, you can use the command line interface or the web console GUI.
Prerequisites
- Before a VM can be started, it must be created and, ideally, also installed with an OS. For instruction to do so, see Section 2.2, “Creating virtual machines”.
2.3.1. Starting a virtual machine using the command-line interface
You can use the command line interface to start a shutdown virtual machine (VM) or restore a saved VM. Follow the procedure below.
Prerequisites
- An inactive VM that is already defined.
- The name of the VM.
For remote VMs:
- The IP address of the host where the VM is located.
- Root access privileges to the host.
Procedure
For a local VM, use the
virsh start
utility.For example, the following command starts the demo-guest1 VM.
# virsh start demo-guest1 Domain demo-guest1 started
For a VM located on a remote host, use the
virsh start
utility along with the QEMU+SSH connection to the host.For example, the following command starts the demo-guest1 VM on the 192.168.123.123 host.
# virsh -c qemu+ssh://root@192.168.123.123/system start demo-guest1 root@192.168.123.123's password: Last login: Mon Feb 18 07:28:55 2019 Domain demo-guest1 started
Additional Resources
-
For more
virsh start
arguments, usevirsh start --help
. - For simplifying VM management on remote hosts, see modifying your libvirt and SSH configuration.
-
You can use the
virsh autostart
utility to configure a VM to start automatically when the host boots up. For more information about autostart, see thevirsh autostart
help page.
2.3.2. Starting virtual machines using the web console
If a virtual machine (VM) is in the shut off state, you can start it using the RHEL 8 web console.
Prerequisites
- An inactive VM that is already defined.
- The name of the VM.
- To use the web console to manage VMs, install the web console VM plug-in.
Procedure
In the
interface, click the row of the VM you want to start.The row expands to reveal the Overview pane with basic information about the selected VM and controls for shutting down and deleting the VM.
Click
.The VM starts, and you can connect to its console or graphical output.
-
Optional: To set up the VM to start automatically when the host starts, click the
Autostart
checkbox.
Additional resources
- For information on shutting down a VM, see Section 2.5.2.1, “Shutting down virtual machines in the web console”.
- For information on restarting a VM, see Section 2.5.2.2, “Restarting virtual machines using the web console”.
- For information on sending a non-maskable interrupt to a VM, see Section 2.5.2.3, “Sending non-maskable interrupts to VMs using the web console”.
2.4. Connecting to virtual machines
To interact with a virtual machine (VM) in RHEL 8, you need to connect to it by doing one of the following:
- When using the web console interface, use the Virtual Machines pane in the web console interface. For more information, see Section 2.4.1, “Interacting with virtual machines using the web console”.
- If you need to interact with a VM graphical display without using the web console, use the Virt Viewer application. For details, see Section 2.4.2, “Opening a virtual machine graphical console using Virt Viewer”.
- When a graphical display is not possible or not necessary, use an SSH terminal connection.
- When the virtual machine is not reachable from your system by using a network, use the virsh console.
If the VMs to which you are connecting are on a remote host rather than a local one, you can optionally configure your system for more convenient access to remote hosts.
2.4.1. Interacting with virtual machines using the web console
To interact with a virtual machine (VM) in the RHEL 8 web console, you need to connect to the VM’s console. These include both graphical and serial consoles.
- To interact with the VM’s graphical interface in the web console, use the graphical console.
- To interact with the VM’s graphical interface in a remote viewer, use the graphical console in remote viewers.
- To interact with the VM’s CLI in the web console, use the serial console.
2.4.1.1. Viewing the virtual machine graphical console in the web console
Using the virtual machine (VM) console interface, you can view the graphical output of a selected VM in the RHEL 8 web console.
Prerequisites
- To use the web console to manage VMs, install the web console VM plug-in.
- Ensure that both the host and the VM support a graphical interface.
Procedure
In the
interface, click the row of the VM whose graphical console you want to view.The row expands to reveal the Overview pane with basic information about the selected VM and controls for shutting down and deleting the VM.
Click
.The graphical console appears in the web interface.

You can interact with the VM console using the mouse and keyboard in the same manner you interact with a real machine. The display in the VM console reflects the activities being performed on the VM.
The host on which the web console is running may intercept specific key combinations, such as Ctrl+Alt+Del, preventing them from being sent to the VM.
To send such key combinations, click the
menu and select the key sequence to send.For example, to send the Ctrl+Alt+Del combination to the VM, click the menu and select the menu entry.
Additional resources
- For instructions on viewing the graphical console in a remote viewer, see Section 2.4.1.2, “Viewing the graphical console in a remote viewer using the web console”.
- For instructions on viewing the serial console in the web console, see Section 2.4.1.3, “Viewing the virtual machine serial console in the web console”.
2.4.1.2. Viewing the graphical console in a remote viewer using the web console
You can view the graphical console of a selected virtual machine (VM) in a remote viewer, such as virt-viewer. For instructions, see below.
You can launch Virt Viewer from within the web console. Other VNC and SPICE remote viewers can be launched manually.
Prerequisites
- To use the web console to manage VMs, install the web console VM plug-in.
- Ensure that both the host and the VM support a graphical interface.
Before you can view the graphical console in Virt Viewer, Virt Viewer must be installed on the machine to which the web console is connected.
To view information on installing Virt Viewer, select the More Information in the Consoles window.
Console Type and click
Some browser extensions and plug-ins do not allow the web console to open Virt Viewer.
Procedure
In the
interface, click the row of the VM whose graphical console you want to view.The row expands to reveal the Overview pane with basic information about the selected VM and controls for shutting down and deleting the VM.
Click
.The graphical console appears in the web interface.
Select the
Console Type.Click
.The graphical console appears in Virt Viewer.
You can interact with the VM console using the mouse and keyboard in the same manner you interact with a real machine. The display in the VM console reflects the activities being performed on the VM.
The server on which the web console is running can intercept specific key combinations, such as Ctrl+Alt+Del, preventing them from being sent to the VM.
To send such key combinations, click the
menu and select the key sequence to send.For example, to send the Ctrl+Alt+Del combination to the VM, click the menu and select the menu entry.
Troubleshooting
If launching a remote viewer graphics console in the web console does not work or is not optimal, you can use the
Manual Connection
information, displayed on the right side of the pane.Enter the information in a SPICE or VNC viewer application, such as Virt Viewer.
Additional resources
- For instructions on viewing the graphical console in the web console, see Section 2.4.1.1, “Viewing the virtual machine graphical console in the web console”.
- For instructions on viewing the serial console in the web console, see Section 2.4.1.3, “Viewing the virtual machine serial console in the web console”.
2.4.1.3. Viewing the virtual machine serial console in the web console
You can view the serial console of a selected virtual machine (VM) in the RHEL 8 web console. This is useful when the host machine or the VM is not configured with a graphical interface.
Prerequisites
- To use the web console to manage VMs, install the web console VM plug-in.
Procedure
In the
pane, click the row of the VM whose serial console you want to view.The row expands to reveal the Overview pane with basic information about the selected VM and controls for shutting down and deleting the VM.
Click
.The graphical console appears in the web interface.
Select the
Console Type.The serial console appears in the web interface.
You can disconnect and reconnect the serial console from the VM.
- To disconnect the serial console from the VM, click .
- To reconnect the serial console to the VM, click .
Additional resources
- For instructions on viewing the graphical console in the web console, see Section 2.4.1.1, “Viewing the virtual machine graphical console in the web console”.
- For instructions on viewing the graphical console in a remote viewer, see Section 2.4.1.2, “Viewing the graphical console in a remote viewer using the web console”.
2.4.2. Opening a virtual machine graphical console using Virt Viewer
To connect to a graphical console of a KVM virtual machine (VM) and open it in the Virt Viewer
desktop application, follow the procedure below.
Prerequisites
- Your system, as well as the VM you are connecting to, must support graphical displays.
- If the target VM is located on a remote host, connection and root access privileges to the host are needed.
- Optional: If the target VM is located on a remote host, set up your libvirt and SSH for more convenient access to remote hosts.
Procedure
To connect to a local VM, use the following command and replace guest-name with the name of the VM you want to connect to:
# virt-viewer guest-name
To connect to a remote VM, use the
virt-viewer
command with the SSH protocol. For example, the following command connects as root to a VM called guest-name, located on remote system 10.0.0.1. The connection also requires root authentication for 10.0.0.1.# virt-viewer --direct --connect qemu+ssh://root@10.0.0.1/system guest-name root@10.0.0.1's password:
If the connection works correctly, the VM display is shown in the Virt Viewer
window.

You can interact with the VM console using the mouse and keyboard in the same manner you interact with a real machine. The display in the VM console reflects the activities being performed on the VM.
Additional resources
-
For more information on using Virt Viewer, see the
virt-viewer
man page. - Connecting to VMs on a remote host can be simplified by modifying your libvirt and SSH configuration.
- For management of VMs in an interactive GUI in RHEL 8, you can use the web console interface. For more information, see Section 2.4.1, “Interacting with virtual machines using the web console”.
2.4.3. Connecting to a virtual machine using SSH
To interact with the terminal of a virtual machine (VM) using the SSH connection protocol, follow the procedure below:
Prerequisites
- You have network connection and root access privileges to the target VM.
- If the target VM is located on a remote host, you also have connection and root access privileges to that host.
The
libvirt-nss
component is installed and enabled on the VM’s host. If it is not, do the following:Install the
libvirt-nss
package:# yum install libvirt-nss
Edit the
/etc/nsswitch.conf
file and addlibvirt_guest
to thehosts
line:[...] passwd: compat shadow: compat group: compat hosts: files libvirt_guest dns [...]
Procedure
Optional: When connecting to a remote VM, SSH into its physical host first. The following example demonstrates connecting to a host machine 10.0.0.1 using its root credentials:
# ssh root@10.0.0.1 root@10.0.0.1's password: Last login: Mon Sep 24 12:05:36 2018 root~#
Use the VM’s name and user access credentials to connect to it. For example, the following connects to to the "testguest1" VM using its root credentials:
# ssh root@testguest1 root@testguest1's password: Last login: Wed Sep 12 12:05:36 2018 root~]#
Troubleshooting
If you do not know the VM’s name, you can list all VMs available on the host using the
virsh list --all
command:# virsh list --all Id Name State ---------------------------------------------------- 2 testguest1 running - testguest2 shut off
2.4.4. Opening a virtual machine serial console
Using the virsh console
command, it is possible to connect to the serial console of a virtual machine (VM).
This is useful when the VM:
- Does not provide VNC or SPICE protocols, and thus does not offer video display for GUI tools.
- Does not have a network connection, and thus cannot be interacted with using SSH.
Prerequisites
The VM must have the serial console configured in its kernel command line. To verify this, the
cat /proc/cmdline
command output on the VM should include console=ttyS0. For example:# cat /proc/cmdline BOOT_IMAGE=/vmlinuz-3.10.0-948.el7.x86_64 root=/dev/mapper/rhel-root ro console=tty0 console=ttyS0,9600n8 rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb
If the serial console is not set up properly on a VM, using virsh console to connect to the VM connects you to an unresponsive guest console. However, you can still exit the unresponsive console by using the Ctrl+] shortcut.
To set up serial console on the VM, do the following:
-
On the VM, edit the
/etc/default/grub
file and add console=ttyS0 to the line that starts with GRUB_CMDLINE_LINUX. Clear the kernel options that may prevent your changes from taking effect.
# grub2-editenv - unset kernelopts
Reload the Grub configuration:
# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-948.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-948.el7.x86_64.img [...] done
- Reboot the VM.
-
On the VM, edit the
Procedure
On your host system, use the
virsh console
command. The following example connects to the guest1 VM, if the libvirt driver supports safe console handling:# virsh console guest1 --safe Connected to domain guest1 Escape character is ^] Subscription-name Kernel 3.10.0-948.el7.x86_64 on an x86_64 localhost login:
- You can interact with the virsh console in the same way as with a standard command-line interface.
Additional resources
- For more information about the VM serial console, see the virsh man page.
2.4.5. Setting up easy access to remote virtualization hosts
When managing VMs on a remote host system using libvirt utilities, it is recommended to use the -c qemu+ssh://root@hostname/system
syntax. For example, to use the virsh list
command as root on the 10.0.0.1 host:
# virsh -c qemu+ssh://root@10.0.0.1/system list
root@10.0.0.1's password:
Last login: Mon Feb 18 07:28:55 2019
Id Name State
---------------------------------
1 remote-guest running
However, for convenience, you can remove the need to specify the connection details in full by modifying your SSH and libvirt configuration. For example, you will be able to do:
# virsh -c remote-host list
root@10.0.0.1's password:
Last login: Mon Feb 18 07:28:55 2019
Id Name State
---------------------------------
1 remote-guest running
To enable this improvement, follow the instructions below.
Procedure
Edit or create the
~/.ssh/config
file and add the following to it, where host-alias is a shortened name associated with a specific remote host, and hosturl is the URL address of the host.Host host-alias User root Hostname hosturl
For example, the following sets up the tyrannosaurus alias for root@10.0.0.1:
Host tyrannosaurus User root Hostname 10.0.0.1
Edit or create the
/etc/libvirt/libvirt.conf
file, and add the following, where qemu-host-alias is a host alias that QEMU and libvirt utilities will associate with the intended host:uri_aliases = [ "qemu-host-alias=qemu+ssh://host-alias/system", ]
For example, the following uses the tyrannosaurus alias configured in the previous step to set up the t-rex alias, which stands for
qemu+ssh://10.0.0.1/system
:uri_aliases = [ "t-rex=qemu+ssh://tyrannosaurus/system", ]
As a result, you can manage remote VMs by using libvirt-based utilities on the local system with an added
-c qemu-host-alias
parameter. This automatically performs the commands over SSH on the remote host.For example, the following lists VMs on the 10.0.0.1 remote host, the connection to which was set up as t-rex in the previous steps:
$ virsh -c t-rex list root@10.0.0.1's password: Last login: Mon Feb 18 07:28:55 2019 Id Name State --------------------------------- 1 velociraptor running
Optional: If you want to use libvirt utilities exclusively on a single remote host, you can also set a specific connection as the default target for libvirt-based utilities. To do so, edit the
/etc/libvirt/libvirt.conf
file and set the value of theuri_default
parameter to qemu-host-alias. For example, the following uses the t-rex host alias set up in the previous steps as a default libvirt target.# These can be used in cases when no URI is supplied by the application # (@uri_default also prevents probing of the hypervisor driver). # uri_default = "t-rex"
As a result, all libvirt-based commands will automatically be performed on the specified remote host.
$ virsh list root@10.0.0.1's password: Last login: Mon Feb 18 07:28:55 2019 Id Name State --------------------------------- 1 velociraptor running
However, this is not recommended if you also want to manage VMs on your local host or on different remote hosts.
Additional resources
When connecting to a remote host, you can avoid having to provide the root password to the remote system. To do so, use one or more of the following methods:
- Set up key-based SSH access to the remote host.
- Use SSH connection multiplexing to connect to the remote system.
- Set up a kerberos authentication ticket on the remote system. For instructions, see Kerberos authentication in Identity Management.
Utilities that can use the
-c
(or--connect
) option and the remote host access configuration described above include:- virt-install
- virt-viewer
- virsh
- virt-manager
2.5. Shutting down virtual machines
To shut down a running virtual machine in Red Hat Enterprise Linux 8, use the command line interface or the web console GUI.
2.5.1. Shutting down a virtual machine using the command-line interface
To shut down a responsive virtual machine (VM), do one of the following:
- Use a shutdown command appropriate to the guest OS while connected to the guest.
Use the
virsh shutdown
command on the host:If the VM is on a local host:
# virsh shutdown demo-guest1 Domain demo-guest1 is being shutdown
If the VM is on a remote host, in this example 10.0.0.1:
# virsh -c qemu+ssh://root@10.0.0.1/system shutdown demo-guest1 root@10.0.0.1's password: Last login: Mon Feb 18 07:28:55 2019 Domain demo-guest1 is being shutdown
To force a guest to shut down, for example if it has become unresponsive, use the virsh destroy
command on the host:
# virsh destroy demo-guest1
Domain demo-guest1 destroyed
The virsh destroy
command does not actually delete or remove the VM configuration or disk images. It only destroys the running VM instance. However, in rare cases, this command may cause corruption of the VM’s file system, so using virsh destroy is only recommended if all other shutdown methods have failed.
2.5.2. Shutting down and restarting virtual machines using the web console
Using the RHEL 8 web console, you can shut down or restart running virtual machines. You can also send a non-maskable interrupt to an unresponsive virtual machine.
2.5.2.1. Shutting down virtual machines in the web console
If a virtual machine (VM) is in the running state, you can shut it down using the RHEL 8 web console.
Prerequisites
- To use the web console to manage VMs, install the web console VM plug-in.
Procedure
In the
interface, click the row of the VM you want to shut down.The row expands to reveal the Overview pane with basic information about the selected VM and controls for shutting down and deleting the VM.
Click
.The VM shuts down.
Troubleshooting
- If the VM does not shut down, click the Menu button next to the button and select .
- To shut down an unresponsive VM, you can also send a non-maskable interrupt. For more information, see Section 2.5.2.3, “Sending non-maskable interrupts to VMs using the web console”.
Additional resources
- For information on starting a VM, see Section 2.3.2, “Starting virtual machines using the web console”.
- For information on restarting a VM, see Section 2.5.2.2, “Restarting virtual machines using the web console”.
2.5.2.2. Restarting virtual machines using the web console
If a virtual machine (VM) is in the running state, you can restart it using the RHEL 8 web console.
Prerequisites
- To use the web console to manage VMs, install the web console VM plug-in.
Procedure
In the
interface, click the row of the VM you want to restart.The row expands to reveal the Overview pane with basic information about the selected VM and controls for shutting down and deleting the VM.
Click
.The VM shuts down and restarts.
Troubleshooting
- If the VM does not restart, click the Menu button next to the button and select .
- To restart an unresponsive VM, you can also send a non-maskable interrupt. For more information, see Section 2.5.2.3, “Sending non-maskable interrupts to VMs using the web console”.
Additional resources
- For information on starting a VM, see Section 2.3.2, “Starting virtual machines using the web console”.
- For information on shutting down a VM, see Section 2.5.2.1, “Shutting down virtual machines in the web console”.
2.5.2.3. Sending non-maskable interrupts to VMs using the web console
Sending a non-maskable interrupt (NMI) may cause an unresponsive running virtual machine (VM) to respond or shut down. For example, you can send the Ctrl+Alt+Del NMI to a VM that is not responding to standard input.
Prerequisites
- To use the web console to manage VMs, install the web console VM plug-in.
Procedure
In the
interface, click the row of the VM to which you want to send an NMI.The row expands to reveal the Overview pane with basic information about the selected VM and controls for shutting down and deleting the VM.
Click the Menu button
next to the button and select .An NMI is sent to the VM.
Additional resources
- For information on starting a VM, see Section 2.3.2, “Starting virtual machines using the web console”.
- For information on restarting a VM, see Section 2.5.2.2, “Restarting virtual machines using the web console”.
- For information on shutting down a VM, see Section 2.5.2.1, “Shutting down virtual machines in the web console”.
2.6. Deleting virtual machines
To delete virtual machines in Red Hat Enterprise Linux 8, use the command line interface or the web console GUI.
2.6.1. Deleting virtual machines using the command line interface
To delete a virtual machine (VM), you can remove its XML configuration and associated storage files from the host using the command line. Follow the procedure below:
Prerequisites
- Back up important data from the VM.
- Shut down the VM.
- Make sure no other VMs use the same associated storage.
Procedure
Use the
virsh undefine
utility.For example, the following command removes the guest1 VM, its associated storage volumes, and non-volatile RAM, if any.
# virsh undefine guest1 --remove-all-storage --nvram Domain guest1 has been undefined Volume 'vda'(/home/images/guest1.qcow2) removed.
Additional resources
-
For other
virsh undefine
arguments, usevirsh undefine --help
or see thevirsh
man page.
2.6.2. Deleting virtual machines using the web console
To delete a virtual machine (VM) and its associated storage files from the host to which the RHEL 8 web console is connected with, follow the procedure below:
Prerequisites
- To use the web console to manage VMs, install the web console VM plug-in.
- Back up important data from the VM.
- Shut down the VM.
- Make sure no other VMs use the same associated storage.
Procedure
In the
interface, click the Menu button of the VM that you want to delete.A drop down menu appears with controls for various VM operations.
Click
.A confirmation dialog appears.
- Optional: To delete all or some of the storage files associated with the VM, select the checkboxes next to the storage files you want to delete.
Click
.The VM and any selected storage files are deleted.