Red Hat Enterprise Linux-8-Configuring and Managing virtualization-en-US PDF
Red Hat Enterprise Linux-8-Configuring and Managing virtualization-en-US PDF
Red Hat Enterprise Linux-8-Configuring and Managing virtualization-en-US PDF
Setting up your host, creating and administering virtual machines, and understanding
virtualization features in Red Hat Enterprise Linux 8
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons
Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is
available at
http://creativecommons.org/licenses/by-sa/3.0/
. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must
provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert,
Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift,
Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States
and other countries.
Linux ® is the registered trademark of Linus Torvalds in the United States and other countries.
XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States
and/or other countries.
MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and
other countries.
Node.js ® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the
official Joyent Node.js open source or commercial project.
The OpenStack ® Word Mark and OpenStack logo are either registered trademarks/service marks
or trademarks/service marks of the OpenStack Foundation, in the United States and other
countries and are used with the OpenStack Foundation's permission. We are not affiliated with,
endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
Abstract
This document describes how to manage virtualization in Red Hat Enterprise Linux 8 (RHEL 8). In
addition to general information about virtualization, it describes how to manage virtualization using
command-line utilities, as well as using the web console.
Table of Contents
Table of Contents
. . . . . . . . . . . . . FEEDBACK
PROVIDING . . . . . . . . . . . . ON
. . . .RED
. . . . .HAT
. . . . .DOCUMENTATION
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7. . . . . . . . . . . . .
.CHAPTER
. . . . . . . . . . 1.. .VIRTUALIZATION
. . . . . . . . . . . . . . . . . . IN
. . .RHEL
. . . . . . 8. .-. .AN
. . . OVERVIEW
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8. . . . . . . . . . . . .
1.1. WHAT IS VIRTUALIZATION? 8
1.2. ADVANTAGES OF VIRTUALIZATION 8
1.3. VIRTUAL MACHINE COMPONENTS AND THEIR INTERACTION 9
1.4. TOOLS AND INTERFACES FOR VIRTUALIZATION MANAGEMENT 10
1.5. RED HAT VIRTUALIZATION SOLUTIONS 11
.CHAPTER
. . . . . . . . . . 2.
. . GETTING
. . . . . . . . . . .STARTED
. . . . . . . . . .WITH
. . . . . .VIRTUALIZATION
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
..............
2.1. ENABLING VIRTUALIZATION 13
2.2. CREATING VIRTUAL MACHINES 14
2.2.1. Creating virtual machines using the command-line interface 15
2.2.2. Creating virtual machines and installing guest operating systems using the web console 17
2.2.2.1. Creating virtual machines using the web console 18
2.2.2.2. Installing guest operating systems using the web console 19
2.3. STARTING VIRTUAL MACHINES 19
2.3.1. Starting a virtual machine using the command-line interface 20
2.3.2. Starting virtual machines using the web console 21
2.4. CONNECTING TO VIRTUAL MACHINES 21
2.4.1. Interacting with virtual machines using the web console 22
2.4.1.1. Viewing the virtual machine graphical console in the web console 22
2.4.1.2. Viewing the graphical console in a remote viewer using the web console 23
2.4.1.3. Viewing the virtual machine serial console in the web console 26
2.4.2. Opening a virtual machine graphical console using Virt Viewer 27
2.4.3. Connecting to a virtual machine using SSH 28
2.4.4. Opening a virtual machine serial console 30
2.4.5. Setting up easy access to remote virtualization hosts 31
2.5. SHUTTING DOWN VIRTUAL MACHINES 33
2.5.1. Shutting down a virtual machine using the command-line interface 33
2.5.2. Shutting down and restarting virtual machines using the web console 34
2.5.2.1. Shutting down virtual machines in the web console 34
2.5.2.2. Restarting virtual machines using the web console 34
2.5.2.3. Sending non-maskable interrupts to VMs using the web console 35
2.6. DELETING VIRTUAL MACHINES 36
2.6.1. Deleting virtual machines using the command line interface 36
2.6.2. Deleting virtual machines using the web console 36
2.7. RELATED INFORMATION 37
.CHAPTER
. . . . . . . . . . 3.
. . GETTING
. . . . . . . . . . .STARTED
. . . . . . . . . . WITH
. . . . . . VIRTUALIZATION
. . . . . . . . . . . . . . . . . . .ON
. . . IBM
. . . . .POWER
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38
..............
3.1. ENABLING VIRTUALIZATION ON IBM POWER 38
3.2. HOW VIRTUALIZATION ON IBM POWER DIFFERS FROM AMD64 AND INTEL 64 39
.CHAPTER
. . . . . . . . . . 4.
. . .GETTING
. . . . . . . . . .STARTED
. . . . . . . . . . WITH
. . . . . . VIRTUALIZATION
. . . . . . . . . . . . . . . . . . .ON
. . . IBM
. . . . .Z. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
..............
4.1. ENABLING VIRTUALIZATION ON IBM Z 42
4.2. HOW VIRTUALIZATION ON IBM Z DIFFERS FROM AMD64 AND INTEL 64 43
4.3. RELATED INFORMATION 45
.CHAPTER
. . . . . . . . . . 5.
. . USING
. . . . . . . .THE
. . . . .WEB
. . . . .CONSOLE
. . . . . . . . . . .FOR
. . . . .MANAGING
. . . . . . . . . . . . .VIRTUAL
. . . . . . . . . MACHINES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46
..............
5.1. OVERVIEW OF VIRTUAL MACHINE MANAGEMENT USING THE WEB CONSOLE 46
5.2. SETTING UP THE WEB CONSOLE TO MANAGE VIRTUAL MACHINES 46
5.3. VIRTUAL MACHINE MANAGEMENT FEATURES AVAILABLE IN THE WEB CONSOLE 47
1
Red Hat Enterprise Linux 8 Configuring and managing virtualization
5.4. DIFFERENCES BETWEEN VIRTUALIZATION FEATURES IN VIRTUAL MACHINE MANAGER AND THE WEB
CONSOLE 48
.CHAPTER
. . . . . . . . . . 6.
. . .VIEWING
. . . . . . . . . INFORMATION
. . . . . . . . . . . . . . . . ABOUT
. . . . . . . . VIRTUAL
. . . . . . . . . . MACHINES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50
..............
6.1. VIEWING VIRTUAL MACHINE INFORMATION USING THE COMMAND-LINE INTERFACE 50
6.2. VIEWING VIRTUAL MACHINE INFORMATION USING THE WEB CONSOLE 52
6.2.1. Viewing a virtualization overview in the web console 52
6.2.2. Viewing storage pool information using the web console 53
6.2.3. Viewing basic virtual machine information in the web console 55
6.2.4. Viewing virtual machine resource usage in the web console 56
6.2.5. Viewing virtual machine disk information in the web console 57
6.2.6. Viewing and editing virtual network interface information in the web console 58
. . . . . . . . . . . 7.
CHAPTER . . SAVING
. . . . . . . . . AND
. . . . . RESTORING
. . . . . . . . . . . . . VIRTUAL
. . . . . . . . . . MACHINES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
..............
7.1. HOW SAVING AND RESTORING VIRTUAL MACHINES WORKS 61
7.2. SAVING A VIRTUAL MACHINE USING THE COMMAND LINE INTERFACE 61
7.3. STARTING A VIRTUAL MACHINE USING THE COMMAND-LINE INTERFACE 62
7.4. STARTING VIRTUAL MACHINES USING THE WEB CONSOLE 63
. . . . . . . . . . . 8.
CHAPTER . . .CLONING
. . . . . . . . . . VIRTUAL
. . . . . . . . . .MACHINES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
..............
8.1. HOW CLONING VIRTUAL MACHINES WORKS 65
8.2. CREATING A VIRTUAL MACHINE TEMPLATE 65
8.3. CLONING A VIRTUAL MACHINE USING THE COMMAND-LINE INTERFACE 67
. . . . . . . . . . . 9.
CHAPTER . . .MANAGING
. . . . . . . . . . . . VIRTUAL
. . . . . . . . . .DEVICES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69
..............
9.1. HOW VIRTUAL DEVICES WORK 69
9.2. ATTACHING DEVICES TO VIRTUAL MACHINES 70
9.3. MODIFYING DEVICES ATTACHED TO VIRTUAL MACHINES 71
9.4. REMOVING DEVICES FROM VIRTUAL MACHINES 73
9.5. TYPES OF VIRTUAL DEVICES 74
9.6. MANAGING SR-IOV DEVICES 75
9.6.1. What is SR-IOV? 75
9.6.2. Attaching SR-IOV networking devices to virtual machines 78
9.6.3. Supported devices for SR-IOV assignment 82
.CHAPTER
. . . . . . . . . . 10.
. . . MANAGING
. . . . . . . . . . . . .STORAGE
. . . . . . . . . . .FOR
. . . . .VIRTUAL
. . . . . . . . . .MACHINES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
..............
10.1. UNDERSTANDING VIRTUAL MACHINE STORAGE 83
10.1.1. Virtual machine storage 83
10.1.2. Storage pools 83
10.1.3. Storage volumes 85
10.2. MANAGING STORAGE FOR VIRTUAL MACHINES USING THE CLI 85
10.2.1. Viewing virtual machine storage information using the CLI 85
10.2.1.1. Viewing storage pool information using the CLI 86
10.2.1.2. Viewing storage volume information using the CLI 86
10.2.2. Creating and assigning storage for virtual machines using the CLI 87
10.2.2.1. Creating and assigning directory-based storage for virtual machines using the CLI 88
10.2.2.1.1. Creating directory-based storage pools using the CLI 88
10.2.2.1.2. Directory-based storage pool parameters 90
10.2.2.2. Creating and assigning disk-based storage for virtual machines using the CLI 90
10.2.2.2.1. Creating disk-based storage pools using the CLI 90
10.2.2.2.2. Disk-based storage pool parameters 93
10.2.2.3. Creating and assigning filesystem-based storage for virtual machines using the CLI 94
10.2.2.3.1. Creating filesystem-based storage pools using the CLI 94
10.2.2.3.2. Filesystem-based storage pool parameters 96
2
Table of Contents
10.2.2.4. Creating and assigning GlusterFS storage for virtual machines using the CLI 97
10.2.2.4.1. Creating GlusterFS-based storage pools using the CLI 97
10.2.2.4.2. GlusterFS-based storage pool parameters 99
10.2.2.5. Creating and assigning iSCSI-based storage for virtual machines using the CLI 100
Recommendations 100
Prerequisites 100
10.2.2.5.1. Creating iSCSI-based storage pools using the CLI 100
10.2.2.5.2. iSCSI-based storage pool parameters 102
10.2.2.5.3. Securing iSCSI storage pools with libvirt secrets 103
10.2.2.6. Creating and assigning LVM-based storage for virtual machines using the CLI 105
10.2.2.6.1. Creating LVM-based storage pools using the CLI 105
10.2.2.6.2. LVM-based storage pool parameters 107
10.2.2.7. Creating and assigning network-based storage for virtual machines using the CLI 108
10.2.2.7.1. Creating network-based storage pools using the CLI 108
10.2.2.7.2. NFS-based storage pool parameters 110
10.2.2.8. Creating and assigning vHBA-based storage for virtual machines using the CLI 111
10.2.2.8.1. Recommendations 111
10.2.2.8.2. Creating vHBAs 112
10.2.2.8.3. Creating vHBA-based storage pools using the CLI 114
10.2.2.8.4. vHBA-based storage pool parameters 116
10.2.2.9. Creating and assigning storage volumes using the CLI 117
10.2.2.9.1. Procedure 118
10.2.3. Deleting storage for virtual machines using the CLI 119
10.2.3.1. Deleting storage pools using the CLI 119
10.2.3.2. Deleting storage volumes using the CLI 120
10.3. MANAGING STORAGE FOR VIRTUAL MACHINES USING THE WEB CONSOLE 121
10.3.1. Viewing storage pool information using the web console 121
10.3.2. Creating storage pools using the web console 123
10.3.3. Removing storage pools using the web console 125
10.3.4. Deactivating storage pools using the web console 126
10.3.5. Creating storage volumes using the web console 127
10.3.6. Removing storage volumes using the web console 129
10.3.7. Managing virtual machine disks using the web console 131
10.3.7.1. Viewing virtual machine disk information in the web console 131
10.3.7.2. Adding new disks to virtual machines using the web console 133
10.3.7.3. Attaching existing disks to virtual machines using the web console 135
10.3.7.4. Detaching disks from virtual machines 137
. . . . . . . . . . . 11.
CHAPTER . . .MANAGING
. . . . . . . . . . . . NVIDIA
. . . . . . . . VGPU
. . . . . . .DEVICES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
...............
11.1. SETTING UP NVIDIA VGPU DEVICES 139
11.2. REMOVING NVIDIA VGPU DEVICES 141
11.3. OBTAINING NVIDIA VGPU INFORMATION ABOUT YOUR SYSTEM 141
11.4. REMOTE DESKTOP STREAMING SERVICES FOR NVIDIA VGPU 142
11.5. RELATED INFORMATION 142
. . . . . . . . . . . 12.
CHAPTER . . . MIGRATING
. . . . . . . . . . . . .VIRTUAL
. . . . . . . . . .MACHINES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .143
...............
12.1. HOW MIGRATING VIRTUAL MACHINES WORKS 143
12.2. REQUIREMENTS AND LIMITATIONS FOR MIGRATING VIRTUAL MACHINES 144
12.3. SHARING VIRTUAL MACHINE IMAGES WITH OTHER HOSTS 144
12.4. MIGRATING A VIRTUAL MACHINE USING THE COMMAND-LINE INTERFACE 146
12.5. SUPPORTED HOSTS FOR VIRTUAL MACHINE MIGRATION 147
12.6. ADDITIONAL RESOURCES 148
. . . . . . . . . . . 13.
CHAPTER . . . OPTIMIZING
. . . . . . . . . . . . . .VIRTUAL
. . . . . . . . . MACHINE
. . . . . . . . . . .PERFORMANCE
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149
...............
3
Red Hat Enterprise Linux 8 Configuring and managing virtualization
. . . . . . . . . . . 14.
CHAPTER . . . SHARING
. . . . . . . . . . .FILES
. . . . . .BETWEEN
. . . . . . . . . . . THE
. . . . .HOST
. . . . . . AND
. . . . . .ITS
. . . VIRTUAL
. . . . . . . . . . MACHINES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
..............
14.1. SHARING FILES BETWEEN THE HOST AND LINUX VIRTUAL MACHINES 171
14.2. SHARING FILES BETWEEN THE HOST AND WINDOWS VIRTUAL MACHINES 173
. . . . . . . . . . . 15.
CHAPTER . . . CONFIGURING
. . . . . . . . . . . . . . . . VIRTUAL
. . . . . . . . . .MACHINE
. . . . . . . . . . NETWORK
. . . . . . . . . . . .CONNECTIONS
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178
...............
15.1. UNDERSTANDING VIRTUAL NETWORKING 178
15.1.1. Virtual networking default configuration 179
15.1.2. Virtual networking with network address translation 180
15.1.3. Virtual networking in routed mode 181
15.1.4. Virtual networking in bridged mode 182
15.1.5. Virtual networking in isolated mode 184
15.1.6. Virtual networking in open mode 184
15.1.7. Virtual networking DNS and DHCP 184
15.2. USING THE WEB CONSOLE FOR MANAGING VIRTUAL MACHINE NETWORK INTERFACES 184
15.2.1. Viewing and editing virtual network interface information in the web console 185
15.2.2. Connecting virtual network interfaces in the web console 186
15.2.3. Disconnecting virtual network interfaces in the web console 187
15.3. ADDITIONAL RESOURCES 188
. . . . . . . . . . . 16.
CHAPTER . . . SECURING
. . . . . . . . . . . .VIRTUAL
. . . . . . . . . .MACHINES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .189
...............
16.1. HOW SECURITY WORKS IN VIRTUAL MACHINES 189
16.2. BEST PRACTICES FOR SECURING VIRTUAL MACHINES 190
16.3. CREATING A SECUREBOOT VIRTUAL MACHINE 191
16.4. AUTOMATIC FEATURES FOR VIRTUAL MACHINE SECURITY 192
16.5. VIRTUALIZATION BOOLEANS 193
. . . . . . . . . . . 17.
CHAPTER . . . INSTALLING
. . . . . . . . . . . . . .AND
. . . . .MANAGING
. . . . . . . . . . . . WINDOWS
. . . . . . . . . . . .VIRTUAL
. . . . . . . . . .MACHINES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .195
...............
17.1. INSTALLING WINDOWS VIRTUAL MACHINES 195
17.2. OPTIMIZING WINDOWS VIRTUAL MACHINES 196
17.2.1. Installing KVM paravirtualized drivers for Windows virtual machines 196
17.2.1.1. How Windows virtio drivers work 196
17.2.1.2. Preparing virtio driver installation media on a host machine 197
17.2.1.3. Installing virtio drivers on a Windows guest 198
4
Table of Contents
. . . . . . . . . . . 18.
CHAPTER . . . CREATING
. . . . . . . . . . . .NESTED
. . . . . . . . .VIRTUAL
. . . . . . . . . .MACHINES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205
...............
18.1. CREATING A NESTED VIRTUAL MACHINE ON INTEL 205
18.2. CREATING A NESTED VIRTUAL MACHINE ON AMD 206
18.3. CREATING A NESTED VIRTUAL MACHINE ON IBM Z 207
18.4. CREATING A NESTED VIRTUAL MACHINE ON IBM POWER9 208
18.5. RESTRICTIONS AND LIMITATIONS FOR NESTED VIRTUALIZATION 209
. . . . . . . . . . . 19.
CHAPTER . . . FEATURE
. . . . . . . . . . .SUPPORT
. . . . . . . . . . AND
. . . . . .LIMITATIONS
. . . . . . . . . . . . . .IN
. . .RHEL
. . . . . .8. .VIRTUALIZATION
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211
..............
19.1. HOW RHEL 8 VIRTUALIZATION SUPPORT WORKS 211
19.2. RECOMMENDED FEATURES IN RHEL 8 VIRTUALIZATION 211
19.3. UNSUPPORTED FEATURES IN RHEL 8 VIRTUALIZATION 212
19.4. RESOURCE ALLOCATION LIMITS IN RHEL 8 VIRTUALIZATION 215
19.5. AN OVERVIEW OF VIRTUALIZATION FEATURES SUPPORT 215
5
Red Hat Enterprise Linux 8 Configuring and managing virtualization
6
PROVIDING FEEDBACK ON RED HAT DOCUMENTATION
1. Make sure you are viewing the documentation in the Multi-page HTML format. In addition,
ensure you see the Feedback button in the upper right corner of the document.
2. Use your mouse cursor to highlight the part of text that you want to comment on.
3. Click the Add Feedback pop-up that appears below the highlighted text.
3. Fill in the Description field with your suggestion for improvement. Include a link to the
relevant part(s) of documentation.
7
Red Hat Enterprise Linux 8 Configuring and managing virtualization
In other words, virtualization makes it possible to have operating systems within operating systems.
VMs enable you to safely test software configurations and features, run legacy software, or optimize the
workload efficiency of your hardware. For more information on the benefits, see Section 1.2,
“Advantages of virtualization”.
For more information on what virtualization is, see the Red Hat Customer Portal .
To try out virtualization in RHEL 8, see Chapter 2, Getting started with virtualization.
NOTE
For example, what the guest OS sees as its disk can be represented as a file on the host file
system, and the size of that disk is less constrained than the available sizes for physical disks.
Software-controlled configurations
The entire configuration of a VM is saved as data on the host, and is under software control.
Therefore, a VM can easily be created, removed, cloned, migrated, operated remotely, or
connected to remote storage.
A single physical machine can host a large number of VMs. Therefore, it avoids the need for
8
CHAPTER 1. VIRTUALIZATION IN RHEL 8 - AN OVERVIEW
A single physical machine can host a large number of VMs. Therefore, it avoids the need for
multiple physical machines to do the same tasks, and thus lowers the space, power, and
maintenance requirements associated with physical hardware.
Software compatibility
Because a VM can use a different OS than its host, virtualization makes it possible to run
applications that were not originally released for your host OS. For example, using a RHEL 6
guest OS, you can run applications released for RHEL 6 on a RHEL 8 host system.
NOTE
Not all operating systems are supported as a guest OS in a RHEL 8 host. For
details, see Section 19.2, “Recommended features in RHEL 8 virtualization” .
Hypervisor
The basis of creating virtual machines (VMs) in RHEL 8 is the hypervisor, a software layer that controls
hardware and enables running multiple operating systems on a host machine.
The hypervisor includes the Kernel-based Virtual Machine (KVM)module and virtualization kernel
drivers, such as virtio and vfio. These components ensure that the Linux kernel on the host machine
provides resources for virtualization to user-space software.
At the user-space level, the QEMU emulator simulates a complete virtualized hardware platform that
the guest operating system can run in, and manages how resources are allocated on the host and
presented to the guest.
In addition, the libvirt software suite serves as a management and communication layer, making QEMU
easier to interact with, enforcing security rules, and providing a number of additional tools for
configuring and running VMs.
XML configuration
A host-based XML configuration file (also known as a domain XML file) describes a specific VM. It
includes:
Metadata such as the name of the VM, time zone, and other information about the VM.
A description of the devices in the VM, including virtual CPUs (vCPUS), storage devices,
input/output devices, network interface cards, and other hardware, real and virtual.
VM settings such as the maximum amount of memory it can use, restart settings, and other
settings about the behavior of the VM.
Component interaction
When a VM is started, the hypervisor uses the XML configuration to create an instance of the VM as a
user-space process on the host. The hypervisor also makes the VM process accessible to the host-
based interfaces, such as the virsh, virt-install, and guestfish utilities, or the web console GUI.
When these virtualization tools are used, libvirt translates their input into instructions for QEMU. QEMU
communicates the instructions to KVM, which ensures that the kernel appropriately assigns the
resources necessary to carry out the instructions. As a result, QEMU can execute the corresponding
9
Red Hat Enterprise Linux 8 Configuring and managing virtualization
user-space changes, such as creating or modifying a VM, or performing an action in the VM’s guest
operating system.
NOTE
For more information on the host-based interfaces, see Section 1.4, “Tools and interfaces for
virtualization management”.
Command-line interface
The CLI is the most powerful method of managing virtualization in RHEL 8. Prominent CLI commands
for virtual machine (VM) management include:
virsh - A versatile virtualization command-line utility and shell with a great variety of purposes,
depending on the provided arguments. For example:
10
CHAPTER 1. VIRTUALIZATION IN RHEL 8 - AN OVERVIEW
virt-install - A CLI utility for creating new VMs. For more information, see the virt-install(1)
man page.
guestfish - A utility for examining and modifying VM disk images. For more information, see the
guestfish(1) man page.
Graphical interfaces
You can use the following GUIs to manage virtualization in RHEL 8:
The RHEL 8 web console, also known as Cockpit, provides a remotely accessible and easy to
use graphical user interface for managing VMs and virtualization hosts.
For instructions on basic virtualization management with the web console, see Chapter 5, Using
the web console for managing virtual machines.
The Virtual Machine Manager (virt-manager) application provides a specialized GUI for
managing VMs and virtualization hosts.
IMPORTANT
Although still supported in RHEL 8, virt-manager has been deprecated. The web
console is intended to become its replacement in a subsequent release. It is,
therefore, recommended that you get familiar with the web console for
managing virtualization in a GUI.
However, in RHEL 8, some features may only be accessible from either virt-
manager or the command line. For details, see Section 5.4, “Differences between
virtualization features in Virtual Machine Manager and the web console”.
The Gnome Boxes application is a lightweight graphical interface to view and access VMs and
remote systems. Gnome Boxes is primarily designed for use on desktop systems.
IMPORTANT
Additional resources
For instructions on basic virtualization management using CLI and GUI, see Chapter 2, Getting
started with virtualization.
RHV is designed for enterprise-class scalability and performance, and enables the management of
11
Red Hat Enterprise Linux 8 Configuring and managing virtualization
RHV is designed for enterprise-class scalability and performance, and enables the management of
your entire virtual infrastructure, including hosts, virtual machines, networks, storage, and users from
a centralized graphical interface.
For information about the differences between virtualization in Red Hat Enterprise Linux and Red
Hat Virtualization, see the Red Hat Customer Portal .
Red Hat Virtualization can be used by enterprises running large deployments or mission-critical
applications. Examples of large deployments suited to Red Hat Virtualization include databases,
trading platforms, and messaging systems that must run continuously without any downtime.
For more information about Red Hat Virtualization, see the Red Hat Customer Portal or the Red Hat
Virtualization documentation suite.
To download a fully supported 60-day evaluation version of Red Hat Virtualization, see
https://access.redhat.com/products/red-hat-virtualization/evaluation
To download a fully supported 60-day evaluation version of Red Hat OpenStack Platform, see
https://access.redhat.com/products/red-hat-openstack-platform/evaluation
In addition, specific Red Hat products provide operating-system-level virtualization, also known as
containerization:
Containers are isolated instances of the host OS and operate on top of an existing OS kernel.
For more information on containers, see the Red Hat Customer Portal .
Containers do not have the versatility of KVM virtualization, but are more lightweight and
flexible to handle. For a more detailed comparison, see the Introduction to Linux Containers .
12
CHAPTER 2. GETTING STARTED WITH VIRTUALIZATION
1. Enable the virtualization module and install the virtualization packages - see Section 2.1,
“Enabling virtualization”.
For CLI, see Section 2.2.1, “Creating virtual machines using the command-line interface” .
For GUI, see Section 2.2.2, “Creating virtual machines and installing guest operating
systems using the web console”.
For CLI, see Section 2.3.1, “Starting a virtual machine using the command-line interface” .
For GUI, see Section 2.3.2, “Starting virtual machines using the web console” .
For CLI, see Section 2.4.3, “Connecting to a virtual machine using SSH” or Section 2.4.2,
“Opening a virtual machine graphical console using Virt Viewer”.
For GUI, see Section 2.4.1, “Interacting with virtual machines using the web console” .
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.
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:
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
13
Red Hat Enterprise Linux 8 Configuring and managing virtualization
# 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.
Prerequisites
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.
14
CHAPTER 2. GETTING STARTED WITH VIRTUALIZATION
WARNING
Prerequisites
An operating system (OS) installation source, which can be one of the following, and be
available locally or on a network:
Optionally, a Kickstart file can also 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:
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.
15
Red Hat Enterprise Linux 8 Configuring and managing virtualization
# 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.
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-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.
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.
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
16
CHAPTER 2. GETTING STARTED WITH VIRTUALIZATION
b. Verify that the libvirt default network is active and configured to start automatically:
i. If activating the default network fails with the following error, the libvirt-daemon-
config-network package has not been installed correctly.
ii. 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.
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.
17
Red Hat Enterprise Linux 8 Configuring and managing virtualization
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:
Procedure
1. In the Virtual Machines interface of the web console, click Create VM.
The Create New Virtual Machine dialog appears.
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.
18
CHAPTER 2. GETTING STARTED WITH VIRTUALIZATION
Operating System - The VM’s operating system. Note that Red Hat provides support only
for a limited set of guest operating systems .
Size - The amount of storage space 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
For information on installing an operating system on a VM, see Section 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
To use the web console to manage VMs, install the web console VM plug-in .
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
19
Red Hat Enterprise Linux 8 Configuring and managing virtualization
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”.
Prerequisites
Procedure
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.
[email protected]'s password:
Last login: Mon Feb 18 07:28:55 2019
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.
20
CHAPTER 2. GETTING STARTED WITH VIRTUALIZATION
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
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
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”.
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 .
21
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Prerequisites
The VMs you want to interact with are installed and started.
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
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.
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.
22
CHAPTER 2. GETTING STARTED WITH VIRTUALIZATION
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
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.
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.
23
Red Hat Enterprise Linux 8 Configuring and managing virtualization
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.
24
CHAPTER 2. GETTING STARTED WITH VIRTUALIZATION
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.
25
Red Hat Enterprise Linux 8 Configuring and managing virtualization
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
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.
26
CHAPTER 2. GETTING STARTED WITH VIRTUALIZATION
You can disconnect and reconnect the serial console from the VM.
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”.
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,
27
Red Hat Enterprise Linux 8 Configuring and managing virtualization
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.
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”.
28
CHAPTER 2. GETTING STARTED WITH VIRTUALIZATION
To interact with the terminal of a virtual machine (VM) using the SSH connection protocol, follow the
procedure below:
Prerequisites
The libvirt-nss component must be installed and enabled on the VM’s host. If it is not, do the
following:
b. 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 [email protected]
[email protected]'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:
29
Red Hat Enterprise Linux 8 Configuring and managing virtualization
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.
a. On the VM, edit the /etc/default/grub file and add console=ttyS0 to the line that starts
with GRUB_CMDLINE_LINUX.
b. Clear the kernel options that may prevent your changes from taking effect.
# 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
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:
Subscription-name
30
CHAPTER 2. GETTING STARTED WITH VIRTUALIZATION
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.
[email protected]'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:
[email protected]'s password:
Last login: Mon Feb 18 07:28:55 2019
Id Name State
---------------------------------
1 remote-guest running
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 [email protected]:
Host tyrannosaurus
User root
Hostname 10.0.0.1
31
Red Hat Enterprise Linux 8 Configuring and managing virtualization
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:
[email protected]'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.
As a result, all libvirt-based commands will automatically be performed on the specified remote
host.
$ virsh list
[email protected]'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.
32
CHAPTER 2. GETTING STARTED WITH VIRTUALIZATION
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:
virt-install
virt-viewer
virsh
virt-manager
Use a shutdown command appropriate to the guest OS while connected to the guest .
[email protected]'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:
NOTE
33
Red Hat Enterprise Linux 8 Configuring and managing virtualization
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.
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
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.
Troubleshooting
If the VM does not shut down, click the arrow next to the Shut Down button and select Force
Shut Down.
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”.
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
34
CHAPTER 2. GETTING STARTED WITH VIRTUALIZATION
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
If the VM does not restart, click the arrow next to the Restart button and select Force Restart.
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”.
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
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
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”.
35
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Prerequisites
Procedure
Additional resources
For other virsh undefine arguments, see the virsh man page.
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
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.
36
CHAPTER 2. GETTING STARTED WITH VIRTUALIZATION
2. Click Delete.
A confirmation dialog appears.
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.
37
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Apart from the information in the following sections, using virtualization on IBM POWER works the same
as on AMD64 and Intel 64. Therefore, you can see other RHEL 8 virtualization documentation for more
information when using virtualization on IBM POWER.
Prerequisites
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.
If the output of this command includes the PowerNV entry, you are running a PowerNV machine
type and can use virtualization on IBM POWER.
Procedure
# modprobe kvm_hv
38
CHAPTER 3. GETTING STARTED WITH VIRTUALIZATION ON IBM POWER
# 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 : PASS
7. 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.
Memory requirements
VMs on IBM POWER consume more memory. Therefore, the recommended minimum memory
allocation for a virtual machine (VM) on an IBM POWER host is 2GB RAM.
Display protocols
The SPICE protocol is not supported on IBM POWER systems. To display the graphical output of a
VM, use the VNC protocol. In addition, only the following virtual graphics card devices are supported:
vga - only supported in -vga std mode and not in -vga cirrus mode.
virtio-vga
39
Red Hat Enterprise Linux 8 Configuring and managing virtualization
virtio-gpu
SMBIOS
SMBIOS configuration is not available.
Memory allocation errors
POWER8 VMs, including compatibility mode VMs, may fail with an error similar to:
qemu-kvm: Failed to allocate KVM HPT of order 33 (try smaller maxmem?): Cannot allocate
memory
This is significantly more likely to occur on VMs that use RHEL 7.3 and prior as the guest OS.
To fix the problem, increase the CMA memory pool available for the guest’s hashed page table (HPT)
by adding kvm_cma_resv_ratio=memory to the host’s kernel command line, where memory is the
percentage of the host memory that should be reserved for the CMA pool (defaults to 5).
Huge pages
Transparent huge pages (THPs) do not provide any notable performance benefits on IBM POWER8
VMs. However, IBM POWER9 VMs can benefit from THPs as expected.
In addition, the size of static huge pages on IBM POWER8 systems are 16 MiB and 16 GiB, as
opposed to 2 MiB and 1 GiB on AMD64, Intel 64, and IBM POWER9. As a consequence, to migrate a
VM configured with static huge pages from an IBM POWER8 host to an IBM POWER9 host, you must
first set up 1GiB huge pages on the VM.
kvm-clock
The kvm-clock service does not have to be configured for time management in VMs on IBM
POWER9.
pvpanic
IBM POWER9 systems do not support the pvpanic device. However, an equivalent functionality is
available and activated by default on this architecture. To enable it in a VM, use the <on_crash>
XML configuration element with the preserve value.
In addition, make sure to remove the <panic> element from the <devices> section, as its presence
can lead to the VM failing to boot on IBM POWER systems.
Single-threaded host
On IBM POWER8 systems, the host machine must run in single-threaded mode to support VMs.
This is automatically configured if the qemu-kvm packages are installed. However, VMs running on
single-threaded hosts can still use multiple threads.
Peripheral devices
A number of peripheral devices supported on AMD64 and Intel 64 systems are not supported on IBM
POWER systems, or a different device is supported as a replacement.
Devices used for PCI-E hierarchy, including ioh3420 and xio3130-downstream, are not
supported. This functionality is replaced by multiple independent PCI root bridges provided
by the spapr-pci-host-bridge device.
UHCI and EHCI PCI controllers are not supported. Use OHCI and XHCI controllers instead.
IDE devices, including the virtual IDE CD-ROM (ide-cd) and the virtual IDE disk ( ide-hd), are
not supported. Use the virtio-scsi and virtio-blk devices instead.
40
CHAPTER 3. GETTING STARTED WITH VIRTUALIZATION ON IBM POWER
Emulated PCI NICs (rtl8139) are not supported. Use the virtio-net device instead.
Sound devices, including intel-hda, hda-output, and AC97, are not supported.
USB redirection devices, including usb-redir and usb-tablet, are not supported.
Additional sources
For a comparison of selected supported and unsupported virtualization features across system
architectures supported by Red Hat, see Section 19.5, “An overview of virtualization features
support”.
41
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Apart from the information in the following sections, using virtualization on IBM Z works the same as on
AMD64 and Intel 64. Therefore, you can see other RHEL 8 virtualization documentation for more
information when using virtualization on IBM Z.
Prerequisites
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.
RHEL 8 has to be installed on a logical partition (LPAR). In addition, the LPAR must support the
start-interpretive execution (SIE) virtualization functions.
To verify this, search for sie in your /proc/cpuinfo file.
Procedure
# modprobe kvm
42
CHAPTER 4. GETTING STARTED WITH VIRTUALIZATION ON IBM Z
# 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
[...]
7. 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.
No graphical output
Displaying the VM graphical output is not possible when connecting to the VM using the VNC
protocol. This is due to the gnome-desktop utility not being supported on IBM Z.
PCI and USB devices
Virtual PCI and USB devices are not supported on IBM Z. This also means that virtio-*-pci devices
are unsupported, and virtio-*-ccw devices should be used instead. For example, use virtio-net-ccw
instead of virtio-net-pci.
Note that direct attachment of PCI devices, also known as PCI passthrough, is supported.
43
Red Hat Enterprise Linux 8 Configuring and managing virtualization
<devices>
<disk type='file' snapshot='external'>
<driver name="tap" type="aio" cache="default"/>
<source file='/var/lib/xen/images/fv0' startupPolicy='optional'>
<seclabel relabel='no'/>
</source>
<target dev='hda' bus='ide'/>
<iotune>
<total_bytes_sec>10000000</total_bytes_sec>
<read_iops_sec>400000</read_iops_sec>
<write_iops_sec>100000</write_iops_sec>
</iotune>
<boot order='2'/>
[...]
</disk>
NOTE
<devices>
<watchdog model='diag288' action='poweroff'/>
</devices>
kvm-clock
The kvm-clock service is specific to AMD64 and Intel 64 systems, and does not have to be
configured for VM time management on IBM Z.
v2v and p2v
The virt-v2v and virt-p2v utilities are supported only on the AMD64 and Intel 64 architecture, and
are not provided on IBM Z.
Nested virtualization
Creating nested VMs requires different settings on IBM Z than on AMD64 and Intel 64. For details,
see Chapter 18, Creating nested virtual machines .
44
CHAPTER 4. GETTING STARTED WITH VIRTUALIZATION ON IBM Z
Additional sources
For a comparison of selected supported and unsupported virtualization features across system
architectures supported by Red Hat, see Section 19.5, “An overview of virtualization features
support”.
This makes the ppa15 and bpb features available to the guest if the host supports them.
If using a specific host model, add the ppa15 and pbp features. The following example uses
the zEC12 CPU model:
Note that when using the ppa15 feature with the z114 and z196 CPU models on a host
machine that uses a z12 CPU, you also need to use the latest microcode level (bundle 95 or
later).
45
Red Hat Enterprise Linux 8 Configuring and managing virtualization
The following sections describe the web console’s virtualization management capabilities and provide
instructions for using them.
For a comprehensive list of VM management actions that the web console provides, see Section 5.3,
“Virtual machine management features available in the web console”.
NOTE
The Virtual Machine Manager (virt-manager) application is still supported in RHEL 8 but
has been deprecated. The web console is intended to become its replacement in a
subsequent release. It is, therefore, recommended that you get familiar with the web
console for managing virtualization in a GUI.
However, in RHEL 8, some features may only be accessible from either virt-manager or
the command line. For details, see Section 5.4, “Differences between virtualization
features in Virtual Machine Manager and the web console”.
For more information on the Virtual Machine Manager, see RHEL 7 documentation .
46
CHAPTER 5. USING THE WEB CONSOLE FOR MANAGING VIRTUAL MACHINES
Before using the RHEL 8 web console to manage VMs, you must install the web console virtual machine
plug-in.
Prerequisites
If the web console is not installed, see the Managing systems using the web console guide for
more information about installing the web console.
Procedure
If the installation is successful, Virtual Machines appears in the web console side menu.
Additional resources
For instructions on connecting to the web console, as well as other information on using the web
console, see the Managing systems using the RHEL 8 web console document.
Create a VM and install it with a guest operating system. For details, see Section 2.2.2, “Creating
virtual machines and installing guest operating systems using the web console”.
47
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Delete a VM. For details, see Section 2.6.2, “Deleting virtual machines using the web console” .
Start, shut down, and restart the VM. For details, see Section 2.3.2, “Starting virtual machines
using the web console” and Section 2.5.2, “Shutting down and restarting virtual machines using
the web console”.
Connect to and interact with a VM using a variety of consoles. For details, see Section 2.4.1,
“Interacting with virtual machines using the web console”.
View a variety of information about the VM. For details, see Section 6.2, “Viewing virtual
machine information using the web console”.
Adjust the host memory allocated to a VM. For details, see Section 13.3.1, “Adding and removing
virtual machine memory using the web console”.
Manage network connections for the VM. For details, see Section 15.2, “Using the web console
for managing virtual machine network interfaces”.
Manage the VM storage available on the host and attach virtual disks to the VM. For details, see
Section 10.3, “Managing storage for virtual machines using the web console” .
Configure the virtual CPU settings of the VM. For details, see Section 13.5.2, “Managing virtual
CPUs using the web console”.
If a feature is available in a later version of RHEL 8, the minimum RHEL 8 version appears in the Web
console column.
48
CHAPTER 5. USING THE WEB CONSOLE FOR MANAGING VIRTUAL MACHINES
• Filesystem Directory
• iSCSI Target
• Partition-based
• GlusterFS-based
• Multipath-based
• RBD-based
49
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Procedure
50
CHAPTER 6. VIEWING INFORMATION ABOUT VIRTUAL MACHINES
For instructions on managing a VM’s storage, see Chapter 10, Managing storage for virtual
machines.
VCPU: 1
CPU: 0
State: running
CPU time: 88.6s
CPU Affinity: yyyy
To configure and optimize the vCPUs in your VM, see Section 13.5, “Optimizing virtual machine
CPU performance”.
51
Red Hat Enterprise Linux 8 Configuring and managing virtualization
For details about network interfaces, VM networks, and instructions for configuring them, see
Chapter 15, Configuring virtual machine network connections .
For instructions on viewing information about storage pools and storage volumes on your host,
see Section 10.2.1, “Viewing virtual machine storage information using the CLI” .
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
Storage Pools - The number of storage pools that can be accessed by the web console and
their state.
Networks - The number of networks that can be accessed by the web console and their state.
52
CHAPTER 6. VIEWING INFORMATION ABOUT VIRTUAL MACHINES
Additional resources
For instructions on viewing detailed information about the storage pools the web console
session can access, see Section 6.2.2, “Viewing storage pool information using the web console” .
For instructions on viewing basic information about a selected VM to which the web console
session is connected, see Section 6.2.3, “Viewing basic virtual machine information in the web
console”.
For instructions on viewing resource usage for a selected VM to which the web console session
is connected, see Section 6.2.4, “Viewing virtual machine resource usage in the web console” .
For instructions on viewing disk information about a selected VM to which the web console
session is connected, see Section 6.2.5, “Viewing virtual machine disk information in the web
console”.
For instructions on viewing virtual network interface information about a selected VM to which
the web console session is connected, see Section 6.2.6, “Viewing and editing virtual network
interface information in the web console”.
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
1. Click Storage Pools at the top of the Virtual Machines interface. The Storage Pools window
appears, showing a list of configured storage pools.
53
Red Hat Enterprise Linux 8 Configuring and managing virtualization
2. Click the row of the storage whose information you want to see.
The row expands to reveal the Overview pane with the following information about the selected
storage pool:
3. To view a list of storage volumes created from the storage pool, click Storage Volumes.
The Storage Volumes pane appears, showing a list of configured storage volumes with their
sizes and the amount of space used.
Additional resources
For instructions on viewing information about all of the VMs to which the web console session is
connected, see Section 6.2.1, “Viewing a virtualization overview in the web console” .
For instructions on viewing basic information about a selected VM to which the web console
session is connected, see Section 6.2.3, “Viewing basic virtual machine information in the web
console”.
For instructions on viewing resource usage for a selected VM to which the web console session
is connected, see Section 6.2.4, “Viewing virtual machine resource usage in the web console” .
For instructions on viewing disk information about a selected VM to which the web console
54
CHAPTER 6. VIEWING INFORMATION ABOUT VIRTUAL MACHINES
For instructions on viewing disk information about a selected VM to which the web console
session is connected, see Section 6.2.5, “Viewing virtual machine disk information in the web
console”.
For instructions on viewing virtual network interface information about a selected VM to which
the web console session is connected, see Section 6.2.6, “Viewing and editing virtual network
interface information in the web console”.
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
CPU Type - The architecture of the virtual CPUs configured for the VM.
55
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Additional resources
For instructions on viewing information about all of the VMs to which the web console session is
connected, see Section 6.2.1, “Viewing a virtualization overview in the web console” .
For instructions on viewing information about the storage pools to which the web console
session is connected, see Section 6.2.2, “Viewing storage pool information using the web
console”.
For instructions on viewing resource usage for a selected VM to which the web console session
is connected, see Section 6.2.4, “Viewing virtual machine resource usage in the web console” .
For instructions on viewing disk information about a selected VM to which the web console
session is connected, see Section 6.2.5, “Viewing virtual machine disk information in the web
console”.
For instructions on viewing virtual network interface information about a selected VM to which
the web console session is connected, see Section 6.2.6, “Viewing and editing virtual network
interface information in the web console”.
To see more detailed virtual CPU information and configure the virtual CPUs configured for a
VM, see Section 13.5.2, “Managing virtual CPUs using the web console” .
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
1. In the Virtual Machines interface, click the row of the VM whose information you want to see.
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 Usage.
The Usage pane appears with information about the memory and virtual CPU usage of the VM.
Additional resources
56
CHAPTER 6. VIEWING INFORMATION ABOUT VIRTUAL MACHINES
Additional resources
For instructions on viewing information about all of the VMs to which the web console session is
connected, see Section 6.2.1, “Viewing a virtualization overview in the web console” .
For instructions on viewing information about the storage pools to which the web console
session is connected, see Section 6.2.2, “Viewing storage pool information using the web
console”.
For instructions on viewing basic information about a selected VM to which the web console
session is connected, see Section 6.2.3, “Viewing basic virtual machine information in the web
console”.
For instructions on viewing disk information about a selected VM to which the web console
session is connected, see Section 6.2.5, “Viewing virtual machine disk information in the web
console”.
For instructions on viewing virtual network interface information about a selected VM to which
the web console session is connected, see Section 6.2.6, “Viewing and editing virtual network
interface information in the web console”.
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
2. Click Disks.
The Disks pane appears with information about the disks assigned to the VM.
57
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Additional resources
For instructions on viewing information about all of the VMs to which the web console session is
connected, see Section 6.2.1, “Viewing a virtualization overview in the web console” .
For instructions on viewing information about the storage pools to which the web console
session is connected, see Section 6.2.2, “Viewing storage pool information using the web
console”.
For instructions on viewing basic information about a selected VM to which the web console
session is connected, see Section 6.2.3, “Viewing basic virtual machine information in the web
console”.
For instructions on viewing resource usage for a selected VM to which the web console session
is connected, see Section 6.2.4, “Viewing virtual machine resource usage in the web console” .
For instructions on viewing virtual network interface information about a selected VM to which
the web console session is connected, see Section 6.2.6, “Viewing and editing virtual network
interface information in the web console”.
6.2.6. Viewing and editing virtual network interface information in the web console
Using the RHEL 8 web console, you can view and modify the virtual network interfaces on a selected
virtual machine (VM):
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
1. In the Virtual Machines interface, click the row of the VM whose information you want to see.
The row expands to reveal the Overview pane with basic information about the selected VM and
controls for shutting down and deleting the VM.
58
CHAPTER 6. VIEWING INFORMATION ABOUT VIRTUAL MACHINES
Type - The type of network interface for the VM. Types include virtual network, bridge to
LAN, and direct attachment.
NOTE
Source - The source of the network interface. This is dependent on the network type.
3. To edit the virtual network interface settings, Click Edit. The Virtual Network Interface Settings
dialog opens.
NOTE
59
Red Hat Enterprise Linux 8 Configuring and managing virtualization
NOTE
Changes to the virtual network interface settings take effect only after restarting
the VM.
Additional resources
For instructions on viewing information about all of the VMs to which the web console session is
connected, see Section 6.2.1, “Viewing a virtualization overview in the web console” .
For instructions on viewing information about the storage pools to which the web console
session is connected, see Section 6.2.2, “Viewing storage pool information using the web
console”.
For instructions on viewing basic information about a selected VM to which the web console
session is connected, see Section 6.2.3, “Viewing basic virtual machine information in the web
console”.
For instructions on viewing resource usage for a selected VM to which the web console session
is connected, see Section 6.2.4, “Viewing virtual machine resource usage in the web console” .
For instructions on viewing disk information about a selected VM to which the web console
session is connected, see Section 6.2.5, “Viewing virtual machine disk information in the web
console”.
60
CHAPTER 7. SAVING AND RESTORING VIRTUAL MACHINES
This section provides information about saving VMs, as well as about restoring them to the same state
without a full VM boot-up.
This process frees up RAM and CPU resources on the host system in exchange for disk space, which
may improve the host system performance. When the VM is restored, because the guest OS does not
need to be booted, the long boot-up period is avoided as well.
To save a VM, you can use the command-line interface (CLI). For instructions, see Saving virtual
machines using the command line interface.
To restore a VM you can use the CLI or the web console GUI.
Prerequisites
Make sure you have sufficient disk space to save the VM and its configuration. Note that the
space occupied by the VM depends on the amount of RAM allocated to that VM.
Procedure
The next time the VM is started, it will automatically restore the saved state from the above file.
61
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Verification
You can make sure that the VM is in a saved state or shut off using the virsh list utility.
To list the VMs that have managed save enabled, use the following command. The VMs listed as
saved have their managed save enabled.
Note that to list the saved VMs that are in a shut off state, you must use the --all or --inactive
options with the command.
Troubleshooting
If the saved VM file becomes corrupted or unreadable, restoring the VM will initiate a standard
VM boot instead.
Additional resources
For more virsh managedsave arguments, see the virsh man page.
For instructions on restoring a saved VM using the command-line interface, see Section 7.3,
“Starting a virtual machine using the command-line interface”.
For instructions on restoring a saved VM using the web console, see Section 7.4, “Starting
virtual machines using the web console”.
Prerequisites
62
CHAPTER 7. SAVING AND RESTORING VIRTUAL MACHINES
Procedure
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.
[email protected]'s password:
Last login: Mon Feb 18 07:28:55 2019
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.
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
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
63
Red Hat Enterprise Linux 8 Configuring and managing virtualization
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”.
64
CHAPTER 8. CLONING VIRTUAL MACHINES
Cloning creates a new VM that uses its own disk image for storage, but most of the clone’s configuration
and stored data is identical to the source VM. This makes it possible to prepare a number of VMs
optimized for a certain task without the need to optimize each VM individually.
This process is faster than creating a new VM and installing it with a guest operating system, and can be
used to rapidly generate VMs with a specific configuration and content.
If you are planning to create multiple clones of a VM, first create a VM template that does not contain:
unique settings, such as persistent network MAC configuration, which can prevent the clones
from working correctly.
To clone a VM, you can use the RHEL 8 CLI. For details, see Section 8.3, “Cloning a virtual machine using
the command-line interface”.
This creates a VM template, which can be used to easily and safely create VM clones.
Prerequisites
You must know where the disk image for the source VM is located, and be the owner of the
VM’s disk image file.
Note that disk images for VMs created in the system session of libvirt are by default located in
the /var/lib/libvirt/images directory and owned by the root user:
# ls -la /var/lib/libvirt/images
-rw-------. 1 root root 9665380352 Jul 23 14:50 a-really-important-vm.qcow2
65
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Optional: Any important data on the VM’s disk has been backed up. If you want to preserve the
source VM intact, clone it first and edit the clone to create a template.
Procedure
1. Ensure you are logged in as the owner of the VM’s disk image:
# whoami
root
# cp /var/lib/libvirt/images/a-really-important-vm.qcow2 /var/lib/libvirt/images/a-really-
important-vm-original.qcow2
This is used later to verify the VM was successfully turned into a template.
# virt-sysprep -a /var/lib/libvirt/images/a-really-important-vm.qcow2
[ 0.0] Examining the guest ...
[ 7.3] Performing "abrt-data" ...
[ 7.3] Performing "backup-files" ...
[ 9.6] Performing "bash-history" ...
[ 9.6] Performing "blkid-tab" ...
[...]
Verification
To confirm that the process was successful, compare the modified disk image to the original
one. The following example shows a successful creation of a template:
# virt-diff -a /var/lib/libvirt/images/a-really-important-vm-orig.qcow2 -A
/var/lib/libvirt/images/a-really-important-vm.qcow2
- - 0644 1001 /etc/group-
- - 0000 797 /etc/gshadow-
= - 0444 33 /etc/machine-id
[...]
- - 0600 409 /home/username/.bash_history
- d 0700 6 /home/username/.ssh
- - 0600 868 /root/.bash_history
[...]
Additional resources
Using the virt-sysprep command as shown above performs the standard VM template
preparation. For more information, see the OPERATIONS section in the virt-sysprep man
page.
To customize which specific operations you want virt-sysprep to perform, use the --operations
66
CHAPTER 8. CLONING VIRTUAL MACHINES
To customize which specific operations you want virt-sysprep to perform, use the --operations
option, and specify the intended operations as a comma-separated list.
For instructions on cloning a VM template, see Section 8.3, “Cloning a virtual machine using the
command-line interface”.
Prerequisites
Ensure that there is sufficient disk space to store the cloned disk images.
Optional: When creating multiple VM clones, remove unique data and settings from the source
VM to ensure the cloned VMs work properly. For instructions, see Section 8.2, “Creating a
virtual machine template”.
Procedure
1. Use the virt-clone utility with options that are appropriate for your environment and use case.
Sample use cases
The following command clones a local VM named doppelganger and creates the
doppelganger-clone VM. It also creates the doppelganger-clone.qcow2 disk image in the
same location as the disk image of the original VM, and with the same data:
The following command clones a VM named kal-el located on the remote system 10.0.0.1,
and creates a local VM named bizarro, which uses only two of kal-el's multiple disks. Note
that running this command also requires root privileges for 10.0.0.1.
Verification
To verify the VM has been successfully cloned and is working correctly:
1. Confirm the clone has been added to the list of VMs on your host.
67
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Id Name State
---------------------------------------
- doppelganger shut off
- doppelganger-clone shut off
Additional resources
For additional options for cloning VMs, see the virt-clone man page.
68
CHAPTER 9. MANAGING VIRTUAL DEVICES
The following sections provide a general overview of what virtual devices are, and instructions on how
they can be attached, modified, or removed from a VM.
Virtual devices attached to a VM can be configured when creating the VM, and can also be managed on
an existing VM. Generally, virtual devices can be attached or detached from a VM only when the VM is
shut off, but some can be added or removed when the VM is running. This feature is referred to as
device hot plug and hot unplug.
When creating a new VM, libvirt automatically creates and configures a default set of essential virtual
devices, unless specified otherwise by the user. These are based on the host system architecture and
machine type, and usually include:
the CPU
memory
a keyboard
a video card
a sound card
To manage virtual devices after the VM is created, use the command-line interface (CLI). However, to
manage virtual storage devices and NICs, you can also use the RHEL 8 web console.
Performance or flexibility
For some types of devices, RHEL 8 supports multiple implementations, often with a trade-off between
performance and flexibility.
For example, the physical storage used for virtual disks can be represented by files in various formats,
such as qcow2 or raw, and presented to the VM using a variety of controllers:
an emulated controller
virtio-scsi
virtio-blk
An emulated controller is slower than a virtio controller, because virtio devices are designed specifically
69
Red Hat Enterprise Linux 8 Configuring and managing virtualization
An emulated controller is slower than a virtio controller, because virtio devices are designed specifically
for virtualization purposes. On the other hand, emulated controllers make it possible to run operating
systems that have no drivers for virtio devices. Similarly, virtio-scsi offers a more complete support for
SCSI commands, and makes it possible to attach a larger number of disks to the VM. Finally, virtio-blk
provides better performance than both virtio-scsi and emulated controllers, but a more limited range of
use-cases. For example, attaching a physical disk as a LUN device to a VM is not possible when using
virtio-blk.
For more information on types of virtual devices, see Section 9.5, “Types of virtual devices”.
Additional resources
For instructions how to attach, remove, or modify VM storage devices using the CLI, see
Chapter 10, Managing storage for virtual machines .
For instructions how to manage VM disks using the web console, see Section 10.3.7, “Managing
virtual machine disks using the web console”.
For instructions how to manage VM NICs using the web console, see Section 15.2, “Using the
web console for managing virtual machine network interfaces”.
For instructions how to create and manage NVIDIA vGPUs, see Chapter 11, Managing NVIDIA
vGPU devices.
Prerequisites
Obtain the required options for the device you intend to attach to a VM. To see the available
options for a specific device, use the virt-xml --device=? command. For example:
# virt-xml --network=?
--network options:
[...]
address.unit
boot_order
clearxml
driver_name
[...]
Procedure
1. To attach a device to a VM, use the virt-xml --add-device command, including the definition of
the device and the required options:
For example, the following command creates a 20GB newdisk qcow2 disk image in the
/var/lib/libvirt/images/ directory, and attaches it as a virtual disk to the running testguest
VM on the next start-up of the VM:
70
CHAPTER 9. MANAGING VIRTUAL DEVICES
The following attaches a USB flash drive, attached as device 004 on bus 002 on the host,
to the testguest2 VM while the VM is running:
The bus-device combination for defining the USB can be obtained using the lsusb
command.
Verification
To verify the device has been added, do any of the following:
Use the virsh dumpxml command and see if the device’s XML definition has been added to the
<devices> section in the VM’s XML configuration.
For example, the following output shows the configuration of the testguest VM and confirms
that the 002.004 USB flash disk device has been added.
Run the VM and test if the device is present and works properly.
Additional resources
For further information on using the virt-xml command, use man virt-xml.
Prerequisites
Obtain the required options for the device you intend to attach to a VM. To see the available
options for a specific device, use the virt-xml --device=? command. For example:
# virt-xml --network=?
--network options:
71
Red Hat Enterprise Linux 8 Configuring and managing virtualization
[...]
address.unit
boot_order
clearxml
driver_name
[...]
Optional: Back up the XML configuration of your VM by using virsh dumpxml vm-name and
sending the output to a file. For example, the following backs up the configuration of your
Motoko VM as the motoko.xml file:
Procedure
1. Use the virt-xml --edit command, including the definition of the device and the required
options:
For example, the following clears the <cpu> configuration of the shut-off testguest VM and sets
it to host-model:
Verification
To verify the device has been modified, do any of the following:
Run the VM and test if the device is present and reflects the modifications.
Use the virsh dumpxml command and see if the device’s XML definition has been modified in
the VM’s XML configuration.
For example, the following output shows the configuration of the testguest VM and confirms
that the CPU mode has been configured as host-model.
Troubleshooting
If modifying a device causes your VM to become unbootable, use the virsh define utility to
restore the XML configuration by reloading the XML configuration file you backed up previously.
NOTE
72
CHAPTER 9. MANAGING VIRTUAL DEVICES
NOTE
For small changes to the XML configuration of your VM, you can use the virsh edit
command - for example virsh edit testguest. However, do not use this method for more
extensive changes, as it is more likely to break the configuration in ways that could
prevent the VM from booting.
Additional resources
Prerequisites
Optional: Back up the XML configuration of your VM by using virsh dumpxml vm-name and
sending the output to a file. For example, the following backs up the configuration of your
Motoko VM as the motoko.xml file:
Procedure
1. Use the virt-xml --remove-device command, including a definition of the device. For example:
The following removes the storage device marked as vdb from the running testguest VM
after it shuts down:
The following immediately removes a USB flash drive device from the running testguest2
VM:
Troubleshooting
If removing a device causes your VM to become unbootable, use the virsh define utility to
restore the XML configuration by reloading the XML configuration file you backed up previously.
73
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Additional resources
Emulated devices
Emulated devices are software implementations of widely used physical devices. Drivers designed for
physical devices are also compatible with emulated devices. Therefore, emulated devices can be
used very flexibly.
However, since they need to faithfully emulate a particular type of hardware, emulated devices may
suffer a significant performance loss compared with the corresponding physical devices or more
optimized virtual devices.
Virtual CPUs (vCPUs), with a large choice of CPU models available. The performance impact
of emulation depends significantly on the differences between the host CPU and the
emulated vCPU.
Paravirtualized devices
Paravirtualization provides a fast and efficient method for exposing virtual devices to VMs.
Paravirtualized devices expose interfaces that are designed specifically for use in VMs, and thus
significantly increase device performance. RHEL 8 provides paravirtualized devices to VMs using the
virtio API as a layer between the hypervisor and the VM. The drawback of this approach is that it
requires a specific device driver in the guest operating system.
It is recommended to use paravirtualized devices instead of emulated devices for VM whenever
possible, notably if they are running I/O intensive applications. Paravirtualized devices decrease I/O
latency and increase I/O throughput, in some cases bringing them very close to bare-metal
performance. Other paravirtualized devices also add functionality to VMs that is not otherwise
available.
74
CHAPTER 9. MANAGING VIRTUAL DEVICES
The balloon device (virtio-balloon), used to share information about guest memory usage
with the hypervisor.
Note, however, that the balloon device also requires the balloon service to be installed.
Nevertheless, some devices can be shared across multiple VMs. For example, a single physical device
can in certain cases provide multiple mediated devices, which can then be assigned to distinct VMs.
Virtual Function I/O (VFIO) device assignment - safely exposes devices to applications or
VMs using hardware-enforced DMA and interrupt isolation.
USB, PCI, and SCSI passthrough - expose common industry standard buses directly to VMs
in order to make their specific features available to guest software.
N_Port ID virtualization (NPIV) - a Fibre Channel technology to share a single physical host
bus adapter (HBA) with multiple virtual ports.
GPUs and vGPUs - accelerators for specific kinds of graphic or compute workloads. Some
GPUs can be attached directly to a VM, while certain types also offer the ability to create
virtual GPUs (vGPUs) that share the underlying physical hardware.
Single-root I/O virtualization (SR-IOV) is a specification that enables a single PCI Express (PCIe) device
75
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Single-root I/O virtualization (SR-IOV) is a specification that enables a single PCI Express (PCIe) device
to present multiple separate PCI devices, called virtual functions (VFs), to the host system. Each of
these devices:
is able to provide the same or similar service as the original PCIe device.
For example, a single SR-IOV capable network device can present VFs to multiple VMs. While all of the
VFs use the same physical card, the same network connection, and the same network cable, each of the
VMs directly controls its own hardware network device, and uses no extra resources from the host.
Physical functions (PFs) - A PCIe function that provides the functionality of its device (for
example networking) to the host, but can also create and manage a set of VFs. Each SR-IOV
capable device has one or more PFs.
Virtual functions (VFs) - Lightweight PCIe functions that behave as independent devices. Each
VF is derived from a PF. The maximum number of VFs a device can have depends on the device
hardware. Each VF can be assigned only to a single VM at a time, but a VM can have multiple
VFs assigned to it.
VMs recognize VFs as virtual devices. For example, a VF created by an SR-IOV network device appears
as a network card to a VM to which it is assigned, in the same way as a physical network card appears to
the host system.
Benefits
The primary advantages of using SR-IOV VFs rather than emulated devices are:
Improved performance
For example, a VF attached to a VM as a vNIC performs at almost the same level as a physical NIC, and
much better than paravirtualized or emulated NICs. In particular, when multiple VFs are used
simultaneously on a single host, the performance benefits can be significant.
Disadvantages
To modify the configuration of a PF, you must first change the number of VFs exposed by the
PF to zero. Therefore, you also need to remove the devices provided by these VFs from the VM
to which they are assigned.
In addition, VFIO-assigned devices require pinning of VM memory, which increases the memory
consumption of the VM and prevents the use of memory ballooning on the VM.
Additional resources
For a list of device types that support SR-IOV, see Section 9.6.3, “Supported devices for SR-
77
Red Hat Enterprise Linux 8 Configuring and managing virtualization
For a list of device types that support SR-IOV, see Section 9.6.3, “Supported devices for SR-
IOV assignment”.
Prerequisites
The CPU and the firmware of your host must support the I/O Memory Management Unit
(IOMMU).
If using an Intel CPU, it must support the Intel Virtualization Technology for Directed I/O
(VT-d).
Verify with the system vendor that the system uses Access Control Service (ACS) to provide
direct memory access (DMA) isolation for PCIe topology.
For additional information, see Hardware Considerations for Implementing SR-IOV .
The physical network device must support SR-IOV. To verify if any network devices on your
system support SR-IOV, use the lspci -v command and look for Single Root I/O Virtualization
(SR-IOV) in the output.
# lspci -v
[...]
02:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
Subsystem: Intel Corporation Gigabit ET Dual Port Server Adapter
Flags: bus master, fast devsel, latency 0, IRQ 16, NUMA node 0
Memory at fcba0000 (32-bit, non-prefetchable) [size=128K]
[...]
Capabilities: [150] Alternative Routing-ID Interpretation (ARI)
Capabilities: [160] Single Root I/O Virtualization (SR-IOV)
Kernel driver in use: igb
Kernel modules: igb
[...]
The host network interface you want to use for creating VFs must be running. For example, to
activate the eth1 interface and verify it is running:
For SR-IOV device assignment to work, the IOMMU feature must be enabled in the host BIOS
and kernel. To do so:
A. Edit the /etc/default/grub file and add the intel_iommu=on and iommu=pt
parameters at the end of the GRUB_CMDLINE_LINUX line:
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/rhel_dell-
per730-27-swap rd.lvm.lv=rhel_dell-per730-27/root rd.lvm.lv=rhel_dell-per730-
27/swap console=ttyS0,115200n81 intel_iommu=on iommu=pt"
# grub2-mkconfig -o /boot/grub2/grub.cfg
A. Edit the /etc/default/grub file and add the iommu=pt parameter at the end of the
GRUB_CMDLINE_LINUX line:
GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/rhel_dell-
per730-27-swap rd.lvm.lv=rhel_dell-per730-27/root rd.lvm.lv=rhel_dell-per730-
27/swap console=ttyS0,115200n81 iommu=pt"
# grub2-mkconfig -o /boot/grub2/grub.cfg
Procedure
1. Optional: Confirm the maximum number of VFs your network device can use. To do so, use the
following command and replace eth1 with your SR-IOV compatible network device.
79
Red Hat Enterprise Linux 8 Configuring and managing virtualization
# cat /sys/class/net/eth1/device/sriov_totalvfs
7
VF-number with the number of VFs you want to create on the PF.
network-interface with the name of the network interface for which the VFs will be created.
The following example creates 2 VFs from the eth1 network interface:
4. Make the created VFs persistent by creating a udev rule for the network interface you used to
create the VFs. For example, for the eth1 interface, create the /etc/udev/rules.d/eth1.rules file,
and add the following line:
This ensures that the two VFs that use the ixgbe driver will automatically be available for the
eth1 interface when the host starts.
WARNING
Currently, this command does not work correctly when attempting to make
VFs persistent on Broadcom NetXtreme II BCM57810 adapters. In addition,
attaching VFs based on these adapters to Windows VMs is currently not
reliable.
5. Use the virsh nodedev-list command to verify that libvirt recognizes the added VF devices.
For example, the following shows that the 01:00.0 and 07:00.0 PFs from the previous example
have been successfully converted into VFs:
80
CHAPTER 9. MANAGING VIRTUAL DEVICES
pci_0000_01_00_0
pci_0000_01_00_1
pci_0000_07_10_0
pci_0000_07_10_1
[...]
6. Obtain the bus, slot, and function values of a PF and one of its corresponding VFs. For
example, for pci_0000_01_00_0 and pci_0000_01_00_1:
7. Create a temporary XML file and add a configuration into using the bus, slot, and function
values you obtained in the previous step. For example:
8. Add the VF to a VM using the temporary XML file. For example, the following attaches a VF
saved in the /tmp/holdmyfunction.xml to a running testguest1 VM and ensures it is available
after the VM restarts:
If this is successful, the guest operating system detects a new network interface card.
81
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Networking devices
82
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
This documentation provides information on how to manage virtual machine storage using the virsh
command.
A storage pool is a quantity of storage managed by the host and set aside for use by VMs. Storage
volumes can be created from space in the storage pools. Each storage volume can be assigned to a VM
as a block device, such as a disk, on a guest bus.
Storage pools and volumes are managed using libvirt. With the libvirt remote protocol, you can manage
all aspects of VM storage. These operations can be performed on a remote host. As a result, a
management application that uses libvirt, such as the RHEL web console, can be used to perform all the
required tasks for configuring the storage for a VM.
The libvirt API can be used to query the list of volumes in the storage pool or to get information
regarding the capacity, allocation, and available storage in the storage pool. A storage volume in the
storage pool may be queried to get information such as allocation and capacity, which may differ for
sparse volumes.
For storage pools that support it, the libvirt API can be used to create, clone, resize, and delete storage
volumes. The APIs can also be used to upload data to storage volumes, download data from storage
volumes, or wipe data from storage volumes.
Once a storage pool is started, a storage volume can be assigned to a VM using the storage pool name
and storage volume name instead of the host path to the volume in the XML configuration files of the
VM.
The virsh pool-define command is used to create a persistent storage pool, and the virsh pool-create
command is used to create a transient storage pool.
83
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Local storage pools are useful for development, testing, and small deployments that do not
require migration or large numbers of VMs.
A storage administrator could define an NFS Storage Pool on the virtualization host to describe the
exported server path and the client target path. This will allow libvirt to perform the mount either
automatically when libvirt is started or as needed while libvirt is running. Files with the NFS Server
exported directory are listed as storage volumes within the NFS storage pool.
When the storage volume is added to the VM, the administrator does not need to add the target path to
the volume. They just needs to add the storage pool and storage volume by name. Therefore, if the
target client path changes, it does not affect the VM.
When the storage pool is started, libvirt mounts the share on the specified directory, just as if the
system administrator logged in and executed mount nfs.example.com:/path/to/share /vmdata. If the
storage pool is configured to autostart, libvirt ensures that the NFS shared disk is mounted on the
directory specified when libvirt is started.
Once the storage pool is started, the files in the NFS shared disk are reported as storage volumes, and
the storage volumes' paths may be queried using the libvirt API. The storage volumes' paths can then
be copied into the section of a VM’s XML definition that describes the source storage for the VM’s
block devices. In the case of NFS, an application that uses the libvirt API can create and delete storage
volumes in the storage pool (files in the NFS share) up to the limit of the size of the pool (the storage
capacity of the share).
Stopping (destroying) a storage pool removes the abstraction of the data, but keeps the data intact.
Not all storage pool types support creating and deleting volumes. Stopping the storage pool (pool-
destroy) undoes the start operation, in this case, unmounting the NFS share. The data on the share is
not modified by the destroy operation, despite what the name of the command suggests. For more
details, see man virsh.
84
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
The following is a list of libvirt storage pool types that are not supported by RHEL:
On the host machine, a storage volume is referred to by its name and an identifier for the storage pool
from which it derives. On the virsh command line, this takes the form --pool storage_pool
volume_name.
For example, to display information about a volume named firstimage in the guest_images pool.
Using virsh, you can add, remove, and modify VM storage, as well as view information about VM storage.
NOTE
In many cases, storage for a VM is created at the same time the VM is created. Therefore,
the following information primarily relates to advanced management of VM storage.
85
Red Hat Enterprise Linux 8 Configuring and managing virtualization
The following provides information about viewing information about storage pools and storage volumes
using the CLI.
Procedure
Additional resources
For information on the available virsh pool-list options, see the relevant man pages.
The following provides information on viewing information about storage pools. You can view a list of all
storage pools in a specified storage pool and details about a specified storage pool.
Procedure
1. Use the virsh vol-list command to list the storage volumes in a specified storage pool.
NOTE
For information on the available virsh vol-list options, see the relevant man
pages.
2. Use the virsh vol-info command to list the storage volumes in a specified storage pool.
NOTE
86
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
NOTE
For information on the available virsh vol-info options, see the relevant man
pages.
10.2.2. Creating and assigning storage for virtual machines using the CLI
The following is a high-level procedure for creating and assigning storage for virtual machines (VMs):
To create persistent storage pools, use the virsh pool-define and virsh pool-define-as
commands.
The virsh pool-define command uses an XML file for the pool options. The virsh pool-
define-as command places the options in the command line.
To create temporary storage pools, use the virsh pool-create and virsh pool-create-as
commands.
The virsh pool-create command uses an XML file for the pool options. The virsh pool-
create-as command places the options in the command line.
NOTE
All examples and procedures in this documentation are for creating persistent storage
pools using the virsh pool-define command. For more information on the virsh pool-
create, virsh pool-define-as, and virsh pool-create-as commands, see the relevant man
pages.
NOTE
All examples and procedures in this documentation are for creating storage using
the virsh vol‑create command. For more information on the virsh vol-create-as
command, see the relevant man pages.
The following sections provide information on creating and assigning storage using the CLI:
Directory-based storage
Filesystem-based storage
GlusterFS-based storage
iSCSI-based storage
LVM-based storage
NFS-based storage
87
Red Hat Enterprise Linux 8 Configuring and managing virtualization
vHBA-based storage
10.2.2.1. Creating and assigning directory-based storage for virtual machines using the CLI
The following provides information about creating directory-based storage pools and storage volumes,
and assigning volumes to virtual machines.
Procedure
NOTE
You can delete the XML file created in step 1 after running the virsh pool-define
command.
# ls -la /guest_images
total 8
drwx------. 2 root root 4096 May 31 19:38 .
dr-xr-xr-x. 25 root root 4096 May 31 19:38 ..
88
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
NOTE
The virsh pool-start command is only necessary for persistent storage pools.
Transient storage pools are automatically started when they are created.
# ls -la /guest_images
total 24
drwxr-xr-x. 3 root root 4096 May 31 19:47 .
dr-xr-xr-x. 25 root root 4096 May 31 19:38 ..
drwx------. 2 root root 16384 May 31 14:18 lost+found
89
Red Hat Enterprise Linux 8 Configuring and managing virtualization
The following provides information about the required parameters for a directory-based storage pool
and an example.
Parameters
The following table provides a list of required parameters for the XML file for a directory-based storage
pool.
Description XML
The path specifying the target. This will be the path <target>
used for the storage pool. <path>target_path</path>
</target>
Example
The following is an example of an XML file for a storage pool based on the /guest_images directory:
<pool type='dir'>
<name>dirpool</name>
<target>
<path>/guest_images</path>
</target>
</pool>
10.2.2.2. Creating and assigning disk-based storage for virtual machines using the CLI
The following provides information about creating disk-based storage pools and storage volumes and
assigning volumes to virtual machines.
Recommendations
Be aware of the following before creating a disk-based storage pool:
Depending on the version of libvirt being used, dedicating a disk to a storage pool may reformat
and erase all data currently stored on the disk device. It is strongly recommended that you back
up the data on the storage device before creating a storage pool.
VMs should not be given write access to whole disks or block devices (for example, /dev/sdb).
Use partitions (for example, /dev/sdb1) or LVM volumes.
If you pass an entire block device to a VM, the VM will likely partition it or create its own LVM
90
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
If you pass an entire block device to a VM, the VM will likely partition it or create its own LVM
groups on it. This can cause the host machine to detect these partitions or LVM groups and
cause errors.
Procedure
1. Relabel the disk with a GUID Partition Table (GPT) disk label. GPT disk labels allow for creating
up to 128 partitions on each device.
# parted /dev/sdb
GNU Parted 2.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
New disk label type? gpt
(parted) quit
Information: You may need to update /etc/fstab.
#
NOTE
You can delete the XML file created in step 1 after running the virsh pool-define
command.
# ls -la /guest_images
total 8
drwx------. 2 root root 4096 May 31 19:38 .
dr-xr-xr-x. 25 root root 4096 May 31 19:38 ..
NOTE
91
Red Hat Enterprise Linux 8 Configuring and managing virtualization
NOTE
Building the target path is only necessary for disk-based, file system-based, and
logical storage pools. If libvirt detects that the source storage device’s data
format differs from the selected storage pool type, the build fails, unless the
overwrite option is specified.
NOTE
The virsh pool-start command is only necessary for persistent storage pools.
Transient storage pools are automatically started when they are created.
92
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
Name: guest_images_fs
UUID: c7466869-e82a-a66c-2187-dc9d6f0877d0
State: running
Persistent: yes
Autostart: yes
Capacity: 458.39 GB
Allocation: 197.91 MB
Available: 458.20 GB
# ls -la /guest_images
total 24
drwxr-xr-x. 3 root root 4096 May 31 19:47 .
dr-xr-xr-x. 25 root root 4096 May 31 19:38 ..
drwx------. 2 root root 16384 May 31 14:18 lost+found
The following provides information about the required parameters for a directory-based storage pool
and an example.
Parameters
The following table provides a list of required parameters for the XML file for a disk-based storage pool.
Description XML
The path specifying the target device. This will be the <target>
path used for the storage pool. <path>target_path</path>
</target>
Example
The following is an example of an XML file for a disk-based storage pool:
<pool type='disk'>
<name>phy_disk</name>
<source>
<device path='/dev/sdb'/>
<format type='gpt'/>
</source>
<target>
93
Red Hat Enterprise Linux 8 Configuring and managing virtualization
<path>/dev</path>
</target>
</pool>
10.2.2.3. Creating and assigning filesystem-based storage for virtual machines using the
CLI
The following provides information about creating directory-based storage pools and storage volumes,
and assigning volumes to virtual machines.
Recommendations
Do not use this procedure to assign an entire disk as a storage pool (for example, /dev/sdb). VMs should
not be given write access to whole disks or block devices. This method should only be used to assign
partitions (for example, /dev/sdb1) to storage pools.
Procedure
NOTE
You can delete the XML file created in step 1 after running the virsh pool-define
command.
# ls -la /guest_images
total 8
drwx------. 2 root root 4096 May 31 19:38 .
dr-xr-xr-x. 25 root root 4096 May 31 19:38 ..
94
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
Use the virsh pool-list command to verify that the pool was created.
NOTE
The virsh pool-start command is only necessary for persistent storage pools.
Transient storage pools are automatically started when they are created.
95
Red Hat Enterprise Linux 8 Configuring and managing virtualization
# ls -la /guest_images
total 24
drwxr-xr-x. 3 root root 4096 May 31 19:47 .
dr-xr-xr-x. 25 root root 4096 May 31 19:38 ..
drwx------. 2 root root 16384 May 31 14:18 lost+found
The following provides information about the required parameters for a directory-based storage pool
and an example.
Parameters
The following table provides a list of required parameters for the XML file for a filesystem-based
storage pool.
Description XML
The file system type, for example ext4. <format type=fs_type />
</source>
The path specifying the target. This will be the path <target>
used for the storage pool. <path>path-to-pool</path>
</target>
Example
The following is an example of an XML file for a storage pool based on the /dev/sdc1 partition:
<pool type='fs'>
<name>guest_images_fs</name>
<source>
<device path='/dev/sdc1'/>
<format type='auto'/>
</source>
<target>
<path>/guest_images</path>
</target>
</pool>
96
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
10.2.2.4. Creating and assigning GlusterFS storage for virtual machines using the CLI
The following provides information about creating directory-based storage pools and storage volumes,
and assigning volumes to virtual machines.
GlusterFS is a user space file system that uses File System in Userspace (FUSE). The following provides
instructions for creating GlusterFS-based storage pools.
Prerequisites
Before a GlusterFS-based storage pool can be created on a host, a Gluster server must be
prepared.
1. Obtain the IP address of the Gluster server by listing its status with the following command:
# setsebool virt_use_fusefs on
# getsebool virt_use_fusefs
virt_use_fusefs --> on
After ensuring that the required packages are installed and enabled, continue creating the storage pool.
Procedure
You can delete the XML file created in step 1 after running the virsh pool-define command.
97
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Use the virsh pool-build command to create a storage pool target path for a pre-formatted file
system storage pool, initialize the storage source device, and define the format of the data.
# ls -la /guest_images
total 8
drwx------. 2 root root 4096 May 31 19:38 .
dr-xr-xr-x. 25 root root 4096 May 31 19:38 ..
NOTE
Building the target path is only necessary for disk-based, file system-based, and
logical storage pools. If libvirt detects that the source storage device’s data
format differs from the selected storage pool type, the build fails, unless the
overwrite option is specified.
NOTE
The virsh pool-start command is only necessary for persistent storage pools.
Transient storage pools are automatically started when they are created.
98
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
# ls -la /guest_images
total 24
drwxr-xr-x. 3 root root 4096 May 31 19:47 .
dr-xr-xr-x. 25 root root 4096 May 31 19:38 ..
drwx------. 2 root root 16384 May 31 14:18 lost+found
The following provides information about the required parameters for a GlusterFS-based storage pool
and an example.
Parameters
The following table provides a list of required parameters for the XML file for a GlusterFS-based
storage pool.
Description XML
99
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Description XML
The path on the Gluster server used for the storage <dir path=gluster-path />
pool. </source>
Example
The following is an example of an XML file for a storage pool based on the Gluster file system at
111.222.111.222:
<pool type='gluster'>
<name>Gluster_pool</name>
<source>
<host name='111.222.111.222'/>
<dir path='/'/>
<name>gluster-vol1</name>
</source>
</pool>
10.2.2.5. Creating and assigning iSCSI-based storage for virtual machines using the CLI
The following provides information about creating iSCSI-based storage pools and storage volumes,
securing iSCSI-based storage pools with libvirt secrets, and assigning volumes to virtual machines.
Recommendations
Internet Small Computer System Interface (iSCSI) is a network protocol for sharing storage devices.
iSCSI connects initiators (storage clients) to targets (storage servers) using SCSI instructions over the
IP layer.
Using iSCSI-based devices to store virtual machines allows for more flexible storage options, such as
using iSCSI as a block storage device. The iSCSI devices use a Linux-IO (LIO) target. This is a multi-
protocol SCSI target for Linux. In addition to iSCSI, LIO also supports Fibre Channel and Fibre Channel
over Ethernet (FCoE).
If you need to prevent access to an iSCSI storage pool, you can secure it using a libvirt secret.
Prerequisites
Before you can create an iSCSI-based storage pool, you must create iSCSI targets. You can
create iSCSI targets are created using the targetcli package, which provides a command set for
creating software-backed iSCSI targets.
For more information and instructions on creating iSCSI targets, see the Red Hat Enterprise
Linux Storage Administration Guide.
Procedure
100
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
You can delete the XML file created in step 1 after running the virsh pool-define command.
NOTE
The virsh pool-start command is only necessary for persistent storage pools.
Transient storage pools are automatically started when they are created.
Verify that the storage pool was created correctly, the sizes reported are as expected, and the
101
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Verify that the storage pool was created correctly, the sizes reported are as expected, and the
state is reported as running. Verify there is a lost+found directory in the target path on the file
system, indicating that the device is mounted.
# ls -la /guest_images
total 24
drwxr-xr-x. 3 root root 4096 May 31 19:47 .
dr-xr-xr-x. 25 root root 4096 May 31 19:38 ..
drwx------. 2 root root 16384 May 31 14:18 lost+found
The following provides information about the required parameters for an iSCSI-based storage pool and
an example.
Parameters
The following table provides a list of required parameters for the XML file for an iSCSI-based storage
pool.
Description XML
The path specifying the target. This will be the path <target>
used for the storage pool. <path>/dev/disk/by-path</path>
</target>
102
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
Description XML
NOTE
The IQN of the iSCSI initiator can be determined using the virsh find-storage-pool-
sources-as iscsi command.
Example
The following is an example of an XML file for a storage pool based on the specified iSCSI device:
<pool type='iscsi'>
<name>iSCSI_pool</name>
<source>
<host name='server1.example.com'/>
<device path='iqn.2010-05.com.example.server1:iscsirhel7guest'/>
</source>
<target>
<path>/dev/disk/by-path</path>
</target>
</pool>
User name and password parameters can be configured with virsh to secure an iSCSI storage pool. This
can be configured before or after the pool is defined, but the pool must be started for the
authentication settings to take effect.
The following provides instructions for securing iSCSI-based storage pools with libvirt secrets.
NOTE
This procedure is required if a user_ID and password were defined when creating the
iSCSI target.
Procedure
1. Create a libvirt secret file with a challenge-handshake authentication protocol (CHAP) user
name. For example:
103
Red Hat Enterprise Linux 8 Configuring and managing virtualization
# virsh secret-list
UUID Usage
-------------------------------------------------------------------
2d7891af-20be-4e5e-af83-190e8a922360 iscsi iscsirhel7secret
4. Assign a secret to the UUID in the output of the previous step using the virsh secret-set-value
command. This ensures that the CHAP username and password are in a libvirt-controlled secret
list. For example:
5. Add an authentication entry in the storage pool’s XML file using the virsh edit command, and
add an <auth> element, specifying authentication type, username, and secret usage.
For example:
<pool type='iscsi'>
<name>iscsirhel7pool</name>
<source>
<host name='192.168.122.1'/>
<device path='iqn.2010-05.com.example.server1:iscsirhel7guest'/>
<auth type='chap' username='redhat'>
<secret usage='iscsirhel7secret'/>
</auth>
</source>
<target>
<path>/dev/disk/by-path</path>
</target>
</pool>
NOTE
The <auth> sub-element exists in different locations within the virtual machine’s
<pool> and <disk> XML elements. For a <pool>, <auth> is specified within the
<source> element, as this describes where to find the pool sources, since
authentication is a property of some pool sources (iSCSI and RBD). For a <disk>,
which is a sub-element of a domain, the authentication to the iSCSI or RBD disk is
a property of the disk. In addition, the <auth> sub-element for a disk differs from
that of a storage pool.
<auth username='redhat'>
<secret type='iscsi' usage='iscsirhel7secret'/>
</auth>
6. To activate the changes, the storage pool must be activated. If the pool has already been
started, stop and restart the storage pool:
# virsh pool-destroy iscsirhel7pool
104
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
10.2.2.6. Creating and assigning LVM-based storage for virtual machines using the CLI
The following provides information about creating LVM-based storage pools and storage volumes and
assigning volumes to virtual machines.
Recommendations
Be aware of the following before creating an LVM-based storage pool:
libvirt supports thin logical volumes, but does not provide the features of thin storage pools.
LVM-based storage pools are volume groups. You can create volume groups using Logical
Volume Manager commands or virsh commands. To manage volume groups using the virsh
interface, use the virsh commands to create volume groups.
For more information about volume groups, refer to the Red Hat Enterprise Linux Logical
Volume Manager Administration Guide.
LVM-based storage pools require a full disk partition. If activating a new partition or device with
these procedures, the partition will be formatted and all data will be erased. If using the host’s
existing Volume Group (VG) nothing will be erased. It is recommended to back up the storage
device before starting.
Procedure
NOTE
You can delete the XML file created in step 1 after running the virsh pool-define
command.
105
Red Hat Enterprise Linux 8 Configuring and managing virtualization
-----------------------------------------
default active yes
guest_images_fs inactive no
NOTE
The virsh pool-start command is only necessary for persistent storage pools.
Transient storage pools are automatically started when they are created.
# ls -la /guest_images
total 24
106
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
The following provides information about the required parameters for an LVM-based storage pool and
an example.
Parameters
The following table provides a list of required parameters for the XML file for a LVM-based storage
pool.
Description XML
NOTE
If the logical volume group is made of multiple disk partitions, there may be multiple
source devices listed. For example:
<source>
<device path='/dev/sda1'/>
<device path='/dev/sdb3'/>
<device path='/dev/sdc2'/>
...
</source>
Example
The following is an example of an XML file for a storage pool based on the specified LVM:
<pool type='logical'>
<name>guest_images_lvm</name>
107
Red Hat Enterprise Linux 8 Configuring and managing virtualization
<source>
<device path='/dev/sdc'/>
<name>libvirt_lvm</name>
<format type='lvm2'/>
</source>
<target>
<path>/dev/libvirt_lvm</path>
</target>
</pool>
10.2.2.7. Creating and assigning network-based storage for virtual machines using the CLI
The following provides information about creating network-based storage pools and storage volumes
and assigning volumes to virtual machines.
Prerequisites
To create a Network File System (NFS)-based storage pool, an NFS Server should already be
configured to be used by the host machine. For more information about NFS, refer to the Red
Hat Enterprise Linux Storage Administration Guide.
Ensure that the required utilities for the file system being used are installed on the host. For
example, cifs-utils for Common Internet File Systems (CIFS) or glusterfs.fuse for GlusterFS.
Procedure
NOTE
You can delete the XML file created in step 1 after running the virsh pool-define
command.
108
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
# ls -la /guest_images
total 8
drwx------. 2 root root 4096 May 31 19:38 .
dr-xr-xr-x. 25 root root 4096 May 31 19:38 ..
NOTE
The virsh pool-start command is only necessary for persistent storage pools.
Transient storage pools are automatically started when they are created.
109
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Name: guest_images_fs
UUID: c7466869-e82a-a66c-2187-dc9d6f0877d0
State: running
Persistent: yes
Autostart: yes
Capacity: 458.39 GB
Allocation: 197.91 MB
Available: 458.20 GB
# ls -la /guest_images
total 24
drwxr-xr-x. 3 root root 4096 May 31 19:47 .
dr-xr-xr-x. 25 root root 4096 May 31 19:38 ..
drwx------. 2 root root 16384 May 31 14:18 lost+found
The following provides information about the required parameters for an NFS-based storage pool and
an example.
Parameters
The following table provides a list of required parameters for the XML file for an NFS-based storage
pool.
Description XML
The path specifying the target. This will be the path <target>
used for the storage pool. <path>target_path</path>
</target>
110
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
Example
The following is an example of an XML file for a storage pool based on the /home/net_mount directory
of the file_server NFS server:
<pool type='netfs'>
<name>nfspool</name>
<source>
<host name='file_server'/>
<format type='nfs'/>
<dir path='/home/net_mount'/>
</source>
<target>
<path>/var/lib/libvirt/images/nfspool</path>
</target>
</pool>
10.2.2.8. Creating and assigning vHBA-based storage for virtual machines using the CLI
The following provides information about creating vHBA-based storage pools and storage volumes and
assigning volumes to virtual machines (VMs).
10.2.2.8.1. Recommendations
N_Port ID Virtualization (NPIV) is a software technology that allows sharing of a single physical Fibre
Channel host bus adapter (HBA). This allows multiple VMs to see the same storage from multiple
physical hosts, and thus allows for easier migration paths for the storage. As a result, there is no need for
the migration to create or copy storage, as long as the correct storage path is specified.
In virtualization, the virtual host bus adapter , or vHBA, controls the Logical Unit Numbers (LUNs) for
VMs. For a host to share one Fibre Channel device path between multiple VMs, you must create a vHBA
for each VM. A single vHBA cannot be used by multiple VMs.
Each vHBA for NPIV is identified by its parent HBA and its own World Wide Node Name (WWNN) and
World Wide Port Name (WWPN). The path to the storage is determined by the WWNN and WWPN
values. The parent HBA can be defined as scsi_host# or as a WWNN/WWPN pair.
NOTE
If a parent HBA is defined as scsi_host# and hardware is added to the host machine, the
scsi_host# assignment may change. Therefore, it is recommended that you define a
parent HBA using a WWNN/WWPN pair.
It is recommended that you define a libvirt storage pool based on the vHBA, because this preserves the
vHBA configuration.
The libvirt code can easily find the LUN’s path via virsh command output.
You can migrate a VM requires only defining and starting a storage pool with the same vHBA
name on the target machine. To do this, the vHBA LUN, libvirt storage pool and volume name
must be specified in the VM’s XML configuration.
NOTE
111
Red Hat Enterprise Linux 8 Configuring and managing virtualization
NOTE
Before creating a vHBA, it is recommended that you configure storage array (SAN)-side
zoning in the host LUN to provide isolation between VMs and prevent the possibility of
data corruption.
To create a persistent vHBA configuration, first create a libvirt 'scsi' storage pool XML file. For
information on the XML file, see Creating vHBAs. When creating a single vHBA that uses a storage pool
on the same physical HBA, it is recommended to use a stable location for the <path> value, such as one
of the /dev/disk/by-{path|id|uuid|label} locations on your system.
When creating multiple vHBAs that use storage pools on the same physical HBA, the value of the
<path> field must be only /dev/, otherwise storage pool volumes are visible only to one of the vHBAs,
and devices from the host cannot be exposed to multiple VMs with the NPIV configuration.
For more information on <path> and the elements in <target>, see upstream libvirt documentation .
Prerequisites
Before creating a vHBA-based storage pools with SCSI devices, create a vHBA.
The following provides instructions on creating a virtual host bus adapter (vHBA).
Procedure
1. Locate the HBAs on your host system, using the virsh nodedev-list --cap vports command.
The following example shows a host that has two HBAs that support vHBA:
2. View the HBA’s details, using the virsh nodedev-dumpxml HBA_device command.
The output from the command lists the <name>, <wwnn>, and <wwpn> fields, which are used
to create a vHBA. <max_vports> shows the maximum number of supported vHBAs. For
example:
<device>
<name>scsi_host3</name>
<path>/sys/devices/pci0000:00/0000:00:04.0/0000:10:00.0/host3</path>
<parent>pci_0000_10_00_0</parent>
<capability type='scsi_host'>
<host>3</host>
<unique_id>0</unique_id>
<capability type='fc_host'>
<wwnn>20000000c9848140</wwnn>
<wwpn>10000000c9848140</wwpn>
<fabric_wwn>2002000573de9a81</fabric_wwn>
</capability>
<capability type='vport_ops'>
112
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
<max_vports>127</max_vports>
<vports>0</vports>
</capability>
</capability>
</device>
In this example, the <max_vports> value shows there are a total 127 virtual ports available for
use in the HBA configuration. The <vports> value shows the number of virtual ports currently
being used. These values update after creating a vHBA.
3. Create an XML file similar to one of the following for the vHBA host. In these examples, the file
is named vhba_host3.xml.
This example uses scsi_host3 to describe the parent vHBA.
<device>
<parent>scsi_host3</parent>
<capability type='scsi_host'>
<capability type='fc_host'>
</capability>
</capability>
</device>
<device>
<name>vhba</name>
<parent wwnn='20000000c9848140' wwpn='10000000c9848140'/>
<capability type='scsi_host'>
<capability type='fc_host'>
</capability>
</capability>
</device>
NOTE
The WWNN and WWPN values must match those in the HBA details seen in the
previous step.
The <parent> field specifies the HBA device to associate with this vHBA device. The details in
the <device> tag are used in the next step to create a new vHBA device for the host. For more
information on the nodedev XML format, see the libvirt upstream pages .
NOTE
The virsh command does not provide a way to define the parent_wwnn,
parent_wwpn, or parent_fabric_wwn attributes.
4. Create a VHBA based on the XML file created in the previous step using the virsh nodev-
create command.
113
Red Hat Enterprise Linux 8 Configuring and managing virtualization
5. Verify the new vHBA’s details (scsi_host5) using the virsh nodedev-dumpxml command:
Prerequisites
Ensure that there are vHBAs. For more information, see Creating vHBAs.
Procedure
You can delete the XML file created in step 1 after running the virsh pool-define command.
114
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
NOTE
The virsh pool-start command is only necessary for persistent storage pools.
Transient storage pools are automatically started when they are created.
# ls -la /guest_images
total 24
drwxr-xr-x. 3 root root 4096 May 31 19:47 .
dr-xr-xr-x. 25 root root 4096 May 31 19:38 ..
drwx------. 2 root root 16384 May 31 14:18 lost+found
115
Red Hat Enterprise Linux 8 Configuring and managing virtualization
The following provides information about the required parameters for a vHBA-based storage pool and
an example.
Parameters
The following table provides a list of required parameters for the XML file for a vHBA-based storage
pool.
Description XML
The target path. This will be the path used for the <target>
storage pool. <path=target_path />
</target>
IMPORTANT
When the <path> field is /dev/, libvirt generates a unique short device path for the
volume device path. For example, /dev/sdc. Otherwise, the physical host path is used. For
example, /dev/disk/by-path/pci-0000:10:00.0-fc-0x5006016044602198-lun-0. The
unique short device path allows the same volume to be listed in multiple virtual machines
(VMs) by multiple storage pools. If the physical host path is used by multiple VMs,
duplicate device type warnings may occur.
NOTE
116
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
NOTE
The parent attribute can be used in the <adapter> field to identify the physical HBA
parent from which the NPIV LUNs by varying paths can be used. This field, scsi_hostN, is
combined with the vports and max_vports attributes to complete the parent
identification. The parent, parent_wwnn, parent_wwpn, or parent_fabric_wwn
attributes provide varying degrees of assurance that after the host reboots the same
HBA is used.
If no parent is specified, libvirt uses the first scsi_hostN adapter that supports
NPIV.
If only the parent is specified, problems can arise if additional SCSI host adapters
are added to the configuration.
If parent_fabric_wwn is used, after the host reboots an HBA on the same fabric
is selected, regardless of the scsi_hostN used.
Examples
The following are examples of XML files for vHBA-based storage pools.
The following is an example of a storage pool that is the only storage pool on the HBA:
<pool type='scsi'>
<name>vhbapool_host3</name>
<source>
<adapter type='fc_host' wwnn='5001a4a93526d0a1' wwpn='5001a4ace3ee047d'/>
</source>
<target>
<path>/dev/disk/by-path</path>
</target>
</pool>
The following is an example of a storage pool that is one of several storage pools that use a single vHBA
and uses the parent attribute to identify the SCSI host device:
<pool type='scsi'>
<name>vhbapool_host3</name>
<source>
<adapter type='fc_host' parent='scsi_host3' wwnn='5001a4a93526d0a1'
wwpn='5001a4ace3ee047d'/>
</source>
<target>
<path>/dev/disk/by-path</path>
</target>
</pool>
The following provides information on creating storage volumes from storage pools and assigning the
117
Red Hat Enterprise Linux 8 Configuring and managing virtualization
The following provides information on creating storage volumes from storage pools and assigning the
storage volumes to virtual machines using the CLI. The procedure is the same for all types of storage
pools.
Prerequisites
10.2.2.9.1. Procedure
capacity - The logical capacity of the storage volume. If the volume is sparse, this value can
differ from the allocation value.
target - The path to the storage volume on the host system, and optionally its permissions
and label.
The following shows an example of a storage volume definition XML file. In this example, the
file is saved to ~/guest_volume.xml.
<volume>
<name>volume1</name>
<allocation>0</allocation>
<capacity>20</capacity>
<target>
<path>/var/lib/virt/images/sparse.img</path>
</target>
</volume>
The following is a list of the storage pool types that do not support the virsh vol-create and
virsh vol-create-as commands and the methods to use with each of them to create storage
volumes:
Use the virsh vol-create command to create and assign the storage volume based on the XML
file. Specify the virtual machine to which the storage volume will be assigned in the virsh vol-
create command.
118
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
NOTE
You can delete the XML file created in step 1 after running the virsh vol-create
command.
For GlusterFS-based, multipath-based, and RBD-based storage pools, describe the storage
volume using the following XML format and add it to the domain XML:
For multipath-based storage pools, describe the storage volume using the following XML
format and add it to the domain XML:
For RBD-based storage pools, describe the storage volume using the following XML format and
add it to the domain XML:
Prerequisites
To avoid negatively affecting other virtual machines that use the storage pool you want to
119
Red Hat Enterprise Linux 8 Configuring and managing virtualization
To avoid negatively affecting other virtual machines that use the storage pool you want to
delete, it is recommended that you stop the storage pool and release any resources being used
by it.
Procedure
1. List the defined storage pools using the virsh pool-list command.
2. Stop the storage pool you want to delete using the virsh pool-destroy command.
3. (Optional) For some types of storage pools, you can optionally remove the directory where the
storage pool resides using the virsh pool-delete command. Note that to remove the directory
where the storage pool resides, it must be empty.
4. Delete the definition of the storage pool using the virsh pool-undefine command.
The following provides information on deleting storage volumes using the CLI.
Prerequisites
To avoid negatively affecting virtual machines that use the storage volume you want to delete, it
is recommended that you release any resources using it.
Procedure
1. List the defined storage volumes in a storage pool using the virsh vol-list command. The
command must specify the name or path of a storage volume.
120
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
2. Delete storage volumes using the virsh vol-delete command. The command must specify the
name or path of the storage volume and the storage pool from which the storage volume is
abstracted.
Manage VM disks .
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
1. Click Storage Pools at the top of the Virtual Machines interface. The Storage Pools window
appears, showing a list of configured storage pools.
121
Red Hat Enterprise Linux 8 Configuring and managing virtualization
2. Click the row of the storage whose information you want to see.
The row expands to reveal the Overview pane with the following information about the selected
storage pool:
3. To view a list of storage volumes created from the storage pool, click Storage Volumes.
The Storage Volumes pane appears, showing a list of configured storage volumes with their
sizes and the amount of space used.
122
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
Additional resources
For instructions on viewing information about all of the VMs to which the web console session is
connected, see Section 6.2.1, “Viewing a virtualization overview in the web console” .
For instructions on viewing basic information about a selected VM to which the web console
session is connected, see Section 6.2.3, “Viewing basic virtual machine information in the web
console”.
For instructions on viewing resource usage for a selected VM to which the web console session
is connected, see Section 6.2.4, “Viewing virtual machine resource usage in the web console” .
For instructions on viewing disk information about a selected VM to which the web console
session is connected, see Section 6.2.5, “Viewing virtual machine disk information in the web
console”.
For instructions on viewing virtual network interface information about a selected VM to which
the web console session is connected, see Section 6.2.6, “Viewing and editing virtual network
interface information in the web console”.
To create storage pools using the RHEL web console, see the following procedure.
Prerequisites
To use the web console to manage virtual machines (VMs), you must install the web console VM
plug-in.
Procedure
1. Click Storage Pools at the top of the Virtual Machines tab. The Storage Pools window appears,
showing a list of configured storage pools.
123
Red Hat Enterprise Linux 8 Configuring and managing virtualization
2. Click Create Storage Pool. The Create Storage Pool dialog appears.
Type - The type of the storage pool. This can be a file-system directory, a network file
system, an iSCSI target, a physical disk drive, or an LVM volume group.
Target Path - The storage pool path on the host’s file system.
Startup - Whether or not the storage pool starts when the host boots.
4. Click Create. The storage pool is created, the Create Storage Pool dialog closes, and the new
storage pool appears in the list of storage pools.
Additional resources
For more information about storage pools, see Understanding storage pools .
For instructions on viewing information about storage pools using the web console, see Viewing
storage pool information using the web console.
124
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
IMPORTANT
Unless explicitly specified, deleting a storage pool does not simultaneously delete the
storage volumes inside that pool.
To delete a storage pool using the RHEL web console, see the following procedure.
NOTE
If you want to temporarily deactivate a storage pool instead of deleting it, see
Deactivating storage pools using the web console
Prerequisites
To use the web console to manage VMs, you must install the web console VM plug-in .
If you want to delete a storage volume along with the pool, you must first detach the disk from
the VM.
Procedure
1. Click Storage Pools at the top of the Virtual Machines tab. The Storage Pools window appears,
showing a list of configured storage pools.
2. In the Storage Pools window, click the storage pool you want to delete.
The row expands to reveal the Overview pane with basic information about the selected storage
pool and controls for deactivating or deleting the VM.
125
Red Hat Enterprise Linux 8 Configuring and managing virtualization
3. Click Delete.
A confirmation dialog appears.
4. Optional: To delete the storage volumes inside the pool, select the check box in the dialog.
5. Click Delete.
The storage pool is deleted. If you had selected the checkbox in the previous step, the
associated storage volumes are deleted as well.
Additional resources
For more information about storage pools, see Understanding storage pools .
For instructions on viewing information about storage pools using the web console, see viewing
storage pool information using the web console.
When you deactivate a storage pool, no new volumes can be created in that pool. However, any virtual
machines (VMs) that have volumes in that pool will continue to run. This is useful for a number of
reasons, for example, you can limit the number of volumes that can be created in a pool to increase
system performance.
To deactivate a storage pool using the RHEL web console, see the following procedure.
Prerequisites
To use the web console to manage virtual machines (VMs), you must install the web console VM
plug-in.
Procedure
1. Click Storage Pools at the top of the Virtual Machines tab. The Storage Pools window appears,
126
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
1. Click Storage Pools at the top of the Virtual Machines tab. The Storage Pools window appears,
showing a list of configured storage pools.
2. In the Storage Pools window, click the storage pool you want to deactivate.
The row expands to reveal the Overview pane with basic information about the selected storage
pool and controls for deactivating and deleting the VM.
3. Click Deactivate.
Additional resources
For more information about storage pools, see Understanding storage pools .
For instructions on viewing information about storage pools using the web console, see Viewing
storage pool information using the web console.
To create a functioning virtual machine (VM) you require a local storage device assigned to the VM that
127
Red Hat Enterprise Linux 8 Configuring and managing virtualization
To create a functioning virtual machine (VM) you require a local storage device assigned to the VM that
can store the VM image and VM-related data. You can create a storage volume in a storage pool and
assign it to a VM as a storage disk.
To create storage volumes using the web console, see the following procedure.
Prerequisites
To use the web console to manage VMs, you must install the web console VM plug-in .
Procedure
1. Click Storage Pools at the top of the Virtual Machines tab. The Storage Pools window appears,
showing a list of configured storage pools.
2. In the Storage Pools window, click the storage pool from which you want to create a storage
volume.
The row expands to reveal the Overview pane with basic information about the selected storage
pool.
3. Click Storage Volumes next to the Overview tab in the expanded row.
The Storage Volume tab appears with basic information about existing storage volumes, if any.
128
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
Format - The format of the storage volume. The supported types are qcow2 and raw.
6. Click Create.
The storage volume is created, the Create Storage Volume dialog closes, and the new storage
volume appears in the list of storage volumes.
Additional resources
For more information about storage volumes, see Understanding storage volumes .
For information about adding disks to VMs using the web console, see Adding new disks to
virtual machines using the web console.
To remove storage volumes using the RHEL web console, see the following procedure.
129
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Prerequisites
To use the web console to manage VMs, you must install the web console VM plug-in .
Procedure
1. Click Storage Pools at the top of the Virtual Machines tab. The Storage Pools window appears,
showing a list of configured storage pools.
2. In the Storage Pools window, click the storage pool from which you want to remove a storage
volume.
The row expands to reveal the Overview pane with basic information about the selected storage
pool.
3. Click Storage Volumes next to the Overview tab in the expanded row.
The Storage Volume tab appears with basic information about existing storage volumes, if any.
130
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
Additional resources
For more information about storage volumes, see Understanding storage volumes .
You can:
The following procedure describes how to view the disk information of a virtual machine (VM) to which
the web console session is connected.
131
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
2. Click Disks.
The Disks pane appears with information about the disks assigned to the VM.
Additional resources
For instructions on viewing information about all of the VMs to which the web console session is
connected, see Section 6.2.1, “Viewing a virtualization overview in the web console” .
For instructions on viewing information about the storage pools to which the web console
session is connected, see Section 6.2.2, “Viewing storage pool information using the web
console”.
For instructions on viewing basic information about a selected VM to which the web console
session is connected, see Section 6.2.3, “Viewing basic virtual machine information in the web
console”.
For instructions on viewing resource usage for a selected VM to which the web console session
is connected, see Section 6.2.4, “Viewing virtual machine resource usage in the web console” .
For instructions on viewing virtual network interface information about a selected VM to which
132
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
For instructions on viewing virtual network interface information about a selected VM to which
the web console session is connected, see Section 6.2.6, “Viewing and editing virtual network
interface information in the web console”.
10.3.7.2. Adding new disks to virtual machines using the web console
You can add new disks to virtual machines (VMs) by creating a new storage volume and attaching it to a
VM using the RHEL 8 web console.
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
1. In the Virtual Machines interface, click the row of the VM for which you want to create and
attach a new disk.
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 Disks.
The Disks pane appears with information about the disks configured for the VM.
133
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Pool - Select the storage pool from which the virtual disk will be created.
Name - Enter a name for the virtual disk that will be created.
Size - Enter the size and select the unit (MiB or GiB) of the virtual disk that will be created.
Format - Select the format for the virtual disk that will be created. The supported types are
qcow2 and raw.
Persistence - If checked, the virtual disk is persistent. If not checked, the virtual disk is
transient.
NOTE
6. Click Add.
The virtual disk is created and connected to the VM.
Additional resources
For instructions on viewing disk information about a selected VM to which the web console
134
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
For instructions on viewing disk information about a selected VM to which the web console
session is connected, see Section 10.3.7.1, “Viewing virtual machine disk information in the web
console”.
For information on attaching existing disks to VMs, see Section 10.3.7.3, “Attaching existing
disks to virtual machines using the web console”.
For information on detaching disks from VMs, see Section 10.3.7.4, “Detaching disks from virtual
machines”.
10.3.7.3. Attaching existing disks to virtual machines using the web console
The following procedure describes how to attach existing storage volumes as disks to a virtual machine
(VM) using the RHEL 8 web console.
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
1. In the Virtual Machines interface, click the row of the VM to which you want to attach an existing
disk.
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 Disks.
The Disks pane appears with information about the disks configured for the VM.
135
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Pool - Select the storage pool from which the virtual disk will be attached.
Persistence - Check to make the virtual disk persistent. Clear to make the virtual disk
transient.
136
CHAPTER 10. MANAGING STORAGE FOR VIRTUAL MACHINES
6. Click Add
The selected virtual disk is attached to the VM.
Additional resources
For instructions on viewing disk information about a selected VM to which the web console
session is connected, see Section 10.3.7.1, “Viewing virtual machine disk information in the web
console”.
For information on creating new disks and attaching them to VMs, see Section 10.3.7.2, “Adding
new disks to virtual machines using the web console”.
For information on detaching disks from VMs, see Section 10.3.7.4, “Detaching disks from virtual
machines”.
The following describes how to detach disks from virtual machines (VMs) using the RHEL 8 web console.
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
1. In the Virtual Machines interface, click the row of the VM from which you want to detach an
existing disk.
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 Disks.
The Disks pane appears with information about the disks configured for the VM.
3. Click the Remove button next to the disk you want to detach from the VM. A Remove Disk
confirmation dialog appears.
137
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Additional resources
For instructions on viewing disk information about a selected VM to which the web console
session is connected, see Section 10.3.7.1, “Viewing virtual machine disk information in the web
console”.
For information on creating new disks and attaching them to VMs, see Section 10.3.7.2, “Adding
new disks to virtual machines using the web console”.
For information on attaching existing disks to VMs, see Section 10.3.7.3, “Attaching existing
disks to virtual machines using the web console”.
138
CHAPTER 11. MANAGING NVIDIA VGPU DEVICES
Note, however, that assigning a physical GPU to VMs, with or without using mediated devices, makes it
impossible for the host to use the GPU.
Prerequisites
Creating mediated vGPU devices is only possible on a limited set of NVIDIA GPUs. For an up-
to-date list of these devices, see the NVIDIA GPU Software Documentation .
If you do not know which GPU your host is using, install the lshw package and use the lshw -C
display command. The following example shows the system is using an NVIDIA Tesla P4 GPU,
compatible with vGPU.
# lshw -C display
*-display
description: 3D controller
product: GP104GL [Tesla P4]
vendor: NVIDIA Corporation
physical id: 0
bus info: pci@0000:01:00.0
version: a1
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress cap_list
configuration: driver=vfio-pci latency=0
resources: irq:16 memory:f6000000-f6ffffff memory:e0000000-efffffff memory:f0000000-
f1ffffff
Procedure
1. Obtain the NVIDIA vGPU drivers and install them on your system. For instructions, see the
NVIDIA documentation.
blacklist nouveau
options nouveau modeset=0
3. Regenerate the initial ramdisk for the current kernel, then reboot.
139
Red Hat Enterprise Linux 8 Configuring and managing virtualization
# dracut --force
# reboot
If you need to use a prior supported kernel version with mediated devices, regenerate the initial
ramdisk for all installed kernel versions.
4. Check that the nvidia_vgpu_vfio module has been loaded by the kernel and that the nvidia-
vgpu-mgr.service service is running.
# uuidgen
30820a6f-b1a5-4503-91ca-0c10ba58692a
# echo "30820a6f-b1a5-4503-91ca-0c10ba58692a" >
/sys/class/mdev_bus/0000:01:00.0/mdev_supported_types/nvidia-63/create
NOTE
For type-id values for specific GPU devices, see the Virtual GPU software
documentation. Note that only Q-series NVIDIA vGPUs, such as GRID P4-2Q, are
supported as mediated device GPU types on Linux VMs.
6. Add the following lines to the <devices/> sections in the XML configurations of guests that you
want to share the vGPU resources. Use the UUID value generated by the uuidgen command in
the previous step. Each UUID can only be assigned to one guest at a time.
Additional resources
140
CHAPTER 11. MANAGING NVIDIA VGPU DEVICES
Additional resources
For the vGPU mediated devices to work properly on the assigned VMs, NVIDIA vGPU guest
software licensing needs to be set up for the VMs. For further information and instructions, see
the NVIDIA virtual GPU software documentation .
Procedure
To remove a mediated vGPU device, use the following command when the device is inactive,
and replace uuid with the UUID of the device, for example 30820a6f-b1a5-4503-91ca-
0c10ba58692a:
Note that attempting to remove a vGPU device that is currently in use by a VM triggers the
following error:
Procedure
Use the virsh nodedev-list --cap mdev_types and virsh nodedev-dumpxml commands.
For example, the following output shows available vGPU types if you are using a physical Tesla
P4 card:
141
Red Hat Enterprise Linux 8 Configuring and managing virtualization
<availableInstances>8</availableInstances>
</type>
<type id='nvidia-65'>
<name>GRID P4-4Q</name>
<deviceAPI>vfio-pci</deviceAPI>
<availableInstances>2</availableInstances>
</type>
<type id='nvidia-63'>
<name>GRID P4-1Q</name>
<deviceAPI>vfio-pci</deviceAPI>
<availableInstances>8</availableInstances>
</type>
<type id='nvidia-71'>
<name>GRID P4-1B</name>
<deviceAPI>vfio-pci</deviceAPI>
<availableInstances>8</availableInstances>
</type>
<type id='nvidia-68'>
<name>GRID P4-2A</name>
<deviceAPI>vfio-pci</deviceAPI>
<availableInstances>4</availableInstances>
</type>
<type id='nvidia-66'>
<name>GRID P4-8Q</name>
<deviceAPI>vfio-pci</deviceAPI>
<availableInstances>1</availableInstances>
</type>
<type id='nvidia-64'>
<name>GRID P4-2Q</name>
<deviceAPI>vfio-pci</deviceAPI>
<availableInstances>4</availableInstances>
</type>
</capability>
</...>
HP-RGS - Note that it is currently not possible to use HP-RGS with RHEL 8 VMs.
Mechdyne TGX - Note that it is currently not possible to use Mechdyne TGX with Windows
Server 2016 VMs.
NICE DCV - When using this streaming service, Red Hat recommends using fixed resolution
settings, as using dynamic resolution in some cases results in a black screen. In addition, it is
currently not possible to use NICE DCV with RHEL 8 VMs.
142
CHAPTER 12. MIGRATING VIRTUAL MACHINES
You can migrate a running VM using live or non-live migrations. To migrate a shut-off VM, an offline
migration must be used.
In a live migration, the VM continues to run on the source host machine while KVM is
transferring the VM’s memory pages to the destination host. When the migration is nearly
complete, KVM very briefly suspends the VM, and resumes it on the destination host.
This is useful for VMs that require constant uptime. However, VMs that modify memory pages
faster than KVM can transfer them, such as VMs under heavy I/O load, cannot be live-migrated,
and non-live migration must be used instead.
A non-live migration suspends the VM, copies its configuration and its memory to the
destination host, and resumes the VM. This creates downtime for the VM, but is generally more
reliable than live migration.
IMPORTANT
For the migration of a running VM (both live and non-live) to work properly, the
VM’s disk images must be located on a shared network, accessible both to the
source host and the destination host. For instructions on setting up such shared
storage, see Section 12.3, “Sharing virtual machine images with other hosts” .
An offline migration moves the VM’s configuration to the destination host. When an offline
migration is used, the VM’s disk images do not have to be available on a shared network, and
can be copied or moved manually to the destination host instead.
Migration benefits
Migrating VMs can be useful for:
Load balancing
VMs can be moved to host machines with lower usage if their host becomes overloaded, or if another
host is under-utilized.
Hardware independence
When you need to upgrade, add, or remove hardware devices on the host machine, you can safely
relocate VMs to other hosts. This means that VMs do not experience any downtime for hardware
improvements.
Energy saving
VMs can be redistributed to other hosts, and the unloaded host systems can thus be powered off to
save energy and cut costs during low usage periods.
Geographic migration
143
Red Hat Enterprise Linux 8 Configuring and managing virtualization
VMs can be moved to another physical location for lower latency or when required for other reasons.
Migration requirements
The source host and the destination host must both be using the KVM hypervisor.
The source host and the destination host must be able to reach each other over the network.
Use the ping utility to verify this.
For the migration to be supportable by Red Hat, the source host and destination host must be
using specific operating systems and machine types. To ensure this is the case, see the VM
migration compatibility table.
Red Hat recommends for the disk images of VMs that will be migrated to be located on a
separate networked location accessible to both the source host and the destination host. This is
optional for offline migration, but required for migrating a running VM.
For instructions to set up such shared VM storage, see Section 12.3, “Sharing virtual machine
images with other hosts”.
When migrating an existing VM in a public bridge tap network, the source and destination hosts
must be located on the same network. Otherwise, the VM network will not operate after
migration.
Migration limitations
Live storage migration cannot be performed on RHEL 8, but you can migrate storage while the
VM is powered down. Note that live storage migration is available on Red Hat Virtualization.
Migrating VMs from or to a user session of libvirt is unreliable and therefore not recommended.
VMs that use certain features and configurations will not work correctly if migrated, or the
migration will fail. Such features include:
Device passthrough
144
CHAPTER 12. MIGRATING VIRTUAL MACHINES
To perform a live migration of a virtual machine (VM) between supported KVM hosts , shared VM storage
is required. This section provides instructions for sharing a locally stored VM image with the source host
and the destination host using the NFS protocol.
Prerequisites
Optional: A host system is available for hosting the storage that is not the source or destination
host, but both the source and the destination host can reach it through the network. This is the
optimal solution for shared storage and is recommended by Red Hat.
Make sure that NFS file locking is not used as it is not supported in KVM.
The NFS is installed and enabled on the source and destination hosts. If they do not:
b. Make sure that the ports for NFS in iptables (such as 2049) are open in the firewall.
Procedure
1. Optional: Use SSH to connect to the host that will provide shared storage. In this example, it is
the phantom-zone host:
# ssh root@phantom-zone
root@phantom-zone's password:
Last login: Mon Sep 24 12:05:36 2019
root~#
2. Create a directory that will hold the disk image and will be shared with the migration hosts.
# mkdir /var/lib/libvirt/shared-images
3. Copy the disk image of the VM from the source host to the newly created directory. For
example, the following copies the disk image of the kal-el VM to the /var/lib/libvirt/shared-
images/ directory on the`phantom-zone` host:
145
Red Hat Enterprise Linux 8 Configuring and managing virtualization
4. On the host that you want to use for sharing the storage, add the sharing directory to the
/etc/exports file. The following example shares the /var/lib/libvirt/shared-images directory
with the krypt.on and ter.ra hosts:
5. On both the source and destination host, mount the shared directory in the
/var/lib/libvirt/images directory:
6. To verify the process was successful, start the VM on the source host and observe if it boots
correctly.
Additional sources
For detailed information on configuring NFS, opening IP tables, and configuring the firewall, see
Exporting NFS shares .
Prerequisites
See Section 12.2, “Requirements and limitations for migrating virtual machines” .
Procedure
1. Use the virsh migrate command with options appropriate for your migration requirements.
The following migrates the kal-el VM from your local host to the system session of the
ter.ra host. The VM will remain running during the migration.
The following enables you to make manual adjustments to the configuration of the jor-el
VM running on your local host, and then migrates the VM to the ter.ra host. The migrated
VM will automatically use the updated configuration.
This procedure can be useful for example when the destination host needs to use a different
path to access the shared VM storage or when configuring a feature specific to the
destination host.
The following suspends the zod VM from the krypt.on host, migrates it to the ter.ra host,
and instructs it to use the adjusted XML configuration, provided by the zod-alt.xml file.
When the migration is completed, libvirt resumes the VM on the destination host.
146
CHAPTER 12. MIGRATING VIRTUAL MACHINES
The following deletes the shut-down faora VM from the krypt.on host, and moves its
configuration to the ter.ra host.
Note that this type of migration does not require moving the VM’s disk image to shared
storage. However, for the VM to be usable on the destination host, you need to migrate the
VM’s disk image. For example:
# scp
[email protected]/var/lib/libvirt/images/faora.qcow2:[email protected]/var/lib/libvirt/images/f
aora.qcow2
2. Wait for the migration to complete. The process may take some time depending on network
bandwidth, system load, and the size of the VM. If the --verbose option is not used for virsh
migrate, the CLI does not display any progress indicators except errors.
In addition, you can use the virsh domjobinfo utility to display the migration statistics.
3. On the destination host, list the available VMs to verify if the VM has been migrated:
# virsh list
Id Name State
----------------------------------
10 kal-el running
Note that if the migration is still running, this command will list the VM state as paused.
Troubleshooting
If a live migration is taking a long time to complete, this may be because the VM is under heavy
load and too many memory pages are changing for live migration to be possible. To fix this
problem, change the migration to a non-live one by suspending the VM.
Additional sources
For further options and examples for virtual machine migration, see the virsh man page.
147
Red Hat Enterprise Linux 8 Configuring and managing virtualization
On supported RHEL 8
systems: machine type
q35.
On supported RHEL 8
systems: machine type
q35.
Additional sources
For information on the currently supported versions of RHEL 7 and RHEL 8, see Red Hat
Knowledge Base.
148
CHAPTER 13. OPTIMIZING VIRTUAL MACHINE PERFORMANCE
Virtual CPUs (vCPUs) are implemented as threads on the host, handled by the Linux scheduler.
VMs do not automatically inherit optimization features, such as NUMA or huge pages, from the
host kernel.
Disk and network I/O settings of the host might have a significant performance impact on the
VM.
Depending on the host devices and their models, there might be significant overhead due to
emulation of particular hardware.
The severity of the virtualization impact on the VM performance is influenced by a variety factors, which
include:
The tuned service can automatically optimize the resource distribution and performance of
your VMs.
Block I/O tuning can improve the performances of the VM’s block devices, such as disks.
IMPORTANT
149
Red Hat Enterprise Linux 8 Configuring and managing virtualization
IMPORTANT
Tuning VM performance can have adverse effects on other virtualization functions. For
example, it can make migrating the modified VM more difficult.
Red Hat recommends using the following profiles when using virtualization in RHEL 8:
For RHEL 8 virtual machines, use the virtual-guest profile. It is based on the generally
applicable throughput-performance profile, but also decreases the swappiness of virtual
memory.
For RHEL 8 virtualization hosts, use the virtual-host profile. This enables more aggressive
writeback of dirty memory pages, which benefits the host performance.
Prerequisites
Procedure
To enable a specific tuned profile:
# tuned-adm list
Available profiles:
- balanced - General non-specialized tuned profile
- desktop - Optimize for the desktop use-case
[...]
- virtual-guest - Optimize for running inside a virtual guest
- virtual-host - Optimize for running KVM guests
Current active profile: balanced
150
CHAPTER 13. OPTIMIZING VIRTUAL MACHINE PERFORMANCE
Additional resources
For more information about tuned and tuned profiles, see Monitoring and managing system
status and performance.
To perform these actions, you can use the web console or the command-line interface.
13.3.1. Adding and removing virtual machine memory using the web console
To improve the performance of a virtual machine (VM) or to free up the host resources it is using, you
can use the web console to adjust amount of memory allocated to the VM.
Prerequisites
The guest OS must be running the memory balloon drivers. To verify this is the case:
If this commands displays any output and the model is not set to none, the memballoon
device is present.
In Windows guests, the drivers are installed as a part of the virtio-win driver package.
For instructions, see Section 17.2.1, “Installing KVM paravirtualized drivers for Windows
virtual machines”.
In Linux guests, the drivers are generally included by default and activate when the
memballoon device is present.
Optional: Obtain the information about the maximum memory and currently used memory for a
VM. This will serve as a baseline for your changes, and also for verification.
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
1. In the Virtual Machines interface, click a row with the name of the VMs for which you want to
151
Red Hat Enterprise Linux 8 Configuring and managing virtualization
1. In the Virtual Machines interface, click a row with the name of the VMs for which you want to
view and adjust the allocated memory.
The row expands to reveal the Overview pane with basic information about the selected VMs.
Maximum allocation - Sets the maximum amount of host memory that the VM can use for
its processes. Increasing this value improves the performance potential of the VM, and
reducing the value lowers the performance footprint the VM has on your host.
Adjusting maximum memory allocation is only possible on a shut-off VM.
Current allocation - Sets a memory limit until the next VM reboot, up to the maximum
allocation. You can use this to temporarily regulate the memory load that the VM has on the
host, without changing the maximum VM allocation.
4. Click Save.
The memory allocation of the VM is adjusted.
Additional resources
For instructions for adjusting VM memory setting using the command-line interface, see
Section 13.3.2, “Adding and removing virtual machine memory using the command-line
interface”.
To optimize how the VM uses the allocated memory, you can modify your vCPU setting. For
more information, see Section 13.5, “Optimizing virtual machine CPU performance” .
13.3.2. Adding and removing virtual machine memory using the command-line
interface
To improve the performance of a virtual machine (VM) or to free up the host resources it is using, you
can use the CLI to adjust amount of memory allocated to the VM.
Prerequisites
The guest OS must be running the memory balloon drivers. To verify this is the case:
152
CHAPTER 13. OPTIMIZING VIRTUAL MACHINE PERFORMANCE
If this commands displays any output and the model is not set to none, the memballoon
device is present.
In Windows guests, the drivers are installed as a part of the virtio-win driver package.
For instructions, see Section 17.2.1, “Installing KVM paravirtualized drivers for Windows
virtual machines”.
In Linux guests, the drivers are generally included by default and activate when the
memballoon device is present.
Optional: Obtain the information about the maximum memory and currently used memory for a
VM. This will serve as a baseline for your changes, and also for verification.
Procedure
1. Adjust the maximum memory allocated to a VM. Increasing this value improves the performance
potential of the VM, and reducing the value lowers the performance footprint the VM has on
your host. Note that this change can only be performed on a shut-off VM, so adjusting a running
VM requires a reboot to take effect.
For example, to change the maximum memory that the testguest VM can use to 4096 MiB:
1. Optional: You can also adjust the memory currently used by the VM, up to the maximum
allocation. This regulates the memory load that the VM has on the host until the next reboot,
without changing the maximum VM allocation.
Verification
2. Optional: If you adjusted the current VM memory, you can obtain the memory balloon statistics
of the VM to evaluate how effectively it regulates its memory use.
153
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Additional resources
For instructions for adjusting VM memory setting using the web console, see Section 13.3.1,
“Adding and removing virtual machine memory using the web console”.
To optimize how the VM uses the allocated memory, you can modify your vCPU setting. For
more information, see Section 13.5, “Optimizing virtual machine CPU performance” .
Increasing the I/O weight of a device increases its priority for I/O bandwidth, and therefore provides it
with more host resources. Similarly, reducing a device’s weight makes it consume less host resources.
NOTE
Each device’s weight value must be within the 100 to 1000 range. Alternatively, the value
can be 0, which removes that device from per-device listings.
Procedure
To display and set a VM’s block I/O parameters:
154
CHAPTER 13. OPTIMIZING VIRTUAL MACHINE PERFORMANCE
<domain>
[...]
<blkiotune>
<weight>800</weight>
<device>
<path>/dev/sda</path>
<weight>1000</weight>
</device>
<device>
<path>/dev/sdb</path>
<weight>500</weight>
</device>
</blkiotune>
[...]
</domain>
For example, the following changes the weight of the /dev/sda device in the liftrul VM to 500.
To enable disk I/O throttling, set a limit on disk I/O requests sent from each block device attached to
VMs to the host machine.
Procedure
1. Use the virsh domblklist command to list the names of all the disk devices on a specified VM.
2. Set I/O limits for a block device attached to a VM using the virsh blkdeviotune command:
For example, to throttle the sdb device on the rollin-coal VM to 1000 I/O operations per
155
Red Hat Enterprise Linux 8 Configuring and managing virtualization
For example, to throttle the sdb device on the rollin-coal VM to 1000 I/O operations per
second and 50 MB per second throughput:
Additional information
Disk I/O throttling can be useful in various situations, for example when VMs belonging to
different customers are running on the same host, or when quality of service guarantees are
given for different VMs. Disk I/O throttling can also be used to simulate slower disks.
I/O throttling can be applied independently to each block device attached to a VM and
supports limits on throughput and I/O operations.
Procedure
To enable multi-queue virtio-scsi support for a specific VM, add the following to the VM’s XML
configuration, where N is the total number of vCPU queues:
1. Adjust how many host CPUs are assigned to the VM. You can do this using the CLI or the web
console.
2. Ensure that the vCPU model is aligned with the CPU model of the host. For example, to set the
testguest1 VM to use the CPU model of the host:
3. If your host machine uses Non-Uniform Memory Access (NUMA), you can also configure NUMA
for its VMs. This maps the host’s CPU and memory processes onto the CPU and memory
processes of the VM as closely as possible. In effect, NUMA tuning provides the vCPU with a
more streamlined access to the system memory allocated to the VM, which can improve the
vCPU processing effectiveness.
For details, see Section 13.5.3, “Configuring NUMA in a virtual machine” and Section 13.5.4,
“Sample vCPU performance tuning scenario”.
13.5.1. Adding and removing virtual CPUs using the command-line interface
To increase or optimize the CPU performance of a virtual machine (VM), you can add or remove virtual
156
CHAPTER 13. OPTIMIZING VIRTUAL MACHINE PERFORMANCE
To increase or optimize the CPU performance of a virtual machine (VM), you can add or remove virtual
CPUs (vCPUs) assigned to the VM.
When performed on a running VM, this is also referred to as vCPU hot plugging and hot unplugging.
However, note that vCPU hot unplug is not supported in RHEL 8, and Red Hat highly discourages its use.
Prerequisites
Optional: View the current state of the vCPUs in the targeted VM. For example, to display the
number of vCPUs on the testguest VM:
This output indicates that testguest is currently using 1 vCPU, and 1 more vCPu can be hot
plugged to it to increase the VM’s performance. However, after reboot, the number of vCPUs
testguest uses will change to 2, and it will be possible to hot plug 2 more vCPUs.
Procedure
1. Adjust the maximum number of vCPUs that can be attached to a VM, which takes effect on the
VM’s next boot.
For example, to increase the maximum vCPU count for the testguest VM to 8:
Note that the maximum may be limited by the CPU topology, host hardware, the hypervisor,
and other factors.
2. Adjust the current number of vCPUs attached to a VM, up to the maximum configured in the
previous step. For example:
This increases the VM’s performance and host load footprint of testguest until the VM’s
next boot.
This decreases the VM’s performance and host load footprint of testguest after the VM’s
next boot. However, if needed, additional vCPUs can be hot plugged to the VM to
temporarily increase its performance.
Verification
Confirm that the current state of vCPU for the VM reflects your changes.
157
Red Hat Enterprise Linux 8 Configuring and managing virtualization
maximum config 8
maximum live 4
current config 1
current live 4
Additional resources
For information on adding and removing vCPUs using the web console, see Section 13.5.2,
“Managing virtual CPUs using the web console”.
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
1. In the Virtual Machines interface, click a row with the name of the VMs for which you want to
view and configure virtual CPU parameters.
The row expands to reveal the Overview pane with basic information about the selected VMs,
including the number of virtual CPUs, and controls for shutting down and deleting the VM.
NOTE
The warning in the vCPU details dialog only appears after the virtual CPU
settings are changed.
NOTE
158
CHAPTER 13. OPTIMIZING VIRTUAL MACHINE PERFORMANCE
NOTE
vCPU Maximum - The maximum number of virtual CPUs that can be configured for the
VM. If this value is higher than the vCPU Count, additional vCPUs can be attached to the
VM.
Cores per socket - The number of cores for each socket to expose to the VM.
Threads per core - The number of threads for each core to expose to the VM.
Note that the Sockets, Cores per socket, and Threads per core options adjust the CPU
topology of the VM. This may be beneficial for vCPU performance and may impact the
functionality of certain software in the guest OS. If a different setting is not required by your
deployment, Red Hat recommends keeping the default values.
4. Click Apply.
The virtual CPUs for the VM are configured.
NOTE
Changes to virtual CPU settings only take effect after the VM is restarted.
Additional resources:
For information on managing your vCPUs using the command-line interface, see Section 13.5.1,
“Adding and removing virtual CPUs using the command-line interface”.
Prerequisites
The host must be a NUMA-compatible machine. To detect whether this is the case, use the
virsh nodeinfo command and see the NUMA cell(s) line:
# virsh nodeinfo
CPU model: x86_64
CPU(s): 48
CPU frequency: 1200 MHz
CPU socket(s): 1
Core(s) per socket: 12
Thread(s) per core: 2
NUMA cell(s): 2
Memory size: 67012964 KiB
Procedure
For ease of use, you can set up a VM’s NUMA configuration using automated utilities and services.
159
Red Hat Enterprise Linux 8 Configuring and managing virtualization
For ease of use, you can set up a VM’s NUMA configuration using automated utilities and services.
However, manual NUMA setup is more likely to yield a significant performance improvement.
Automatic methods
Set the VM’s NUMA policy to Preferred. For example, to do so for the testguest5 VM:
Use the numad command to automatically align the VM CPU with memory resources.
# numad
Manual methods
1. Pin specific vCPU threads to a specific host CPU or range of CPUs. This is also possible on non-
NUMA hosts and VMs, and is recommended as a safe method of vCPU performance
improvement.
For example, the following commands pin vCPU threads 0 to 5 of the testguest6 VM to host
CPUs 1, 3, 5, 7, 9, and 11, respectively:
2. After pinning vCPU threads, you can also pin QEMU process threads associated with a specified
VM to a specific host CPU or range of CPUs. For example, the following commands pin the
QEMU process thread of testguest6 to CPUs 13 and 15, and verify this was successful:
160
CHAPTER 13. OPTIMIZING VIRTUAL MACHINE PERFORMANCE
3. Finally, you can also specify which host NUMA nodes will be assigned specifically to a certain
VM. This can improve the host memory usage by the VM’s vCPU. For example, the following
commands set testguest6 to use host NUMA nodes 3 to 5, and verify this was successful:
Additional resources
Note that for best performance results, it is recommended to use all of the manual tuning
methods listed above. For an example of such a configuration, see Section 13.5.4, “Sample
vCPU performance tuning scenario”.
To see the current NUMA configuration of your system, you can use the numastat utility. For
details on using numastat, see Section 13.7, “Virtual machine performance monitoring tools” .
NUMA tuning is currently not possible to perform on IBM Z hosts. For further information, see
Section 4.2, “How virtualization on IBM Z differs from AMD64 and Intel 64” .
Starting scenario
2 NUMA nodes
The output of virsh nodeinfo of such a machine would look similar to:
# virsh nodeinfo
CPU model: x86_64
CPU(s): 12
CPU frequency: 3661 MHz
CPU socket(s): 2
Core(s) per socket: 3
Thread(s) per core: 2
NUMA cell(s): 2
Memory size: 31248692 KiB
You intend to modify an existing VM to have 8 vCPUs, which means that it will not fit in a single
NUMA node.
Therefore, you should distribute 4 vCPUs on each NUMA node and make the vCPU topology
resemble the host topology as closely as possible. This means that vCPUs that run as sibling
threads of a given physical CPU should be pinned to host threads on the same core. For details,
see the Solution below:
Solution
161
Red Hat Enterprise Linux 8 Configuring and managing virtualization
# virsh capabilities
The output should include a section that looks similar to the following:
<topology>
<cells num="2">
<cell id="0">
<memory unit="KiB">15624346</memory>
<pages unit="KiB" size="4">3906086</pages>
<pages unit="KiB" size="2048">0</pages>
<pages unit="KiB" size="1048576">0</pages>
<distances>
<sibling id="0" value="10" />
<sibling id="1" value="21" />
</distances>
<cpus num="6">
<cpu id="0" socket_id="0" core_id="0" siblings="0,3" />
<cpu id="1" socket_id="0" core_id="1" siblings="1,4" />
<cpu id="2" socket_id="0" core_id="2" siblings="2,5" />
<cpu id="3" socket_id="0" core_id="0" siblings="0,3" />
<cpu id="4" socket_id="0" core_id="1" siblings="1,4" />
<cpu id="5" socket_id="0" core_id="2" siblings="2,5" />
</cpus>
</cell>
<cell id="1">
<memory unit="KiB">15624346</memory>
<pages unit="KiB" size="4">3906086</pages>
<pages unit="KiB" size="2048">0</pages>
<pages unit="KiB" size="1048576">0</pages>
<distances>
<sibling id="0" value="21" />
<sibling id="1" value="10" />
</distances>
<cpus num="6">
<cpu id="6" socket_id="1" core_id="3" siblings="6,9" />
<cpu id="7" socket_id="1" core_id="4" siblings="7,10" />
<cpu id="8" socket_id="1" core_id="5" siblings="8,11" />
<cpu id="9" socket_id="1" core_id="3" siblings="6,9" />
<cpu id="10" socket_id="1" core_id="4" siblings="7,10" />
<cpu id="11" socket_id="1" core_id="5" siblings="8,11" />
</cpus>
</cell>
</cells>
</topology>
2. Optional: Test the performance of the VM using the applicable tools and utilities.
default_hugepagesz=1G hugepagesz=1G
[Unit]
Description=HugeTLB Gigantic Pages Reservation
DefaultDependencies=no
Before=dev-hugepages.mount
ConditionPathExists=/sys/devices/system/node
ConditionKernelCommandLine=hugepagesz=1G
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/etc/systemd/hugetlb-reserve-pages.sh
[Install]
WantedBy=sysinit.target
#!/bin/sh
nodes_path=/sys/devices/system/node/
if [ ! -d $nodes_path ]; then
echo "ERROR: $nodes_path does not exist"
exit 1
fi
reserve_pages()
{
echo $1 > $nodes_path/$2/hugepages/hugepages-1048576kB/nr_hugepages
}
reserve_pages 4 node1
reserve_pages 4 node2
This reserves four 1GiB huge pages from node1 and four 1GiB huge pages from node2.
# chmod +x /etc/systemd/hugetlb-reserve-pages.sh
4. Use the virsh edit command to edit the XML configuration of the VM you wish to optimize, in
this example super-VM:
a. Set the VM to use 8 static vCPUs. Use the <vcpu/> element to do this.
163
Red Hat Enterprise Linux 8 Configuring and managing virtualization
b. Pin each of the vCPU threads to the corresponding host CPU threads that it mirrors in the
topology. To do so, use the <vcpupin/> elements in the <cputune> section.
Note that, as shown by the virsh capabilities utility above, host CPU threads are not
ordered sequentially in their respective cores. In addition, the vCPU threads should be
pinned to the highest available set of host cores on the same NUMA node. For a table
illustration, see the Additional Resources section below.
The XML configuration for steps a. and b. can look similar to:
<cputune>
<vcpupin vcpu='0' cpuset='1'/>
<vcpupin vcpu='1' cpuset='4'/>
<vcpupin vcpu='2' cpuset='2'/>
<vcpupin vcpu='3' cpuset='5'/>
<vcpupin vcpu='4' cpuset='7'/>
<vcpupin vcpu='5' cpuset='10'/>
<vcpupin vcpu='6' cpuset='8'/>
<vcpupin vcpu='7' cpuset='11'/>
<emulatorpin cpuset='6,9'/>
</cputune>
<memoryBacking>
<hugepages>
<page size='1' unit='GiB'/>
</hugepages>
</memoryBacking>
d. Configure the VM’s NUMA nodes to use memory from the corresponding NUMA nodes on
the host. To do so, use the <memnode/> elements in the <numatune/> section:
<numatune>
<memory mode="preferred" nodeset="1"/>
<memnode cellid="0" mode="strict" nodeset="0"/>
<memnode cellid="1" mode="strict" nodeset="1"/>
</numatune>
e. Ensure the CPU mode is set to host-passthrough, and that the CPU uses cache in
passthrough mode:
<cpu mode="host-passthrough">
<topology sockets="2" cores="2" threads="2"/>
<cache mode="passthrough"/>
6. The resulting XML configuration of the VM should include a section similar to the following:
[...]
<memoryBacking>
<hugepages>
<page size='1' unit='GiB'/>
</hugepages>
</memoryBacking>
<vcpu placement='static'>8</vcpu>
164
CHAPTER 13. OPTIMIZING VIRTUAL MACHINE PERFORMANCE
<cputune>
<vcpupin vcpu='0' cpuset='1'/>
<vcpupin vcpu='1' cpuset='4'/>
<vcpupin vcpu='2' cpuset='2'/>
<vcpupin vcpu='3' cpuset='5'/>
<vcpupin vcpu='4' cpuset='7'/>
<vcpupin vcpu='5' cpuset='10'/>
<vcpupin vcpu='6' cpuset='8'/>
<vcpupin vcpu='7' cpuset='11'/>
<emulatorpin cpuset='6,9'/>
</cputune>
<numatune>
<memory mode="preferred" nodeset="1"/>
<memnode cellid="0" mode="strict" nodeset="0"/>
<memnode cellid="1" mode="strict" nodeset="1"/>
</numatune>
<cpu mode="host-passthrough">
<topology sockets="2" cores="2" threads="2"/>
<cache mode="passthrough"/>
<numa>
<cell id="0" cpus="0-3" memory="2" unit="GiB">
<distances>
<sibling id="0" value="10"/>
<sibling id="1" value="21"/>
</distances>
</cell>
<cell id="1" cpus="4-7" memory="2" unit="GiB">
<distances>
<sibling id="0" value="21"/>
<sibling id="1" value="10"/>
</distances>
</cell>
</numa>
</cpu>
</domain>
7. Optional: Test the performance of the VM using the applicable tools and utilities to evaluate
the impact of the VM’s optimization.
Additional resources
The following tables illustrate the connections between the vCPUs and the host CPUs they
should be pinned to:
CPU threads 0 3 1 4 2 5 6 9 7 10 8 11
Cores 0 1 2 3 4 5
Sockets 0 1
NUMA nodes 0 1
165
Red Hat Enterprise Linux 8 Configuring and managing virtualization
vCPU threads 0 1 2 3 4 5 6 7
Cores 0 1 2 3
Sockets 0 1
NUMA nodes 0 1
vCPU threads 0 1 2 3 4 5 6 7
Host CPU 0 3 1 4 2 5 6 9 7 10 8 11
threads
Cores 0 1 2 3 4 5
Sockets 0 1
NUMA nodes 0 1
In this scenario, there are 2 NUMA nodes and 8 vCPUs. Therefore, 4 vCPU threads should be
pinned to each node.
In addition, Red Hat recommends leaving at least a single CPU thread available on each node
for host system operations.
Because in this example, each NUMA node houses 3 cores, each with 2 host CPU threads, the
set for node 0 translates as follows:
Procedure
Use any of the following methods and observe if it has a beneficial effect on your VM network
performance:
166
CHAPTER 13. OPTIMIZING VIRTUAL MACHINE PERFORMANCE
If the output of this command is blank, enable the vhost_net kernel module:
# modprobe vhost_net
<interface type='network'>
<source network='default'/>
<model type='virtio'/>
<driver name='vhost' queues='N'/>
</interface>
Also, enabling zero-copy transmit can cause head-of-line blocking of packets, which may create a
potential security risk.
# modprobe -r vhost_net
2. Re-enable the vhost-net module with the zero-copy parameter turned on:
# cat /sys/module/vhost_net/parameters/experimental_zcopytx
1
167
Red Hat Enterprise Linux 8 Configuring and managing virtualization
SR-IOV
If your host NIC supports SR-IOV, use SR-IOV device assignment for your vNICs. For more
information, see Section 9.6, “Managing SR-IOV devices” .
Additional resources
For additional information on virtual network connection types and tips for usage, see
Section 15.1, “Understanding virtual networking” .
On your RHEL 8 host, as root, use the top utility or the system monitor application, and look for
qemu and virt in the output. This shows how much host system resources your VMs are
consuming.
If the monitoring tool displays that any of the qemu or virt processes consume a large
portion of the host CPU or memory capacity, use the perf utility to investigate. For details,
see below.
On the guest operating system, use performance utilities and applications available on the
system to evaluate which processes consume the most system resources.
perf kvm
You can use the perf utility to collect and analyze virtualization-specific statistics about the
performance of your RHEL 8 host. To do so:
2. Use the perf kvm stat command to display perf statistics for your virtualization host:
For real-time monitoring of your hypervisor, use the perf kvm stat live command.
To log the perf data of your hypervisor over a period of time, activate the logging using the
perf kvm stat record command. After the command is canceled or interrupted, the data is
saved in the perf.data.guest file, which can be analyzed using the perf kvm stat report
168
CHAPTER 13. OPTIMIZING VIRTUAL MACHINE PERFORMANCE
command.
3. Analyze the perf output for types of VM-EXIT events and their distribution. For example, the
PAUSE_INSTRUCTION events should be infrequent, but in the following output, the high
occurrence of this event suggests that the host CPUs are not handling the running vCPUs well.
In such a scenario, consider shutting down some of your active VMs, removing vCPUs from
these VMs, or tuning the performance of the vCPUs.
VM-EXIT Samples Samples% Time% Min Time Max Time Avg time
Other event types that can signal problems in the output of perf kvm stat include:
For more information on using perf to monitor virtualization performance, see the perf-kvm man page.
numastat
To see the current NUMA configuration of your system, you can use the numastat utility, which is
provided by installing the numactl package.
The following shows a host with 4 running VMs, each obtaining memory from multiple NUMA nodes. This
is not optimal for vCPU performance, and warrants adjusting:
# numastat -c qemu-kvm
169
Red Hat Enterprise Linux 8 Configuring and managing virtualization
In contrast, the following shows memory being provided to each VM by a single node, which is
significantly more efficient.
# numastat -c qemu-kvm
170
CHAPTER 14. SHARING FILES BETWEEN THE HOST AND ITS VIRTUAL MACHINES
Prerequisites
A directory that you want to share with your VMs. If you do not want to share any of your existing
directories, create a new one, for example named shared-files.
# mkdir shared-files
The host is visible and reachable over a network for the VM. This is generally the case if the VM
is connected using the NAT and bridge type of virtual networks. However, for the macvtap
connection, you must first set up the macvlan feature on the host. To do so:
1. Create a network device file, for example called vm-macvlan.netdev in the host’s
/etc/systemd/network/ directory.
# touch /etc/systemd/network/vm-macvlan.netdev
2. Edit the network device file to have the following content. You can replace vm-macvlan
with the name you chose for your network device.
[NetDev]
Name=vm-macvlan
Kind=macvlan
[MACVLAN]
Mode=bridge
3. Create a network configuration file for your macvlan network device, for example vm-
macvlan.network.
# touch /etc/systemd/network/vm-macvlan.network
4. Edit the network configuration file to have the following content. You can replace vm-
macvlan with the name you chose for your network device.
[Match]
Name=_vm-macvlan_
[Network]
171
Red Hat Enterprise Linux 8 Configuring and managing virtualization
IPForward=yes
Address=192.168.250.33/24
Gateway=192.168.250.1
DNS=192.168.250.1
5. Create a network configuration file for your physical network interface. For example, if your
interface is enp4s0:
# touch /etc/systemd/network/enp4s0.network
If you are unsure what interface name to use, you can use the ifconfig command on your
host to obtain the list of active network interfaces.
6. Edit the physical network configuration file to make the physical network a part of the
macvlan interface, in this case vm-macvlan:
[Match]
Name=enp4s0
[Network]
MACVLAN=vm-macvlan
Optional: For improved security, ensure your VMs are compatible with NFS version 4 or later.
Procedure
1. On the host, export a directory with the files you want to share as a network file system (NFS).
a. Obtain the IP address of each virtual machine you want to share files with. The following
example obtains the IPs of testguest1 and testguest2.
b. Edit the /etc/exports file on the host and add a line that includes the directory you want to
share, IPs of VMs you want to share with, and sharing options.
For example, the following shares the /usr/local/shared-files directory on the host with
testguest1 and testguest2, and enables the VMs to edit the content of the directory:
172
CHAPTER 14. SHARING FILES BETWEEN THE HOST AND ITS VIRTUAL MACHINES
# exportfs -a
e. Obtain the IP address of the host system. This will be used for mounting the shared
directory on the VMs later.
# ip addr
[...]
5: virbr0: [BROADCAST,MULTICAST,UP,LOWER_UP] mtu 1500 qdisc noqueue state
UP group default qlen 1000
link/ether 52:54:00:32:ff:a5 brd ff:ff:ff:ff:ff:ff
inet 192.168.124.1/24 brd 192.168.124.255 scope global virbr0
valid_lft forever preferred_lft forever
[...]
Note that the relevant network is the one being used use for connection to the host by the
VMs you want to share files with. Usually, this is virbr0.
2. On the guest OS of a VM specified in the /etc/exports file, mount the exported file system.
a. Create a directory you want to use as a mount point for the shared file system, for example
/mnt/host-share:
# mkdir /mnt/host-share
b. Mount the directory exported by the host on the mount point. This example mounts the
/usr/local/shared-files directory exported by the 192.168.124.1 host on /mnt/host-share in
the guest:
c. To verify the mount has succeeded, access and explore the shared directory on the mount
point:
# cd /mnt/host-share
# ls
shared-file1 shared-file2 shared-file3
Prerequisites
The samba packages are installed on your host. If they are not:
173
Red Hat Enterprise Linux 8 Configuring and managing virtualization
The host is visible and reachable over a network for the VM. This is generally the case if the VM
is connected using the NAT and bridge type of virtual networks. However, for the macvtap
connection, you must first set up the macvlan feature on the host. To do so:
1. Create a network device file, for example called vm-macvlan.netdev in the host’s
/etc/systemd/network/ directory.
# touch /etc/systemd/network/vm-macvlan.netdev
2. Edit the network device file to have the following content. You can replace vm-macvlan
with the name you chose for your network device.
[NetDev]
Name=vm-macvlan
Kind=macvlan
[MACVLAN]
Mode=bridge
3. Create a network configuration file for your macvlan network device, for example vm-
macvlan.network.
# touch /etc/systemd/network/vm-macvlan.network
4. Edit the network configuration file to have the following content. You can replace vm-
macvlan with the name you chose for your network device.
[Match]
Name=_vm-macvlan_
[Network]
IPForward=yes
Address=192.168.250.33/24
Gateway=192.168.250.1
DNS=192.168.250.1
5. Create a network configuration file for your physical network interface. For example, if your
interface is enp4s0:
# touch /etc/systemd/network/enp4s0.network
If you are unsure what interface to use, you can use the ifconfig command on your host to
obtain the list of active network interfaces.
6. Edit the physical network configuration file to make the physical network a part of the
macvlan interface, in this case vm-macvlan:
[Match]
Name=enp4s0
[Network]
MACVLAN=vm-macvlan
174
CHAPTER 14. SHARING FILES BETWEEN THE HOST AND ITS VIRTUAL MACHINES
Procedure
1. On the host, create a Samba share and make it accessible for external systems.
Note that the hosts allow line restricts the accessibility of the share only to hosts on
the VM network. If you want the share to be accessible by anyone, remove the line.
# mkdir -p /samba/VM-share
f. Allow the VM-share directory to be accessible and modifiable for the VMs.
2. On the Windows guest operating system, attach the Samba share as a network location.
175
Red Hat Enterprise Linux 8 Configuring and managing virtualization
c. In the Add Network Location wizard that opens, select "Choose a custom network location"
and click Next.
d. In the "Internet or network address" field, type host-IP/VM-share, where host-IP is the IP
address of the host. Usually, the host IP is the default gateway of the VM. Afterwards, click
Next.
e. When the wizard asks if you want to rename the shared directory, keep the default name.
This ensures the consistency of file sharing configuration across the VM and the guest. Click
Next.
f. If accessing the network location was successful, you can now click Finish and open the
176
CHAPTER 14. SHARING FILES BETWEEN THE HOST AND ITS VIRTUAL MACHINES
f. If accessing the network location was successful, you can now click Finish and open the
shared directory.
177
Red Hat Enterprise Linux 8 Configuring and managing virtualization
The VMs on your host can be made possible to discover and connect to by locations outside the
host, as if the VMs were on the same network as the host.
A VM can be partially or completely isolated from inbound network traffic to increase its security
and minimize the risk of any problems with the VM impacting the host.
The following sections explain the various types of VM network configuration and provide instructions
for setting up selected VM network configurations.
Virtual networking uses the concept of a virtual network switch. A virtual network switch is a software
construct that operates on a host machine. VMs connect to the network through the virtual network
switch.
The following figure shows a virtual network switch connecting two VMs to the network:
From the perspective of a guest operating system, a virtual network connection is the same as a physical
network connection. Host machine servers view virtual network switches as network interfaces. When
the libvirtd daemon (libvirtd) is first installed and started, the default network interface that represents
the virtual network switch is virbr0.
This interface can be viewed with the ip command like any other network interface.
178
CHAPTER 15. CONFIGURING VIRTUAL MACHINE NETWORK CONNECTIONS
By default, all VMs on a single host are connected to the same libvirt virtual network, named default.
For details, see Section 15.1.1, “Virtual networking default configuration” .
For basic outbound-only network access from VMs, no additional network setup is usually needed,
because the default network is installed along with the libvirt package, and is automatically started when
the libvirtd service is started.
If more advanced functionality is needed, additional networks can be created and configured using
virsh, and the VM’s XML configuration file can be edited to use one of these new networks.
For more information on the default configuration, see Section 15.1.1, “Virtual networking default
configuration”.
If needed, guest interfaces can instead be set to one of the following modes:
Routed mode
Bridged mode
Isolated mode
Open mode
The virtual network uses network address translation (NAT) to assign IP address ranges to virtual
networks and dnsmasq to automatically assign IP addresses to virtual machine network interface cards
(NICs) and to connect to a domain name service (DNS).
179
Red Hat Enterprise Linux 8 Configuring and managing virtualization
NOTE
A virtual network can be restricted to a specific physical interface. This may be useful on a
physical system that has several interfaces (for example, eth0, eth1, and eth2). This is
only useful in routed and NAT modes, and can be defined in the dev=<interface> option,
or in the RHEL 8 web console when creating a new virtual network.
180
CHAPTER 15. CONFIGURING VIRTUAL MACHINE NETWORK CONNECTIONS
WARNING
Virtual network switches use NAT configured by iptables rules. Editing these rules
while the switch is running is not recommended, because incorrect rules may result
in the switch being unable to communicate.
If the switch is not running, you can set the public IP range for forward mode NAT in order to create a
port masquerading range by running:
Common topologies
The common topologies in which routed mode is used include DMZ and virtual server hosting include
the following:
DMZ
You can create a network where one or more nodes are placed in a controlled sub-network for
security reasons. Such a sub-network is known as a demilitarized zone (DMZ).
181
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Host machines in a DMZ typically provide services to WAN (external) host machines as well as LAN
(internal) host machines. Since this requires them to be accessible from multiple locations, and
considering that these locations are controlled and operated in different ways based on their security
and trust level, routed mode is the best configuration for this environment.
182
CHAPTER 15. CONFIGURING VIRTUAL MACHINE NETWORK CONNECTIONS
A VM in bridged mode has to connect to an existing Linux bridge on the host, and therefore requires a
network bridge to be created on the host interface. In contrast, other VM networking modes
automatically create and connect to the virbr0 virtual bridge.
All of the VMs appear within the same subnet as the host machine. All other physical machines on the
same physical network are aware of the VMs, and can access them. Bridging operates on Layer 2 of the
OSI networking model.
It is possible to use multiple physical interfaces on the hypervisor by joining them together with a bond.
The bond is then added to a bridge and then VMs are added onto the bridge as well. However, the
bonding driver has several modes of operation, and only a few of these modes work with a bridge where
VMs are in use.
WARNING
When using bridged mode, the only bonding modes that should be used with a VM
are Mode 1, Mode 2, and Mode 4. Using modes 0, 3, 5, or 6 is likely to cause the
connection to fail. Also note that Media-Independent Interface (MII) monitoring
should be used to monitor bonding modes, as Address Resolution Protocol (ARP)
monitoring does not work.
For more information on bonding modes, refer to the Red Hat Knowledgebase .
Common scenarios
The most common use cases for bridged mode include:
Deploying VMs in an existing network alongside host machines, making the difference between
virtual and physical machines transparent to the end user.
Deploying VMs without making any changes to existing physical network configuration settings.
Deploying VMs that must be easily accessible to an existing physical network. Placing VMs on a
physical network where they must access services within an existing broadcast domain, such as
DHCP.
183
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Additional resources
The dnsmasq DHCP service can assign a pool of addresses to a virtual network switch. IP information
can be assigned to virtual machines via DHCP.
dnsmasq accepts DNS queries from virtual machines on the virtual network and forwards them to a real
DNS server.
An instance of dnsmasq is automatically configured and started by libvirt for each virtual network
switch that needs it.
Using the RHEL 8 web console, you can manage the virtual network interfaces for the virtual machines
184
CHAPTER 15. CONFIGURING VIRTUAL MACHINE NETWORK CONNECTIONS
Using the RHEL 8 web console, you can manage the virtual network interfaces for the virtual machines
to which the web console is connected. You can:
Add network interfaces to virtual machines , and disconnect or delete the interfaces.
15.2.1. Viewing and editing virtual network interface information in the web console
Using the RHEL 8 web console, you can view and modify the virtual network interfaces on a selected
virtual machine (VM):
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
1. In the Virtual Machines interface, click the row of the VM whose information you want to see.
The row expands to reveal the Overview pane with basic information about the selected VM and
controls for shutting down and deleting the VM.
Type - The type of network interface for the VM. Types include virtual network, bridge to
LAN, and direct attachment.
NOTE
Source - The source of the network interface. This is dependent on the network type.
185
Red Hat Enterprise Linux 8 Configuring and managing virtualization
3. To edit the virtual network interface settings, Click Edit. The Virtual Network Interface Settings
dialog opens.
NOTE
Changes to the virtual network interface settings take effect only after restarting
the VM.
Additional resources
For instructions on viewing information about all of the VMs to which the web console session is
connected, see Section 6.2.1, “Viewing a virtualization overview in the web console” .
For instructions on viewing information about the storage pools to which the web console
session is connected, see Section 6.2.2, “Viewing storage pool information using the web
console”.
For instructions on viewing basic information about a selected VM to which the web console
session is connected, see Section 6.2.3, “Viewing basic virtual machine information in the web
console”.
For instructions on viewing resource usage for a selected VM to which the web console session
is connected, see Section 6.2.4, “Viewing virtual machine resource usage in the web console” .
For instructions on viewing disk information about a selected VM to which the web console
session is connected, see Section 6.2.5, “Viewing virtual machine disk information in the web
console”.
186
CHAPTER 15. CONFIGURING VIRTUAL MACHINE NETWORK CONNECTIONS
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
1. In the Virtual Machines interface, click the row of the VM whose virtual network interface you
want to connect.
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 Networks.
The Networks pane appears with information about the virtual network interfaces configured for
the VM.
3. Click Plug in the row of the virtual network interface you want to connect.
The selected virtual network interface connects to the VM.
Prerequisites
To use the web console to manage VMs, install the web console VM plug-in .
Procedure
1. In the Virtual Machines interface, click the row of the VM whose virtual network interface you
want to disconnect.
The row expands to reveal the Overview pane with basic information about the selected VM and
controls for shutting down and deleting the VM.
187
Red Hat Enterprise Linux 8 Configuring and managing virtualization
3. Click Unplug in the row of the virtual network interface you want to disconnect.
The selected virtual network interface disconnects from the VM.
188
CHAPTER 16. SECURING VIRTUAL MACHINES
This document outlines the mechanics of securing VMs on a RHEL 8 host and provides a list of methods
to increase the security of your VMs.
Because the hypervisor uses the host kernel to manage VMs, services running on the VM’s operating
system are frequently used for injecting malicious code into the host system. However, you can protect
your system against such security threats by using a number of security features on your host and your
guest systems.
These features, such as SELinux or QEMU sandboxing, provide various measures that make it more
difficult for malicious code to attack the hypervisor and transfer between your host and your VMs.
Many of the features that RHEL 8 provides for VM security are always active and do not have to be
enabled or configured. For details, see Section 16.4, “Automatic features for virtual machine security” .
In addition, you can adhere to a variety of best practices to minimize the vulnerability of your VMs and
your hypervisor. For more information, see Section 16.2, “Best practices for securing virtual machines” .
Secure the virtual machine as if it was a physical machine. The specific methods available to
enhance security depend on the guest OS.
If your VM is running RHEL 8, see Configuring and managing security in RHEL 8 for detailed
instructions on improving the security of your guest system.
When managing VMs remotely, use cryptographic utilities such as SSH and network protocols
such as SSL for connecting to the VMs.
# getenforce
Enforcing
If SELinux is disabled or in Permissive mode, see the Using SELinux document for instructions
on activating Enforcing mode.
NOTE
190
CHAPTER 16. SECURING VIRTUAL MACHINES
NOTE
SELinux Enforcing mode also enables the sVirt RHEL 8 feature. This is a set of
specialized SELinux booleans for virtualization, which can be manually adjusted
for fine-grained VM security management.
SecureBoot can only be applied when installing a Linux VM that uses OVMF firmware. For
instructions, see Section 16.3, “Creating a SecureBoot virtual machine” .
Additional resources
For detailed information on modifying your virtualization booleans, see Section 16.5,
“Virtualization booleans”.
Prerequisites
An operating system (OS) installation source, which can be one of the following, and be
available locally or on a network:
Optionally, a Kickstart file can also be provided for faster and easier configuration of the
installation.
Procedure
1. Use the virt-install command to create a VM as detailed in Section 2.2.1, “Creating virtual
191
Red Hat Enterprise Linux 8 Configuring and managing virtualization
machines using the command-line interface”. For the --boot option, use the
uefi,nvram_template=/usr/share/OVMF/OVMF_VARS.secboot.fd value. This uses the
OVMF_VARS.secboot.fd and OVMF_CODE.secboot.fd files as templates for the VM’s non-
volatile RAM (NVRAM) settings, which enables the SecureBoot feature.
For example:
3. After the guest OS is installed, access the VM’s command line by opening the terminal in the
graphical guest console or connecting to the guest OS using SSH.
# mokutil --sb-state
SecureBoot enabled
NOTE
The RHEL 8 documentation assumes you have libvirt system session privileges.
192
CHAPTER 16. SECURING VIRTUAL MACHINES
To list all virtualization-related booleans and their statuses, use the getsebool -a | grep virt command:
To enable a specific boolean, use the setsebool -P boolean_name on command as root. To disable a
boolean, use setsebool -P boolean_name off.
The following table lists virtualization-related booleans available in RHEL 8 and what they do when
enabled:
193
Red Hat Enterprise Linux 8 Configuring and managing virtualization
194
CHAPTER 17. INSTALLING AND MANAGING WINDOWS VIRTUAL MACHINES
For this purpose, the following sections provide information on installing and optimizing Windows VMs
on the host, as well as installing and configuring drivers in these VMs.
You can create a VM and install it using the virt-install command or the RHEL 8 web console.
Prerequisites
A Windows OS installation source, which can be one of the following, and be available locally or
on a network:
Procedure
1. Create the VM. For instructions, see Section 2.2, “Creating virtual machines”.
If using the virt-install utility to create the VM, add the following options to the command:
The storage medium with the KVM virtio drivers. For example:
--disk path=/usr/share/virtio-win/virtio-win.iso,device=disk,bus=virtio
The Windows version you will install. For example, for Windows 10:
--os-variant win10
For a list of available Windows versions and the appropriate option, use the following
command:
# osinfo-query os
If using the web console to create the VM, specify your version of Windows in the
Operating System field of the Create New Virtual Machine window. After the VM is
created and the guest OS is installed, attach the storage medium with virtio drivers to the
VM using the Disks interface. For instructions, see Section 10.3.7.3, “Attaching existing
disks to virtual machines using the web console”.
195
Red Hat Enterprise Linux 8 Configuring and managing virtualization
3. Configure KVM virtio drivers in the Windows guest OS. For details, see Section 17.2.1, “Installing
KVM paravirtualized drivers for Windows virtual machines”.
Additional resources
For information on further optimizing Windows VMs, see Section 17.2, “Optimizing Windows
virtual machines”.
Therefore, Red Hat recommends optimizing your Windows VMs by doing any combination of the
following:
Using paravirtualized drivers. For more information, see Section 17.2.1, “Installing KVM
paravirtualized drivers for Windows virtual machines”.
Enabling Hyper-V enlightenments. For more information, see Section 17.2.2, “Enabling Hyper-V
enlightenments”.
Configuring NetKVM driver parameters. For more information, see Section 17.2.3, “Configuring
NetKVM driver parameters”.
To do so:
1. Prepare the install media on the host machine. For more information, see Section 17.2.1.2,
“Preparing virtio driver installation media on a host machine”.
2. Attach the install media to an existing Windows VM, or attach it when creating a new Windows
VM.
3. Install the virtio drivers on the Windows guest OS. For more information, see Section 17.2.1.3,
“Installing virtio drivers on a Windows guest”.
Paravirtualized drivers enhance the performance of virtual machines (VMs) by decreasing I/O latency
and increasing throughput to almost bare-metal levels. Red Hat recommends that you use
paravirtualized drivers for VMs that run I/O-heavy tasks and applications.
virtio drivers are KVM’s paravirtualized device drivers, available for Windows VMs running on KVM hosts.
These drivers are provided by the virtio-win package, which includes drivers for:
196
CHAPTER 17. INSTALLING AND MANAGING WINDOWS VIRTUAL MACHINES
Video controllers
NOTE
For additional information about emulated, virtio, and assigned devices, refer to
Chapter 9, Managing virtual devices.
Using KVM virtio drivers, the following Microsoft Windows versions are expected to run similarly to
physical systems:
Windows Server versions: See Certified guest operating systems for Red Hat Enterprise Linux
with KVM in the Red Hat Knowledgebase.
To install KVM virtio drivers on a Windows virtual machine (VM), you must first prepare the installation
media for the virtio driver on the host machine. To do so, install the virtio-win package on the host
machine and use the .iso file it provides as storage for the VM.
Prerequisites
Procedure
b. Select the Product Variant relevant for your system architecture. For example, for Intel 64
and AMD64, select Red Hat Enterprise Linux for x86_64.
197
Red Hat Enterprise Linux 8 Configuring and managing virtualization
2. Install the virtio-win package from the download directory. For example:
If the installation succeeds, the virtio-win driver files are prepared in the /usr/share/virtio-win/
directory. These include ISO files and a drivers directory with the driver files in directories, one
for each architecture and supported Windows version.
# ls /usr/share/virtio-win/
drivers/ guest-agent/ virtio-win-1.9.9.iso virtio-win.iso
3. Use the virtio-win.iso file as a disk when creating a new Windows VM , or add the file as a disk to
an existing Windows VM.
Additional resources
When virtio-win.iso is attached as a disk to the Windows VM, you can proceed to installing the
virtio driver on the Windows guest operating system. For instructions, see Section 17.2.1.3,
“Installing virtio drivers on a Windows guest”.
To install KVM virtio drivers on a Windows guest operating system (OS), you must add a storage device
that contains the drivers - either when creating the virtual machine (VM) or afterwards - and install the
drivers in the Windows guest OS.
Prerequisites
The installation media for KVM drivers on a Windows virtual machine is prepared on the host
machine. For more information, see Section 17.2.1.2, “Preparing virtio driver installation media on
a host machine”.
A storage medium with the KVM virtio drivers must be attached to the Windows VM.
If you have not attached this medium when creating the VM , see Section 10.2.2, “Creating and
assigning storage for virtual machines using the CLI” for instructions.
Procedure
4. Based on the architecture of the VM’s vCPU, run one of the installers on the medium.
If using a 32-bit vCPU, run the virtio-win-gt-x86 installer.
198
CHAPTER 17. INSTALLING AND MANAGING WINDOWS VIRTUAL MACHINES
5. In the Virtio-win-guest-tools setup wizard that opens, follow the displayed instructions until
you reach the Custom Setup step.
6. In the Custom Setup window, select the device drivers you want to install. The recommended
driver set is selected automatically, and the descriptions of the drivers are displayed on the right
of the list.
199
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Verification
Additional resources
You can use the Microsoft Windows Installer (MSI) command-line interface (CLI) instead of the
graphical interface to install the drivers. For more information about MSI, see the Microsoft
documentation.
If you install the NetKVM driver, you may also need to configure the Windows guest’s networking
parameters. For instructions, see Section 17.2.3, “Configuring NetKVM driver parameters” .
The following sections provide information about the supported Hyper-V enlightenments and how to
enable them.
Hyper-V enlightenments provide better performance in a Windows virtual machine (VM) running in a
RHEL 8 host. For instructions on how to enable them, see the following.
200
CHAPTER 17. INSTALLING AND MANAGING WINDOWS VIRTUAL MACHINES
Procedure
1. Edit the XML configuration of the VM, adding the Hyper-V enlightenments. In the following
commands, replace $VMNAME with the name of the Windows VM.
2. Restart the VM
Verification
Use the virsh dumpxml command to display the XML configuration of the modified VM. If it
includes the following segments, the Hyper-V enlightenments are enabled on the VM.
<hyperv>
<relaxed state='on'/>
<vapic state='on'/>
<spinlocks state='on' retries='8191'/>
<vpindex state='on'/>
<runtime state='on' />
<synic state='on'/>
<stimer state='on'/>
<frequencies state='on'/>
</hyperv>
<clock offset='localtime'>
<timer name='hypervclock' present='yes'/>
</clock>
The following is a list of Hyper-V enlightenments with a description of the functionality of each
enlightenment:
Hyper-V enlightenments
clock
Defines the virtual time source and offset to use with the Windows virtual machine.
frequencies
Enables Hyper-V frequency Machine Specific Registers (MSRs).
relaxed
Disables a Windows sanity check that commonly results in a BSOD when the VM is running on a
heavily loaded host. This is similar to the Linux kernel option no_timer_check, which is automatically
enabled when Linux is running on KVM.
runtime
Specifies the virtual processor’s run time.
spinlock
201
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Used by a virtual machine’s operating system to notify the hypervisor that the calling virtual
processor is attempting to acquire a resource that is potentially held by another virtual
processor within the same partition.
Used by the hypervisor to indicate to the virtual machine’s operating system the number of
times a spinlock acquisition should be attempted before indicating an excessive spin
situation to the hypervisor.
synic
Together with stimer, activates the synthetic timer. Windows 8 uses this feature in periodic mode.
vapic
Provides accelerated MSR access to the high-usage, memory-mapped Advanced Programmable
Interrupt Controller (APIC) registers.
vpindex
Specifies the virtual processor’s index.
IMPORTANT
Modifying the driver’s parameters causes Windows to reload that driver. This interrupts
existing network activity.
Prerequisites
Procedure
b. Under the list of network adapters, double-click Red Hat VirtIO Ethernet Adapter. The
Properties window for the device opens.
a. Click the parameter you want to modify. Options for that parameter are displayed.
For information on the NetKVM parameter options, refer to Section 17.2.4, “NetKVM driver
202
CHAPTER 17. INSTALLING AND MANAGING WINDOWS VIRTUAL MACHINES
For information on the NetKVM parameter options, refer to Section 17.2.4, “NetKVM driver
parameters”.
Parameter Description 2
NOTE
The following table provides information on the configurable NetKVM driver initial parameters.
Parameter Description
203
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Parameter Description
Valid values are: 16, 32, 64, 128, 256, 512, and 1024.
Valid values are: 16, 32, 64, 128, 256, 512, and 1024.
204
CHAPTER 18. CREATING NESTED VIRTUAL MACHINES
In other words, a RHEL 8 host can run L1 virtual machines (VMs), and each of these VMs can host nested
L2 VMs.
It is possible to create nested VMs on multiple architectures, but Red Hat currently supports nested VMs
only on Intel systems. In contrast, nested virtualization on AMD, IBM POWER9 , and IBM Z systems is
only provided as a Technology Preview and is therefore unsupported.
Prerequisites
The hypervisor CPU must support nested virtualization. To verify, use the cat /proc/cpuinfo
command on the L0 hypervisor. If the output of the command includes the vmx and ept flags,
creating L2 VMs is possible. This is generally the case on Intel Xeon v3 cores and later.
# cat /sys/module/kvm_intel/parameters/nested
If the command returns 1, the feature is enabled, and you can start the Procedure below..
If the command returns 0 or N but your system supports nested virtualization, use the
following steps to enable the feature.
# modprobe -r kvm_intel
iii. The nesting feature is now enabled, but only until the next reboot of the L0 host. To
enable it permanently, add the following line to the /etc/modprobe.d/kvm.conf file:
Procedure
205
Red Hat Enterprise Linux 8 Configuring and managing virtualization
a. Open the XML configuration of the VM. The following example opens the configuration of
the Intel-L1 VM:
<cpu mode='host-passthrough'/>
If the VM’s XML configuration file already contains a <cpu> element, rewrite it.
2. Create an L2 VM within the L1 VM. To do this, follow the same procedure as when creating the
L1 VM.
WARNING
Prerequisites
The hypervisor CPU must support nested virtualization. To verify, use the cat /proc/cpuinfo
command on the L0 hypervisor. If the output of the command includes the svm and npt flags,
creating L2 VMs is possible. This is generally the case on AMD EPYC cores and later.
# cat /sys/module/kvm_amd/parameters/nested
If the command returns Y or 1, the feature is enabled, and you can start the Procedure
below..
If the command returns 0 or N, use the following steps to enable the feature.
# modprobe -r kvm_amd
206
CHAPTER 18. CREATING NESTED VIRTUAL MACHINES
iv. The nesting feature is now enabled, but only until the next reboot of the L0 host. To
enable it permanently, add the following to the /etc/modprobe.d/kvm.conf file:
Procedure
a. Open the XML configuration of the VM. The following example opens the configuration of
the AMD-L1 VM:
<cpu mode='host-passthrough'/>
If the guest’s XML configuration file already contains a <cpu> element, rewrite it.
2. Create an L2 VM within the L1 VM. To do this, follow the same procedure as when creating the
L1 VM.
WARNING
Prerequisites
The hypervisor CPU must support nested virtualization. To verify this is the case, use the cat
/proc/cpuinfo command on the L0 hypervisor. If the output of the command includes the sie
flag, creating L2 VMs is possible.
# cat /sys/module/kvm/parameters/nested
If the command returns Y or 1, the feature is enabled, and you can start the Procedure
below..
207
Red Hat Enterprise Linux 8 Configuring and managing virtualization
If the command returns 0 or N, use the following steps to enable the feature.
# modprobe -r kvm
iv. The nesting feature is now enabled, but only until the next reboot of the L0 host. To
enable it permanently, add the following line to the /etc/modprobe.d/kvm.conf file:
Procedure
Create an L2 VM within the L1 VM. To do this, follow the same procedure as when creating the
L1 VM.
WARNING
Prerequisites
An L0 RHEL8 host running an L1 VM. The L1 VM must be using RHEL 8 as the guest operating
system.
# cat /sys/module/kvm_hv/parameters/nested
If the command returns Y or 1, the feature is enabled, and you can start the Procedure
below..
If the command returns 0 or N, use the following steps to enable the feature:
208
CHAPTER 18. CREATING NESTED VIRTUAL MACHINES
# modprobe -r kvm
iv. The nesting feature is now enabled, but only until the next reboot of the L0 host. To
enable it permanently, add the following line to the /etc/modprobe.d/kvm.conf file:
Procedure
1. To ensure that the L1 VM can create L2 VMs, add the cap-nested-hv parameter to the machine
type of the L1 VM. To do so, use the virsh edit command to modify the L1 VM’s XML
configuration, and the following line to the <features> section:
<nested-hv state='on'/>
2. Create an L2 VM within the L1 VM. To do this, follow the same procedure as when creating the
L1 VM.
To significantly improve the performance of L2 VMs, Red Hat recommends adding the`cap-
nested-hv` parameter to the XML configurations of L2 VMs as well. For instructions, see the
previous step.
Additional information
Note that using IBM POWER8 as the architecture for the L2 VM currently does not work.
The L0 host must be an Intel, AMD, IBM POWER9, or IBM Z system. Nested virtualization
currently does not work on other architectures. In addition, Red Hat currently only supports Intel
as a host for nested virtual machines (VMs), and all other architectures are provided only as
Technology Previews.
For nested virtualization to be supported, you must run RHEL 8 on the L0 host and RHEL 7 or
RHEL 8 on the L1 VM. L2 VMs can contain any guest system supported by Red Hat .
In addition, on IBM POWER9, nested virtualization currently only works if both the host and the
L1 VM use RHEL 8, and if the L2 VM uses RHEL 8, or RHEL 7 with a rhel-alt kernel.
Use of L2 VMs as hypervisors and creating L3 guests has not been properly tested and is not
expected to work.
On AMD amd Intel systems, migrating L2 VMs does not work properly, and is not recommended
by Red Hat. However, on IBM Z systems, L2 VM migration is expected to work.
On an IBM Z system, huge-page backing storage and nested virtualization cannot be used at
209
Red Hat Enterprise Linux 8 Configuring and managing virtualization
On an IBM Z system, huge-page backing storage and nested virtualization cannot be used at
the same time.
Not all features available on the host are available to be utilized by the L1 hypervisor. For
example, IOMMU/VT-d or APICv cannot be used by the L1 hypervisor.
210
CHAPTER 19. FEATURE SUPPORT AND LIMITATIONS IN RHEL 8 VIRTUALIZATION
Features listed in Section 19.2, “Recommended features in RHEL 8 virtualization” have been tested and
certified by Red Hat to work with the KVM hypervisor on a RHEL 8 system. Therefore, they are fully
supported and recommended for use in virtualization in RHEL 8.
Features listed in Section 19.3, “Unsupported features in RHEL 8 virtualization” may work, but are not
supported and not intended for use in RHEL 8. Therefore, Red Hat strongly recommends not using
these features in RHEL 8 with KVM.
Section 19.4, “Resource allocation limits in RHEL 8 virtualization” lists the maximum amount of specific
resources supported on a KVM guest in RHEL 8. Guests that exceed these limits are not supported by
Red Hat.
In addition, unless stated otherwise, all features and solutions used by the documentation for RHEL 8
virtualization are supported. However, some of these have not been completely tested and therefore
may not be fully optimized.
IMPORTANT
Many of these limitations do not apply to other virtualization solutions provided by Red
Hat, such as Red Hat Virtualization (RHV) or Red Hat OpenStack Platform (RHOSP).
IBM POWER8
IBM POWER9
NOTE
211
Red Hat Enterprise Linux 8 Configuring and managing virtualization
NOTE
Q35 guests
The recommended machine type for KVM virtual machines is QEMU Q35, which emulates the
ICH9 chipset.
Additional resources
For information about unsupported guest OS types and features in RHEL 8 virtualization, see
Section 19.3, “Unsupported features in RHEL 8 virtualization” .
For information about the maximum supported amounts of resources that can be allocated to a
virtual machine, see Section 19.4, “Resource allocation limits in RHEL 8 virtualization” .
IMPORTANT
Many of these limitations may not apply to other virtualization solutions provided by Red
Hat, such as Red Hat Virtualization (RHV) or Red Hat OpenStack Platform (RHOSP).
Features supported by RHV 4.2 and onwards, or RHOSP 13 and onwards, are highlighted
as notes in the following document.
macOS
212
CHAPTER 19. FEATURE SUPPORT AND LIMITATIONS IN RHEL 8 VIRTUALIZATION
NOTE
For a list of guest operating systems supported on RHEL hosts, see Certified
guest operating systems for Red Hat Enterprise Linux with KVM.
NOTE
This feature is supported in RHV. For details, see Hot plugging VCPUs .
NOTE
This feature is supported in RHV but only on guest VMs running RHEL with
specific guest configurations. For details, see Hot Unplugging Virtual Memory .
I/O throttling
Configuring maximum input and output levels for operations on virtual disk, also known as I/O
throttling, is not supported in RHEL 8.
NOTE
This feature is supported in RHV. For details, see Storage quality of service .
This feature is supported in RHOSP. For details, see Setting Resource Limitation
on Disk and the Use Quality-of-Service Specifications section in the RHOSP
Storage Guide.
NOTE
This feature is supported in RHV. For details, see Overview of Live Storage
Migration.
This feature is also supported in RHOSP but with some limitations. For details,
see Migrate a Volume .
213
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Live snapshots
Creating or loading a snapshot of a running VM, also referred to as a live snapshot, is not
supported in RHEL 8.
In addition, note that non-live VM snapshots are deprecated in RHEL 8. Therefore, creating or
loading a snapshot of a shut-down VM is supported, but Red Hat recommends not using it.
NOTE
This feature is supported in RHV with some limitations. For details, see Live
snapshots in Red Hat Virtualization.
This feature is supported in RHOSP. For details, see Importing virtual machines
into the overcloud.
Vhost-user
RHEL 8 does not support the implementation of a user-space vHost interface.
NOTE
This feature is supported in RHOSP, but only for virtio-net interfaces. For details,
see virtio-net implementation and vhost user ports.
NOTE
NOTE
This feature is supported in RHV. For details, see Cluster support on RHV guests .
virtio-crypto
The drivers for the virtio-crypto device are available in the RHEL 8 kernel, and the device can
thus be enabled on a KVM hypervisor under certain circumstances. However, using the virtio-
crypto device in RHEL 8 is not supported and its use is therefore highly discouraged.
NOTE
Additional resources
214
CHAPTER 19. FEATURE SUPPORT AND LIMITATIONS IN RHEL 8 VIRTUALIZATION
For information about supported guest OS types and recommended features in RHEL 8
virtualization, see Section 19.2, “Recommended features in RHEL 8 virtualization” .
For information about the maximum supported amounts of resources that can be allocated to a
VM, see Section 19.4, “Resource allocation limits in RHEL 8 virtualization” .
IMPORTANT
Many of these limitations do not apply to other virtualization solutions provided by Red
Hat, such as Red Hat Virtualization (RHV) or Red Hat OpenStack Platform (RHOSP).
Each PCI bridge adds a new bus, potentially enabling another 256 device addresses. However,
some buses do not make all 256 device addresses available for the user; for example, the root
bus has several built-in devices occupying slots.
215
Red Hat Enterprise Linux 8 Configuring and managing virtualization
Additional sources
For a complete list of unsupported features of virtual machines in RHEL 8, see Section 19.3,
“Unsupported features in RHEL 8 virtualization”.
For details on the specifics for virtualization on the IBM Z architecture, see Section 4.2, “How
virtualization on IBM Z differs from AMD64 and Intel 64”.
For details on the specifics for virtualization on the IBM POWER architecture, see Section 3.2,
“How virtualization on IBM POWER differs from AMD64 and Intel 64”.
216