Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

Chapter 22. Graphical User Interface Tools for Guest Virtual Machine Management

In addition to virt-manager, Red Hat Enterprise Linux 7 provides the following tools that enable you to access your guest virtual machine's console.

22.1. virt-viewer

virt-viewer is a minimalistic command-line utility for displaying the graphical console of a guest virtual machine. The console is accessed using the VNC or SPICE protocol. The guest can be referred to by its name, ID, or UUID. If the guest is not already running, the viewer can be set to wait until it starts before attempting to connect to the console. The viewer can connect to remote hosts to get the console information and then also connect to the remote console using the same network transport.
In comparison with virt-manager, virt-viewer offers a smaller set of features, but is less resource-demanding. In addition, unlike virt-manager, virt-viewer in most cases does not require read-write permissions to libvirt. Therefore, it can be used by non-privileged users who should be able to connect to and display guests, but not to configure them.
To install virt-viewer, run:
# yum install virt-viewer

Syntax

The basic virt-viewer command-line syntax is as follows:
# virt-viewer [OPTIONS] {guest-name|id|uuid}
To see the full list of options available for use with virt-viewer, see the virt-viewer man page.

Connecting to a guest virtual machine

If used without any options, virt-viewer lists guests that it can connect to on the default hypervisor of the local system.
To connect to a specified guest virtual machine that uses the default hypervisor:
# virt-viewer guest-name
To connect to a guest virtual machine that uses the KVM-QEMU hypervisor:
# virt-viewer --connect qemu:///system guest-name
To connect to a remote console using TLS:
# virt-viewer --connect qemu://example.org/ guest-name
To connect to a console on a remote host by using SSH, look up the guest configuration and then make a direct non-tunneled connection to the console:
# virt-viewer --direct --connect qemu+ssh://root@example.org/ guest-name

Interface

By default, the virt-viewer interface provides only the basic tools for interacting with the guest:
Sample virt-viewer interface

Figure 22.1. Sample virt-viewer interface

Setting hotkeys

To create a customized keyboard shortcut (also referred to as a hotkey) for the virt-viewer session, use the --hotkeys option:
# virt-viewer --hotkeys=action1=key-combination1[,action2=key-combination2] guest-name
The following actions can be assigned to a hotkey:
  • toggle-fullscreen
  • release-cursor
  • smartcard-insert
  • smartcard-remove
Key-name combination hotkeys are not case-sensitive. Note that the hotkey setting does not carry over to future virt-viewer sessions.

Example 22.1. Setting a virt-viewer hotkey

To add a hotkey to change to full screen mode when connecting to a KVM-QEMU guest called testguest:
# virt-viewer --hotkeys=toggle-fullscreen=shift+f11 qemu:///system testguest

Kiosk mode

In kiosk mode, virt-viewer only allows the user to interact with the connected desktop, and does not provide any options to interact with the guest settings or the host system unless the guest is shut down. This can be useful for example when an administrator wants to restrict a user's range of actions to a specified guest.
To use kiosk mode, connect to a guest with the -k or --kiosk option.

Example 22.2. Using virt-viewer in kiosk mode

To connect to a KVM-QEMU virtual machine in kiosk mode that terminates after the machine is shut down, use the following command:
# virt-viewer --connect qemu:///system guest-name --kiosk --kiosk-quit on-disconnect
Note, however, that kiosk mode alone cannot ensure that the user does not interact with the host system or the guest settings after the guest is shut down. This would require further security measures, such as disabling the window manager on the host.