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.

Note

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 must be installed and registered on your host machine.
  • Your system must meet 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

  1. Install the packages in the RHEL 8 virtualization module:

    # yum module install virt
  2. Install the virt-install and virt-viewer packages:

    # yum install virt-install virt-viewer
  3. Start the libvirtd service.

    # systemctl start libvirtd
  4. 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)
  5. 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 must be installed and enabled on your system.
  • Make sure 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.

    Warning

    Installing 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 Knowledge Base.

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

  • An operating system (OS) installation source, which can be one of the following, and be available locally or on a network:

    • An ISO image of an installation medium
    • A disk image of an existing VM installation
  • Optionally, a Kickstart file can also be provided for faster and easier configuration of the installation.
  • Virtualization must be enabled on your host system.

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 a cannot find default network error:

    1. Ensure that the libvirt-daemon-config-network package is installed:

      # yum info libvirt-daemon-config-network
      Installed Packages
      Name         : libvirt-daemon-config-network
      [...]
    2. 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
    3. 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
      1. 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
      2. 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

The following sections provide information on how to use the RHEL 8 web console to create virtual machines and install operating systems on VMs.

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.
  • Make sure 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.
  • A locally available operating system (OS) installation source, which can be one of the following:

    • An ISO image of an installation medium
    • A disk image of an existing VM installation

Procedure

  1. In the Virtual Machines interface of the web console, click Create VM.

    The Create New Virtual Machine dialog appears.

    cockpit create new vm
  2. 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.
    • Immediately Start VM - Whether or not the VM will start immediately after it is created.
  3. Click Create.

    The VM is created. If the Immediately Start VM checkbox is selected, the VM will immediately start and begin installing the guest operating system.

If you did not choose Existing Disk Image as the installation source type, you must install the operating system the first time the VM is run.

Additional resources

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

Note

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

Procedure

  1. In the Virtual Machines 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.

  2. Click Install.

    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

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, see the virsh man page.
  • 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 the virsh 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

Procedure

  1. In the Virtual Machines 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.

  2. Click Run.

    The VM starts, and you can connect to its console or graphical output.

  3. Optional: To set up the VM to start automatically when the host starts, click the Autostart checkbox.

Additional resources

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:

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.

Prerequisites

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.

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

Procedure

  1. In the Virtual Machines 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.

  2. Click Consoles.

    The graphical console appears in the web interface.

cockpit graphical console in cockpit

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.

Note

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 Send key menu and select the key sequence to send.

For example, to send the Ctrl+Alt+Del combination to the VM, click the Send key menu and select the Ctrl+Alt+Del menu entry.

Additional resources

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.

Note

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 Graphics Console in Desktop Viewer Console Type and click More Information in the Consoles window.

    cockpit install vv info
Note

Some browser extensions and plug-ins do not allow the web console to open Virt Viewer.

Procedure

  1. In the Virtual Machines 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.

  2. Click Consoles.

    The graphical console appears in the web interface.

  3. Select the Graphics Console in Desktop Viewer Console Type.

    cockpit launch graphical console in vv
  4. Click Launch Remote Viewer.

    The graphical console appears in Virt Viewer.

    virt viewer GUI

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.

Note

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 Send key menu and select the key sequence to send.

For example, to send the Ctrl+Alt+Del combination to the VM, click the Send key menu and select the Ctrl+Alt+Del 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 Graphics Console pane.

    cockpit manual viewer info

    Enter the information in a SPICE or VNC viewer application, such as Virt Viewer.

Additional resources

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

Procedure

  1. In the Virtual Machines 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.

  2. Click Consoles.

    The graphical console appears in the web interface.

  3. Select the Serial Console Console Type.

    The serial console appears in the web interface.

    cockpit serial console in cockpit

You can disconnect and reconnect the serial console from the VM.

  • To disconnect the serial console from the VM, click Disconnect.
  • To reconnect the serial console to the VM, click Reconnect.

Additional resources

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.

Virt Viewer displaying a RHEL 7 guest OS

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

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

  • Network connection and root access privileges to the target VM.
  • The libvirt-nss component must be installed and enabled on the VM’s host. If it is not, do the following:

    1. Install the libvirt-nss package:

      # yum install libvirt-nss
    2. Edit the /etc/nsswitch.conf file and add libvirt_guest to the hosts line:

      [...]
      passwd:      compat
      shadow:      compat
      group:       compat
      hosts:       files libvirt_guest dns
      [...]
  • If the target VM is located on a remote host, connection and root access privileges to the host are also needed.

Procedure

  1. 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~#
  2. 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:

    1. On the VM, edit the /etc/default/grub file and add console=ttyS0 to the line that starts with GRUB_CMDLINE_LINUX.
    2. Clear the kernel options that may prevent your changes from taking effect.

      # grub2-editenv - unset kernelopts
    3. 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
    4. Reboot the VM.

Procedure

  1. 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:
  2. 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

  1. 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
  2. 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",
    ]
  3. 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
  4. 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 the uri_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:

  • Utilities that can use the -c (or --connect) option and the remote host access configuration described above include:

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
Note

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

Procedure

  1. In the Virtual Machines 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.

  2. Click Shut Down.

    The VM shuts down.

Troubleshooting

Additional resources

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

Procedure

  1. In the Virtual Machines 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.

  2. Click Restart.

    The VM shuts down and restarts.

Troubleshooting

Additional resources

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

Procedure

  1. In the Virtual Machines 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.

  2. Click the arrow next to the Shut Down button and select Send Non-Maskable Interrupt.

    An NMI is sent to the VM.

Additional resources

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, see the virsh 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

  1. In the Virtual Machines interface, click the name of the VM you want to delete.

    The row expands to reveal the Overview pane with basic information about the selected VM and controls for shutting down and deleting the VM.

    cockpit 1 vm info
  2. Click Delete.

    A confirmation dialog appears.

    cockpit vm delete confirm
  3. 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.
  4. Click Delete.

    The VM and any selected storage files are deleted.