Oracle Linux KVM Guide
Oracle Linux KVM Guide
F29966-32
December 2024
Oracle Linux KVM User's Guide,
F29966-32
iii
Oracle Linux 7: Install Virtualization Packages 2-9
Validate Host System 2-10
Switch KVM Stacks 2-10
Oracle Linux 9: Switch KVM Stacks 2-11
Switch Default Stack to Oracle KVM Stack 2-11
Switch Oracle KVM Stack to Default Stack 2-12
Oracle Linux 8: Switch KVM Stacks 2-12
Switch Default Stack to Oracle KVM Stack 2-13
Switch Oracle KVM Stack to Default Stack 2-14
Upgrade the Oracle KVM Stack 2-15
Oracle Linux 7: Switch KVM Stacks 2-16
Switch Default Stack to Oracle KVM Stack 2-16
Switch Oracle KVM Stack to Default Stack 2-17
iv
KVM Network Configuration 5-5
Overview: Virtual Networking 5-6
Command Usage: Manage Virtual Network 5-7
Command Usage: Add or Remove vNIC 5-9
Bridged Networking: Setup 5-10
Setup Guidelines: Bridged Network 5-10
Create: Bridge Network Connection 5-12
Bonded Interfaces for Increased Throughput 5-13
PCIe Passthrough: Setup 5-14
Create: Direct PCIe Passthrough Connection 5-14
Setup Guidelines: SR-IOV PCIe Passthrough 5-17
Create: SR-IOV PCIe Passthrough Connection 5-17
KVM Storage Configuration 5-23
Storage Pools: Create and Manage 5-24
Creating a Storage Pool 5-25
Creating a Storage Pool from XML 5-26
Removing a Storage Pool 5-27
Storage Volumes: Create and Manage 5-27
Creating a Storage Volume 5-28
Creating a Storage Volume from XML 5-29
Cloning a Storage Volume 5-29
Resizing a Storage Volume 5-30
Deleting a Storage Volume 5-30
Virtual Disks: Create and Manage 5-30
Attaching a Virtual Disk to an Existing VM 5-31
Attaching a Virtual Disk when Creating a VM 5-31
Detaching a Virtual Disk 5-32
Resizing a Virtual Disk 5-32
KVM Memory and CPU Allocation Configuration 5-33
Command Usage: Set Virtual CPU Count 5-33
Command Usage: Allocate Memory 5-34
v
Preface
Preface
Oracle Linux: KVM User's Guide provides information about how to install, configure, and use
the Oracle Linux KVM packages to run guest system on top of a bare metal Oracle Linux
system. This documentation provides information on using KVM on a standalone platform in an
unmanaged environment. Typical usage in this mode is for development and testing purposes,
although production level deployments are supported. Oracle recommends that customers use
Oracle Linux Virtualization Manager for more complex deployments of a managed KVM
infrastructure.
Documentation License
The content in this document is licensed under the Creative Commons Attribution–Share Alike
4.0 (CC-BY-SA) license. In accordance with CC-BY-SA, if you distribute this content or an
adaptation of it, you must provide attribution to Oracle and retain the original copyright notices.
Conventions
The following text conventions are used in this document:
Convention Meaning
boldface Boldface type indicates graphical user interface
elements associated with an action, or terms
defined in text or the glossary.
italic Italic type indicates book titles, emphasis, or
placeholder variables for which you supply
particular values.
monospace Monospace type indicates commands within a
paragraph, URLs, code in examples, text that
appears on the screen, or text that you enter.
Documentation Accessibility
For information about Oracle's commitment to accessibility, visit the Oracle Accessibility
Program website at https://www.oracle.com/corporate/accessibility/.
vi
Preface
vii
1
Deployment Overview: Oracle Linux KVM
For a high-level overview of the Kernel-based Virtual Machine (KVM) deployment options,
operating requirements, and virtualization package descriptions, see these topics:
• KVM Management: Deployment Options
• KVM Guest: Operating Systems
• KVM Host: System Requirements
• KVM Virtualization Packages: Recommended
• KVM Repositories and Channels: Yum and ULN
1-1
Chapter 1
KVM Management: Deployment Options
Note:
For UEK users,
also see the kernel
version release
notes to obtain
more information
about the KVM
features and any
known issues that
might apply. For
these type of
details, see the
Unbreakable
Enterprise Kernel
documentation.
Note:
As an alternative to
using the
command-line
interface to
manage KVM
instances on a
host, the Cockpit
web console
provides a
graphical interface
to interact with
KVM and
libvirtd. For
more details about
setting up VMs on
a system using the
Cockpit web
console interface,
see Oracle Linux:
Using the Cockpit
Web Console.
Managed KVM Server Virtualization This KVM option is for enterprise or clustered
KVM deployment environments on Oracle
Linux. For these KVM environments, consider
using Oracle Linux Virtualization Manager
which is a server virtualization management
platform.
Using Oracle Linux Virtualization Manager's
administration or virtual machine (VM) portals,
you can configure, monitor, and manage an
1-2
Chapter 1
KVM Guest: Operating Systems
Note:
Oracle Linux ISO images and disk images are available for download from Oracle
Software Delivery Cloud: https://edelivery.oracle.com/linux.
1-3
Chapter 1
KVM Guest: Operating Systems
Table footnote:
• *cloud-init is unavailable for 32-bit architectures.
Caution:
Microsoft Windows 8 is no longer supported by Microsoft. See https://
docs.microsoft.com/en-us/lifecycle/products/windows-8 for more information.
Microsoft Windows 8.1 falls out of extended support by Microsoft in January 2023.
See https://docs.microsoft.com/en-us/lifecycle/products/windows-81 for more
information.
1-4
Chapter 1
KVM Guest: Operating Systems
Oracle Solaris version 11.4 Oracle Solaris 11.4 can be used as a guest
operating system when installed within a
standalone instance of KVM.
Note:
Oracle Solaris
version 11.4.33
(Oracle Solaris 11.4
SRU 33) is the
minimum version
that includes
functionality for
VirtIO guest
support.
Special Considerations:
1-5
Chapter 1
KVM Host: System Requirements
For best results when using Oracle Solaris as a guest operating system, follow these
recommendations:
• Use at least a two-core configuration for the Oracle Solaris VM.
• Use the most current QEMU system type (Custom Emulated Machine = pc-i440fx-4.2) for
the Oracle Solaris VM.
Bare metal host KVM can be used when it's run on a bare
metal host. Note that nested virtualization
scenarios aren't supported for KVM
deployments.
1-6
Chapter 1
KVM Virtualization Packages: Recommended
Package Description
1-7
Chapter 1
KVM Virtualization Packages: Recommended
Package Description
Note:
Note that the
Cockpit web
console also
provides a
graphical interface
to interact with
KVM and libvirtd
to set up and
configure VMs on
a system. See
Oracle Linux:
Using the Cockpit
Web Console for
more information.
Install example:
1-8
Chapter 1
KVM Virtualization Packages: Recommended
Package Description
Install example:
The command syntax to display the details of what a group package installs is as follows:
For instructions on how to install virtualization on Oracle Linux 7, Oracle Linux 8, and Oracle
Linux 9, see Install Virtualization Packages.
1-9
Chapter 1
KVM Repositories and Channels: Yum and ULN
• https://www.linux-kvm.org/page/Main_Page
• https://libvirt.org/
• https://www.qemu.org/
Note:
Unlike Oracle Linux 8, the packages for Oracle Linux 9 aren't released as part of a
DNF module.
1-10
Chapter 1
KVM Repositories and Channels: Yum and ULN
Table 1-4 (Cont.) Oracle Linux 9: Repository Files and Channel Names
N
o
t
e
:
Y
o
u
m
u
s
t
r
e
m
o
v
e
a
l
l
e
x
i
s
t
i
n
g
v
i
1-11
Chapter 1
KVM Repositories and Channels: Yum and ULN
Table 1-4 (Cont.) Oracle Linux 9: Repository Files and Channel Names
r
t
u
a
l
i
z
a
t
i
o
n
p
a
c
k
a
g
e
s
b
e
f
o
r
e
e
n
a
b
l
i
n
g
t
h
i
s
c
h
a
n
n
e
l
o
r
r
e
p
o
s
i
t
1-12
Chapter 1
KVM Repositories and Channels: Yum and ULN
Table 1-4 (Cont.) Oracle Linux 9: Repository Files and Channel Names
o
r
y
.
Special Considerations
• Default KVM Stack – Because the Application Stream repository or channel is a system
software requirement on Oracle Linux, it's enabled by default on Oracle all Linux 9
systems. Therefore the Default KVM Stack can be installed without changing any
repository or channel configuration.
• Oracle KVM Stack – For ULN users, subscribe to the virtualization ULN channels after
registering the Oracle Linux system with ULN and then install virtualization packages. For
yum repository users enable the yum repository and then install virtualization packages.
For more details, see Oracle Linux 9: Enable Yum Repositories or Oracle Linux 9:
Subscribe to ULN Channels.
Note:
If the system is running UEK, you can choose to switch between stacks. For
more details, see Switch KVM Stacks.
1-13
Chapter 1
KVM Repositories and Channels: Yum and ULN
Table 1-5 (Cont.) Oracle Linux 8: Repository Files and Channel Names
Special Considerations
• Default KVM Stack – Because the Application Stream repository or channel is a system
software requirement on Oracle Linux, it's enabled by default on Oracle all Linux 8
systems. Therefore the Default KVM Stack can be installed without changing any
repository or channel configuration.
• Oracle KVM Stacks – For ULN users, subscribe to the virtualization ULN channels after
registering the Oracle Linux system with ULN and then install virtualization packages. For
yum repository users, enable the yum repository and then install virtualization packages.
1-14
Chapter 1
KVM Repositories and Channels: Yum and ULN
For more details, see Oracle Linux 8: Enable Yum Repositories or Oracle Linux 8:
Subscribe to ULN Channels.
• Note:
If the system is running UEK, you can choose to switch between stacks. For
more details, see Switch KVM Stacks.
WARNING:
Oracle Linux 7 is now in Extended Support. See Oracle Linux Extended Support and
Oracle Open Source Support Policies for more information.
Migrate applications and data to Oracle Linux 8 or Oracle Linux 9 as soon as
possible.
The following tables provide a list of Oracle Linux 7 Yum repositories and ULN channels that
you can use for KVM deployment.
Note:
Because of the availability of different kernel versions and the requirement for more
updated versions of user space tools, several different versions of Yum repositories
and ULN channels are available for use. Packages for each channel have different
use cases and different levels of support.
Table 1-6 Oracle Linux 7 x86_64 Platforms: YUM Repository Files and ULN Channel
Names
1-15
Chapter 1
KVM Repositories and Channels: Yum and ULN
Table 1-6 (Cont.) Oracle Linux 7 x86_64 Platforms: YUM Repository Files and ULN
Channel Names
1-16
Chapter 1
KVM Repositories and Channels: Yum and ULN
Table 1-6 (Cont.) Oracle Linux 7 x86_64 Platforms: YUM Repository Files and ULN
Channel Names
1-17
Chapter 1
KVM Repositories and Channels: Yum and ULN
Table 1-7 Oracle Linux 8 64-bit Arm Platforms: Yum Repository Files and ULN Channel
Names
1-18
2
Installation: Oracle Linux KVM
The process to install the KVM user space packages on Oracle Linux involves these steps:
1. Enable the yum repositories or subscribe to the ULN channels.
Important:
This step is only required when using the Oracle KVM Stack. The Default KVM
Stack is available in the standard core system repositories.
For more details on which sources include the Default KVM Stack or the Oracle KVM
Stack, see KVM Repositories and Channels: Yum and ULN.
For details on how to enable a repository or subscribe to a ULN channel, see Enable Yum
Repositories or Subscribe to ULN Channels.
2. Install the virtualization packages on an existing system running Oracle Linux.
For more details, see Install Virtualization Packages.
3. (Optional - UEK system users only) Switch the KVM stack between the Default KVM Stack
and the Oracle KVM Stack.
For more details, see Switch KVM Stacks.
Note:
The Default KVM Stack is available in the core system repositories and can be
installed without enabling any other repositories. If the Oracle KVM Stack is already
installed and you intend to switch KVM stacks, see Switch KVM Stacks for more
details.
2-1
Chapter 2
Enable Yum Repositories
2. Enable the Oracle Linux 9 yum repositories, by running the dnf config-manager
command:
3. Proceed to the topic for installing the virtualization packages (Install Virtualization
Packages).
2. Enable the Oracle Linux 8 yum repository, by running the dnf config-manager
command:
3. After enabling the Oracle Linux 8 KVM appstream repository, proceed to the topic for
installing the virtualization packages (Install Virtualization Packages).
2-2
Chapter 2
Enable Yum Repositories
WARNING:
Oracle Linux 7 is now in Extended Support. See Oracle Linux Extended Support and
Oracle Open Source Support Policies for more information.
Migrate applications and data to Oracle Linux 8 or Oracle Linux 9 as soon as
possible.
The Default KVM Stack is available in the standard yum repositories on an Oracle Linux 7
system. To use the Oracle KVM Stack, the ol7_kvm_utils yum repository must be enabled
before installing the virtualization packages.
What Do You Need?
• Ensure that the system meets the virtualization package requirements, see KVM Host:
System Requirements and Oracle Linux 7: Yum Repositories and ULN Channels .
• Ensure that UEK R4, UEK R5, or UEK R6 is installed and running on the system.
• Administrator privileges.
Steps
Follow these steps to enable an Oracle Linux repository.
1. Install or update the release package:
[ol7_kvm_utils]
name=Oracle Linux $releasever KVM Utilities ($basearch)
baseurl=https://yum$ociregion.$ocidomain/repo/OracleLinux/OL7/kvm/
utils/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
3. (Optional) To prevent yum from installing unwanted package versions from a particular
repository, set an exclude option using the yum-config-manager command.
2-3
Chapter 2
Subscribe to ULN Channels
For example, to prevent yum from installing unwanted virtualization packages that are
included in the ol7_developer_EPEL repository, you would type:
4. Proceed to the topic for installing the virtualization packages (Install Virtualization
Packages).
Note:
A ULN channel subscription isn't required when installing the Default KVM Stack.
2-4
Chapter 2
Subscribe to ULN Channels
WARNING:
Oracle Linux 7 is now in Extended Support. See Oracle Linux Extended Support and
Oracle Open Source Support Policies for more information.
Migrate applications and data to Oracle Linux 8 or Oracle Linux 9 as soon as
possible.
The Default KVM Stack is available in the standard ULN channels on an Oracle Linux 7
system. To use the Oracle KVM Stack, the appropriate ol7_<arch>_kvm_utils ULN channel
must be enabled before installing the virtualization packages.
What Do You Need?
• A registered ULN Oracle Linux 7 server. For details on how to register an Oracle Linux 7
server with ULN, see Oracle Linux: Unbreakable Linux Network User's Guide for Oracle
Linux 6 and Oracle Linux 7.
2-5
Chapter 2
Install Virtualization Packages
• Ensure that the system meets the virtualization package requirements, see KVM Host:
System Requirements and Oracle Linux 7: Yum Repositories and ULN Channels .
• Ensure that UEK R4, UEK R5, or UEK R6 is installed and running on the system.
• ULN user account credentials (username and password).
Steps
To subscribe to ULN channels, follow these steps:
1. Sign in to https://linux.oracle.com with the ULN username and password.
2. On the Systems tab, from the list of registered systems, select the link name for the
specified system.
3. On the System Details page, select Manage Subscriptions.
4. On the System Summary page, select the required ol7_<arch>_kvm_utils channel from
the Available Channels list, then click the right-arrow to move selected channels to the
Subscribed Channels list.
5. Click Save Subscriptions.
Note:
To install the Default KVM Stack, you don't need to enable any repositories
or subscribe to any other ULN channels.
2-6
Chapter 2
Install Virtualization Packages
3. Install the latest available base virtualization packages and other utilities:
• To install the Default KVM Stack:
• To install the Oracle KVM Stack, first remove any existing virtualization packages and
then install the packages as usual:
4. (Recommended) Reboot the system to ensure that the virtualization packages and utilities
were updated.
Note:
After performing a system update, reboot the system to ensure that the system
restarts with the latest packages.
5. Start, enable, or check the service of the libvirtd service. See Libvirtd Service:
Management Tasks for instructions.
Note:
Before you can create and manage KVM instances, the libvirtd service must be
started and enabled.
6. Verify that the system can act as act as a virtual host. See Validate Host System
7. After verifying that the system can act as a virtual host, you can proceed to KVM
Instances: Create and Manage.
2-7
Chapter 2
Install Virtualization Packages
Note:
To install the Default KVM Stack, you don't need to enable any repositories
or subscribe to any other ULN channels.
– The host system must be running the latest UEK R6 or UEK R7.
Steps
Follow these steps to install the virtualization packages on an Oracle Linux 8 system.
1. Log in to the Oracle Linux 8 system.
2. Ensure that the latest packages are installed on the system:
• To install the Oracle KVM Stack, install the module stream that you want to use. For
example, to install the latest stream:
4. (Recommended) Reboot the system to ensure that the virtualization packages and utilities
were updated.
Note:
After performing a system update, reboot the system to ensure that the system
restarts with the latest packages.
5. Start, enable, or check the service of the libvirtd service. See Libvirtd Service:
Management Tasks for instructions.
Note:
Before you can create and manage KVM instances, the libvirtd service must be
started and enabled.
6. Verify that the system can act as act as a virtual host. See Validate Host System for
instructions.
7. After verifying that the system can act as a virtual host, proceed to KVM Instances: Create
and Manage.
2-8
Chapter 2
Install Virtualization Packages
WARNING:
Oracle Linux 7 is now in Extended Support. See Oracle Linux Extended Support and
Oracle Open Source Support Policies for more information.
Migrate applications and data to Oracle Linux 8 or Oracle Linux 9 as soon as
possible.
The following information describes how to install the virtualization packages on an Oracle
Linux 7 system.
What Do You Need?
• Administrator privileges.
• To install the Oracle KVM Stack, the following requirements must be met:
– Yum repository must be enabled or the ULN channel must be subscribed. See Enable
Yum Repositories or Subscribe to ULN Channels for instructions.
Note:
To install the Default KVM Stack, you don't need to enable any repositories
or subscribe to any other ULN channels.
– The host system must be running the latest UEK R4, UEK R5, or UEK R6.
Steps
Follow these steps to install the virtualization packages on an Oracle Linux 7 system.
1. Log in to the Oracle Linux 7 system.
2. Ensure that the latest packages are installed on the system:
3. Install the latest available base virtualization packages and other utilities:
4. (Recommended) Restart the system to ensure that the packages and utilities were
updated.
Note:
After performing a system update, reboot the system to ensure that the system
restarts with the latest packages.
2-9
Chapter 2
Switch KVM Stacks
5. Start, enable, or check the service of the libvirtd service. See Libvirtd Service:
Management Tasks for instructions.
Note:
Before you can create and manage KVM instances, the libvirtd service must be
started and enabled.
6. Verify that the system can act as act as a virtual host. See Validate Host System for
instructions.
7. After verifying that the system can act as a virtual host, proceed to KVM Instances: Create
and Manage.
If all checks return a PASS value, the system can host guest VMs. If any of the tests fail, a
reason is provided and information is displayed on how to resolve the issue, if such an
option is available.
Note:
If the following message is displayed, the system isn't capable of functioning as a
KVM host:
If you try to create or start a VM on a host where this message is displayed, the
action is likely to fail.
2-10
Chapter 2
Switch KVM Stacks
The Oracle KVM Stack, which includes more KVM features than the default stack, requires
UEK to be running on the host system and that the system is subscribed to the appropriate
yum repositories or ULN channels.
Switching the KVM stack on an Oracle Linux system involves removing one version of the
KVM stack and then replacing it with another version of the KVM stack.
Caution:
Guests instances that were created by using one KVM stack might not be compatible
and might not start after switching to another KVM stack.
For more details on how UEK users can switch between the KVM stacks, see these topics:
• Oracle Linux 9: Switch KVM Stacks
• Oracle Linux 8: Switch KVM Stacks
• Oracle Linux 7: Switch KVM Stacks
Note:
For details about the KVM stacks included in virtualization packages from a yum
repository or ULN channel, see KVM Repositories and Channels: Yum and ULN.
Caution:
Guests instances that were created by using the default KVM stack might not be
compatible and might not start after switching to the Oracle KVM stack.
2-11
Chapter 2
Switch KVM Stacks
1. Remove any packages from the existing Default KVM Stack, for example:
Caution:
Guest instances that were created by using the Oracle KVM Stack might not be
compatible and might not start after switching to the Default KVM Stack.
2-12
Chapter 2
Switch KVM Stacks
Caution:
Guests instances that were created by using the Default KVM Stack might not be
compatible and might not start after switching to the Oracle KVM Stack.
Note:
Oracle Linux 8 virtualization stacks are managed by switching between
application streams for the virt module. For more information about using DNF
modules and application streams, see Oracle Linux: Managing Software on
Oracle Linux
2. Reset the virt module state so that it's neither enabled nor disabled:
2-13
Chapter 2
Switch KVM Stacks
6. Install the base packages from the appropriate module and stream. For example, to use
the latest packages:
Caution:
Guest instances that were created by using the Oracle KVM Stack might not be
compatible and might not start after switching to the Default KVM Stack.
Note:
Oracle Linux 8 virtualization stacks are managed by switching between
application streams for the virt module. For more information about using DNF
modules and application streams, see Oracle Linux: Managing Software on
Oracle Linux.
2. Reset the virt module state so that it's neither enabled nor disabled:
2-14
Chapter 2
Switch KVM Stacks
Caution:
Guest instances that were created by using an earlier Oracle KVM Stack stream
might not be compatible and might not start after switching to the later version of the
Oracle KVM Stack.
Note:
Oracle Linux 8 virtualization stacks are managed by switching between
application streams for the virt module. For more information about using DNF
modules and application streams, see Oracle Linux: Managing Software on
Oracle Linux.
2. Reset the virt module state so that it's neither enabled nor disabled:
2-15
Chapter 2
Switch KVM Stacks
3. Enable the latest module and stream. For example, to enable virt:kvm_utils3:
5. Install the later version of the Oracle KVM Stack packages. For example, to install the
packages from virt:kvm_utils3:
WARNING:
Oracle Linux 7 is now in Extended Support. See Oracle Linux Extended Support and
Oracle Open Source Support Policies for more information.
Migrate applications and data to Oracle Linux 8 or Oracle Linux 9 as soon as
possible.
For instructions on how to switch KVM stacks on Oracle Linux 7 systems with UEK, see these
topics:
• Switch Default Stack to Oracle KVM Stack
• Switch Oracle KVM Stack to Default Stack
Caution:
Guest instances that were created by using the Default KVM Stack might not be
compatible and might not start after switching to the Oracle KVM Stack.
2-16
Chapter 2
Switch KVM Stacks
1. Remove any packages from the existing Default KVM Stack, for example:
Caution:
Guests instances that were created by using the Oracle KVM Stack might not be
compatible and might not start after switching to the Default KVM stack.
2-17
3
Libvirtd Service: Management Tasks
For instructions on how to start, enable, or check the status of the libvirtd service, see these
topics:
• Oracle Linux 9: Manage the Libvirtd Service
• Oracle Linux 8: Manage the libvirtd Service
• Oracle Linux 7: Manage the libvirtd Service
You don't need to start the service for each daemon, as the service is automatically started
when the first socket is established.
Note:
For legacy systems, the libvirtd socket is available for use to manage remote
virtual guest connections.
3-1
Chapter 3
Oracle Linux 9: Manage the Libvirtd Service
If connections from remote hosts are needed, the virtproxyd daemon must be
enabled and started:
The output identifies all enabled units and their current status.
Note:
When the virt$[DRIVER]d daemon is managed by systemd other features are
also available, most notably socket activation. For more information about the
use of modular sockets and systemd integration, see https://libvirt.org/
daemons.html#modular-sockets.
3-2
Chapter 3
Oracle Linux 8: Manage the libvirtd Service
By default, the traditional monolithic daemon, known as libvirtd is configured when you
update from Oracle Linux 8 to Oracle Linux 9. The libvirtd daemon controls a wide
variety of virtualization drivers by using a single configuration file (/etc/libvirt/
libvirtd.conf). In some instances, system resources might be used inefficiently when
using the libvirtd centralized configuration. Therefore, we recommend that Oracle Linux
9 users switch to the modular libvirt driver daemons. For instructions, see https://
libvirt.org/daemons.html#switching-to-modular-daemons
For general information about the usage of libvirt daemons, see https://libvirt.org/
daemons.htmlj.
The output indicates whether the libvirtd daemon is running, as shown in the following
example output:
3-3
Chapter 3
Oracle Linux 7: Manage the libvirtd Service
WARNING:
Oracle Linux 7 is now in Extended Support. See Oracle Linux Extended Support and
Oracle Open Source Support Policies for more information.
Migrate applications and data to Oracle Linux 8 or Oracle Linux 9 as soon as
possible.
The following information describes how to start, enable, and check the status of the libvirtd
service.
What Do You Need?
• Virtualization packages installed on host system. See Install Virtualization Packages for
details.
• Administrator privileges.
Steps
Follow these steps to start and enable the libvirtd service:
The output indicates whether the libvirtd daemon is running, as shown in the following
example output:
3-4
4
KVM Instances: Create and Manage
To create and manage KVM instances from the CLI, see the following topics.
• KVM Instances: Hardware Configuration
• Add Watchdog Device to KVM Instance
• Add vTPM Security to KVM Instance
• KVM Memory and CPU Allocation Configuration
• KVM Storage Configuration
• Overview: Virtual Networking
Note:
To create and manage KVM instances using a graphical user interface (GUI), see the
Virtual Machines Management Tasks topics in the Oracle Linux: Using the Cockpit
Web Console. Additionally, you can choose to manage a virtual machine environment
by using the Oracle VM Manager. For more details about using the VM Manager, see
Oracle Linux Virtualization Manager documentation.
4-1
Chapter 4
Create: KVM Instance
1. To create a virtual machine, use the virt-install command and its options to define the
resources required. For example:
Virtual Machine Creation: Options
virt-install \
--name [unique-virtual-machine-name]
--memory [allocated-MiB-memory-size]
--vcpus [integer-vcpus-value-for-guest]
--location [installation-source-path]
--disk [type-and-size]
--os-variant=[os-verison]
--network [default]
--graphics [none]
Note:
For a complete list of virt-install options, see the virt-install(1) man
page. Or, for a quick list of virt-install options, type: virt-install --
help.
Where:
--disk /storage-pool-path/volume-
path,size=#
4-2
Chapter 4
Create: KVM Instance
--disk=/iso-images/ol8-
dvd.iso,device=cdrom
Special considerations:
• If a path isn't specified the disk image is
automatically created as a qcow file
format.
• If virt-install is run as root, the
disk image is created in /var/lib/
libvirt/images/ and is named using
the name specified for the VM at install.
• If virt-install is run as an ordinary
user, the disk image is created
in $HOME/.local/share/libvirt/
images/
Note:
For a list other source installation
options, see the virt-install
(1)– Linux man page.
4-3
Chapter 4
Create: KVM Instance
Based on the virt-install options specified, the virtual machine is created and the guest
OS is automatically installed.
Virtual Machine Creation Examples: See Virt-Install: Command Line Examples
2. After creating the virtual machine, you can:
a. Start the virtual machine.
For details, see KVM: Start Instance.
b. Connect to the virtual machine.
virt-install \
--name ol9-guest-demo --memory 16384 --vcpus 16 --disk size=280 \
--os-variant ol9.0 --location ol9.iso \
--graphics none --extra-args='console=ttyS0'
Description: Creates a KVM instance named ol9-guest-demo using an ol9.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. Note that this guest
installation example might be useful when connecting to a host over a slow network link.
• Scenario: URL installation tree path - automated Kickstart install.
virt-install \
--graphics vnc \
--name ol9-guest-demo1 --memory 2048 --vcpus 2 --disk size=160 \
--os-variant ol9.0 --location http://example.com/OS-install \
--initrd-inject /home/uniquename/ks.cfg --extra-args="inst.ks=file:/
ks.cfg console=tty0 console=ttyS0,115200n8"
4-4
Chapter 4
Clone: Existing KVM Instance
%packages
-kernel
kernel-64k
%end
These lines ensure that the kickstart file, depicted in the ol9-guest-demo1 scenario, installs
the kernel-64k package.
virt-install \
--name ol8-guest-demo --memory 4096 --vcpus 4 \
--disk none --livecd --os-variant ol8.0 \
--cdrom /home/uniquename/Downloads/ol8.iso
virt-install \
--name ol7-guest-demo --memory 2048 --vcpus 2 \
--os-variant ol7.0 --import \
--disk /home/uniquename/backup/disk.qcow2
4-5
Chapter 4
Clone: Existing KVM Instance
Note:
When creating multiple clones from a single KVM instance, we recommend preparing
the source configuration before cloning it. Preparing the source configuration lets you
examine the configuration and remove unique parameters that would not apply to the
clone configuration and cause the clone to possibly fail or not work correctly.
For instructions on how to prepare a KVM instance for cloning or create a KVM clone, see
these topics:
• Prepare KVM for Cloning: Using virt-sysprep
• Prepare KVM for Cloning: Manually
• Create a KVM Clone Using virt-clone Command
Note:
In addition to using the CLI to create KVM clones, you can use the Cockpit web
console to clone KVM instances. For details, see Cloning VMs in Oracle Linux: Using
the Cockpit Web Console.
Note:
The virt-sysprep tool helps you to prepare a KVM configuration for cloning by
removing SSH host keys, persistent network configurations, and user accounts on
the disk image. It also lets you add SSH keys, users, or logos. For more details about
virt-sysprep, see https://libguestfs.org/virt-sysprep.1.html.
4-6
Chapter 4
Clone: Existing KVM Instance
1. Log in as the root owner of the KVM disk image, for example:
whoami
root
2. To prepare the source KVM disk image for cloning, use the following virt-sysprep command
syntax.
Where:
• [/var/lib/libvirt/images/replace me-my-kvm.qcow2] replace with the source KVM disk
image path.
3. Use the virt-sysprep tool to inspect the prepared disk image. For a list of available
options, type: virt-sysprep --help
For more details, see the virt-sysprep(1) Linux man page.
4. After preparing the disk image for cloning, proceed with using the prepared KVM disk
configuration to create a clone.
For details, see Create a KVM Clone Using virt-clone Command.
Note:
On the first boot of the clone, we recommend that you change the hostname.
4-7
Chapter 4
Clone: Existing KVM Instance
• Configure any required properties that are considered non-unique for the operating
system or system applications.
2. Remove the network configuration, as follows:
a. To remove any persistent udev rules, type:
rm -f /etc/udev/rules.d/70-persistent-net.rules
Note:
If you don't remove the udev rules, the name of the first NIC might be
eth1instead of eth0.
DEVICE=eth[x]
BOOTPROTO=none
ONBOOT=yes
#NETWORK=10.0.1.0 <- REMOVE
#NETMASK=255.255.255.0 <- REMOVE
#IPADDR=10.0.1.20 <- REMOVE
#HWADDR=xx:xx:xx:xx:xx <- REMOVE
#USERCTL=no <- REMOVE
After modification, the file must not include a HWADDR entry or any unique information,
and at a minimum include the following lines:
DEVICE=eth[x]
ONBOOT=yes
Important:
You must remove the HWADDR entry because if its address doesn't match the
new guest's MAC address, the ifcfg is ignored.
c. If the following files exist, ensure they have the same content:
• /etc/sysconfig/networking/profiles/default/ifcfg-eth[x]
• /etc/sysconfig/networking/devices/ifcfg-eth[x]
Note:
If NetworkManager was used or any special settings with the KVM, ensure
that all unique information is removed from the ifcfg scripts.
4-8
Chapter 4
Clone: Existing KVM Instance
For example, if the KVM guest from which you want to create a clone is registered with
ULN, you must unregister it. For more information, see the applicable reference:
• Oracle Linux 7: Oracle Linux: Unbreakable Linux Network User's Guide for Oracle
Linux 6 and Oracle Linux 7
• Oracle Linux 8 and Oracle Linux 9: Oracle Linux: Managing Software on Oracle Linux
4. Remove sshd public/private key pairs.
For example, type:
rm -rf /etc/ssh/ssh_host_[name]
• For Oracle Linux 8 and 9, remove the gnome-initial-setup-done file to configure the
KVM to run the configuration wizard on the next boot:
# rm ~/.config/gnome-initial-setup-done
7. After addressing all required modifications, proceed to using the prepared KVM
configuration to create a clone.
For details, see Create a KVM Clone Using virt-clone Command.
Note:
On the first boot of the clone we recommend that you change the hostname.
Steps
Follow these steps to clone an existing KVM instance:
4-9
Chapter 4
View: KVM Instances, Status, and Configuration
In this example, the virt-clone command copies the source My-KVM configuration
and creates: (1) a clone KVM guest named My_KVM-clone, and (2) a clone disk
image named My_KVM-clone.qcow2
-OR-
• To clone a source KVM using the virt-clone command with other options, type the
following command to view the available configuration options:
virt-clone --help
For more examples of how to use the virt-clone command, see the virt-clone(1)
Linux man page.
2. Verify that the cloned KVM instance is working, for example:
• Confirm that the clone has been added to the list of KVMs on the host:
4-10
Chapter 4
View: KVM Instances, Status, and Configuration
Example output:
Id Name State
----------------------------------------------------
1 My_KVM_Guest running
Where:
• KVM ID or Name: The unique ID and name assigned to the KVM instance.
• State: The operating status of the KVM instance. Possible status states that might
appear include:
– Running – The KVM instance is considered operational and working.
– Paused – Execution of the KVM instance has been paused until it's resumed.
– Shut off or Shutdown – The KVM instance is powered off.
– Saved – The saved state is similar to the paused state, however the KVM
instance's configuration is saved to persistent storage.
For more details on how to manage the state of a KVM instance, see Start, Shutdown,
Reboot, or Remove KVM.
2. To view basic details about a specific KVM instance, type:
Example output:
Id: 1
Name: My_KVM_Guest
UUID: c321630AA-2f5e-665c-8949-75b7d99999e1
OS Type: hvm
State: running
CPU(s): 2
CPU time: 188.3s
Max memory: 4188304 KiB
Used memory: 4188304 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: selinux
4-11
Chapter 4
Connect to KVM: virsh Serial Console
Security DOI: 0
Security label: system_u:system_r:svirt_t:s0:###,### (enforcing)
3. To view the complete XML configuration associated with a KVM instance, use the virsh
dumpxml command. For example:
The virsh dumpxml command output returns the guest KVM XML configuration file, which
can be viewed, saved, changed, or used in other ways.
4. To edit the XML configuration file associated with a KVM guest, use the virsh edit
command. For example:
Note:
A serial console connection to a KVM instance might be useful when a the instance
isn't configured with a GUI display, or if the instance lacks a network configuration,
preventing SSH access.
Within the <devices> tag, add the following text to the XML. For example:
<devices>
<console type='pty'/>
</devices>
4-12
Chapter 4
Start, Shutdown, Reboot, or Remove KVM
• On the host system, use the virsh console command to open up a KVM session in a
serial console. For example:
Note:
If the connection failed and the guest serial console is unresponsive, you can exit
the connection by pressing: Ctrl key and the ] right square bracket key.
4-13
Chapter 4
Start, Shutdown, Reboot, or Remove KVM
Example output:
• For remote KVM, use the virt start command and the SSH connection protocol as
follows:
Example output:
root@host_ip-address's password:
4-14
Chapter 4
Start, Shutdown, Reboot, or Remove KVM
Note:
The virsh destroy command doesn't delete or remove the KVM configuration or its
disk images. It only forces the running KVM instance to shut down, similarly to pulling
the power cord on a physical machine. However, in unique cases, the virsh destroy
command might cause corruption to the KVM file system, so using this command is
only recommended when all other shutdown methods have failed.
Example output:
– For a remote KVM, use the virt shutdown command and the SSH connection
protocol as follows:
Example output:
root@host_ip-address's password:
4-15
Chapter 4
Start, Shutdown, Reboot, or Remove KVM
Example output:
Example output:
– For a remote KVM, use the virt suspend command and the SSH connection
protocol as follows:
4-16
Chapter 4
Start, Shutdown, Reboot, or Remove KVM
Example output:
root@host_ip-address's password:
• Resume KVM - Use the virt resume command on an suspended KVM instance as
follows:
Example output:
Note:
Rebooting a KVM can be helpful with various problems and might even be necessary
to complete some configurations.
• Type:
Where:
• [--mode method] is optional. The mode method option lets you specify an alternative
shutdown method such as acpi or agent.
Example output:
4-17
Chapter 4
Start, Shutdown, Reboot, or Remove KVM
Example output:
<source file='/home/testuser/.local/share/libvirt/images/
My_KVMGuest_Name-1.qcow2'/>
– KVM instance is shutdown. For details, see KVM: Shut Down Instance
– (Optional) Back up all important data on KVM instance. If required, see Clone: Existing
KVM Instance.
Steps
Follow these steps to remove a KVM instance from a host system.
1. To delete the KVM instance, type:
The virsh undefine command removes all configuration information about the KVM
instance from libvirt. Note that the associated KVM storage artifacts such as virtual disks
remain intact.
2. (Optional) To delete the storage artifacts such as virtual disks associated with the KVM
instance (removed in Step 1), use the rm command followed by the storage path.
For example:
sudo rm /home/testuser/.local/share/libvirt/images/
My_KVMGuest_Name-1.qcow2
4-18
5
KVM Instances: Hardware Configuration
Using the CLI, system administrators can add, remove, or change any of the following
hardware configuration settings as required.
• Add Watchdog Device to KVM Instance
• Add vTPM Security to KVM Instance
• Overview: Virtual Networking
• KVM Storage Configuration
• KVM Memory and CPU Allocation Configuration
Note:
Watchdog device configurations aren't supported on Arm-based KVMs. Arm-based
KVMs are cloud-native virtual machines that operate on Arm-based processors.
5-1
Chapter 5
Add Watchdog Device to KVM Instance
Note:
The latest version of libvirt (9.x or later) includes a number of Watchdog
enhancements and bug fixes over the earlier versions of libvirt.
Note:
The virsh edit command opens the XML file in the text editor specified by
the $EDITOR shell parameter. The vi editor is set by default.
b. Update the guest OS XML configuration file to include the required watchdog device
settings.
For example:
<devices>
...
</input>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<watchdog model='i6300esb' action='poweroff'/>
<graphics type='vnc' port='-1' autoport='yes'>
<listen type='address'/>
</graphics>
...
</devices
Where:
• model – Specifies the emulated watchdog device driver. Valid property values are
specific to the KVM machine type, for example:
5-2
Chapter 5
Add Watchdog Device to KVM Instance
Note:
This device doesn't work with
the q35 machine type.
• action – (Optional) Describes the action taken when the watchdog timer expires.
Important:
The shutdown action requires
that the guest is responsive to
ACPI signals. In cases where
the watchdog timer expired,
the guests are typically unable
to respond to ACPI signals.
Therefore assigning a
'shutdown' action isn't
recommended.
Note:
To configure the directory to
save the dump file, set the
auto_dump_path in file /etc/
libvirt/qemu.conf.
5-3
Chapter 5
Add vTPM Security to KVM Instance
Note:
The virsh edit command opens the XML file in the text editor specified by
the $EDITOR shell parameter. The vi editor is set by default.
b. Update the guest OS XML configuration file to include the vTPM security properties.
5-4
Chapter 5
KVM Network Configuration
For example:
<devices>
...
</input>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<tpm model='tpm-crb'>
<backend type='emulator' version='2.0'/>
</tpm>
<graphics type='vnc' port='-1' autoport='yes'>
<listen type='address'/>
</graphics>
...
</devices>
Where:
• model='tpm-crb' – sets the TPM model type as Command-Response Buffer (CRB).
Note:
The tpm-crb option is available only when you specify version='2.0'.
Note:
When creating a KVM instance for the first time on Oracle Linux 8 or Oracle
Linux 9, you can also use the virt-install command --tpm option to
specify the TPM emulated device information at installation time. For
example:
5-5
Chapter 5
KVM Network Configuration
5-6
Chapter 5
KVM Network Configuration
passthrough networking. Direct PCIe passthrough allocates exclusive use of a PCIe device
on the host system to a single KVM guest. Shared PCIe passthrough allocates shared use
of an SR-IOV (Single Root I/O Virtualization) capable PCIe device to multiple KVM guests.
Both of these configuration methods require some hardware set up and configuration on
the host system before attaching the PCIe device to a KVM guest(s) for network use.
KVM Tools for Configuring Virtual Network
In cases where network configurations are likely to be more complex, we recommend using
Oracle Linux Virtualization Manager. The fundamental purpose of the CLI networking
configurations and operations described in this guide is to facilitate the most basic KVM
network deployment scenarios.
For details about Oracle Linux Virtualization Manager for more complex network
configurations, see Oracle Linux Virtualization Manager documentation.
Output example:
Output example:
Name: default
UUID: 16318035-eed4-45b6-99f8-02f1ed0661d9
Active: yes
Persistent: yes
Autostart: yes
Bridge: virbr0
Where:
– Name = assigned network name.
– UUID = assigned network identifier.
– virbr0 = virtual network bridge.
5-7
Chapter 5
KVM Network Configuration
Note:
virbr0 should not be confused with traditional bridge networking. In this
case, the virtual bridge isn't connected to a physical interface. The virtual
network bridge relies on NAT and IP forwarding to connect VMs to the
physical network.
Output example:
<network>
<name>default</name>
<uuid>16318035-eed4-45b6-99f8-02f1ed0661d9</uuid>
<forward mode='nat'>
<nat>
<port start='1024' end='65535'/>
</nat>
</forward>
<bridge name='virbr0' stp='on' delay='0'/>
<mac address='52:54:00:82:75:1d'/>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.122.2' end='192.168.122.254'/>
</dhcp>
</ip>
</network>
In this example, the virtual network uses a network bridge, called virbr0, not to be
confused with traditional bridged networking. The virtual bridge isn't connected to a
physical interface and relies on NAT and IP forwarding to connect VMs to the physical
network beyond. libvirt also handles IP address assignment for VMs using DHCP. The
default network is typically in the range 192.168.122.1/24.
• virsh net-start – Start an inactive, previously defined virtual network.
For a more complete list of libvirt's network management commands, see the section 'Basic
Command-line Usage for Virtual Networks' on the libvirt Virtual Networking site (https://
wiki.libvirt.org/VirtualNetworking.html#virsh-xml-commands).
5-8
Chapter 5
KVM Network Configuration
The domain or VM name and type are required parameters. If the VM has more than one vNIC
attached, you must specify the mac parameter to provide the MAC address of the vNIC that you
5-9
Chapter 5
KVM Network Configuration
want to remove. You can obtain this value by listing the vNICs that are attached to a VM. For
example, you can run:
<interface type="direct">
<mac address="#:##:##:##:#:##"/>
5-10
Chapter 5
KVM Network Configuration
Where:
• mac address="#:##:##:##:#:##" – The MAC address field is optional. If it is omitted,
the libvirt daemon will generate a unique address.
• interface type="direct" – Used for MacVTap. Specifies a direct mapping to an
existing KVM host device.
• source dev="kvm-host-device" mode="bridge" – Specifies the KVM host
network interface name that will be used by the KVM guest's MacVTap interface. The
mode keyword defines which MacVTap mode is used.
MacVTAP Driver Modes
The macvtap driver creates endpoint devices that follow the tun/tap ioctl interface model to
extend an existing network interface so that KVM can use it to connect to the physical network
interface directly to support different network functions. These functions can be controlled by
setting a different mode for the interface. The following modes are available:
• vepa (Virtual Ethernet Port Aggregator) is the default mode and forces all data from a vNIC
out of the physical interface to a network switch. If the switch supports a hairpin mode,
different vNICs connected to the same physical interface can communicate through the
switch. Many switches today don't support a hairpin mode, which means that virtual
machines with direct connection interfaces running in VEPA mode are unable to
communicate, but can connect to the external network by using the switch.
• bridge mode connects all vNICs directly to each other so that traffic between the virtual
machines on same physical interface isn't sent to the switch but sent directly. The bridge
mode option is the most useful for switches that don't support a hairpin mode, and when
you need maximum performance for communications between VMs. Note the bridge
mode, unlike a traditional software bridge, the host is unable to use this interface to
communicate directly with the KVM.
• private mode behaves like a VEPA mode vNIC in the absence of a switch supporting a
hairpin mode option. However, even if the switch does support the hairpin mode, two VMs
connected to the same physical interface are unable to communicate with each other. This
option supports limited use cases.
• passthrough mode attaches a physical interface device or an SR-IOV Virtual Function (VF)
directly to the vNIC without losing the migration capability. All packets are sent directly to
the configured network device. A one-to-one mapping exists between network devices and
VMs when configured in passthrough mode because a network device can't be shared
between VMs in this configuration.
Note:
The virsh attach-interface command doesn't provide an option for you to specify
the different modes available when attaching a direct type interface that uses the
macvtap driver and defaults to vepa mode. The graphical virt-manager utility makes
setting up bridged networks using macvtap easier and provides options for each
different mode.
5-11
Chapter 5
KVM Network Configuration
Where:
• bridge_name – The name assigned to the bridge.
• enp0s31f6 – The physical interface the Ethernet port name used in this example.
2. Attach the bridge interface to the KVM instance using the virsh attach-interface
command.
Example:
Where:
• My_KVM_Guest_Name – The name of the KVM instance.
• wlp4s0 --config – The source interface name used in this example.
For more details about using the virsh-attach command, see Command Usage: Add or
Remove vNIC.
3. Shut down the KVM instance. For details, see KVM: Shut Down Instance
4. Edit the KVM XML configuration to set the source interface mode to bridge. For example:
a. Use virsh edit to edit the file:
5-12
Chapter 5
KVM Network Configuration
Note:
The virsh edit command opens the XML file in the text editor specified by
the $EDITOR shell parameter. The vi editor is set by default.
Note:
The source interface mode is set, by default, to vepa.
For more details about how to set the source interface mode to bridge, see the
macvtap driver example in Setup Guidelines: Bridged Network.
5. Save the KVM XML configuration changes.
6. Inform the libvirt daemon of the KVM XML configuration changes by using the virsh
undefine and virsh define commands.
Example:
The virsh undefine command removes the existing KVM configuration and the virsh
define replaces it with the updated configuration in the XML file.
7. Start the KVM instance. For details, see KVM: Start Instance.
The direct network interface is attached in bridge mode and starts automatically when
starting the KVM instance.
5-13
Chapter 5
KVM Network Configuration
Note:
Using direct PCIe passthrough can result in increased consumption of host
system CPU resources and, thereby, decrease the overall performance of the
host system.
For more information about configuring PCIe passthrough using this method, see Create:
Direct PCIe Passthrough Connection.
.
• Shared PCIe Passthrough to KVM Guests Using SR-IOV. Use this method to allocate
shared use of SR-IOV (Single Root I/O Virtualization) capable PCIe devices to multiple
KVM guests. This method uses SR-IOV device assignment to configure a PCIe resource to
be shared amongst several KVM guests. SR-IOV device assignment is beneficial in
workloads with high packet rates or low latency requirements. For more information about
SR-IOV PCIe passthrough, see the following topics:
– Setup Guidelines: SR-IOV PCIe Passthrough
– Create: SR-IOV PCIe Passthrough Connection
– SR-IOV Enabled PCIe Devices
5-14
Chapter 5
KVM Network Configuration
Note:
The following procedure doesn't cover the configuration of enabling passthrough of
SR-IOV Ethernet virtual devices. For instructions on how to configure passthrough for
SR-IOV capable PCIe devices, see Create: SR-IOV PCIe Passthrough Connection.
Steps
Follow these steps to directly assign a host PCIe device to a KVM guest:
1. Shut down the KVM guest.
2. To identify the host attached PCIe devices and their assigned IDs, use the lspci
command as follows:
Where:
• lspci lists all PCIe devices.
• -D option lists the PCIe domain numbers for each device.
• awk is a scripting language that manipulates the device IDs into a format usable by the
virsh command.
For example, the output might look as follows:
3. Select the device that you want to configure for passthrough and create a variable
containing the device ID. For example:
pci_dev="pci_0000_00_07_0"
4. Use the virsh nodedev-dumpxml command to calculate the PCIe device domain, bus, slot,
and function parameters into usable variables. For example:
5-15
Chapter 5
KVM Network Configuration
5. To identify the device source domain address required for passthrough, use the print
function to convert the PCIe domain, bus, slot, and function variables to hexadecimal
values.
For example:
Note:
managed and unmanagedlibvirt recognizes two management modes for
handling PCIe devices: managed='yes' (default) or managed='no". When the
mode is set to managed='yes', libvirt handles the unbinding of the device
from the existing driver, resetting the device, and then binding it to the vfio-pci
driver before starting the domain. In cases when the domain is stopped or the
device is removed from the domain, libvirt unbinds it from the vfio-pci
driver and rebinds it to the original driver. When the mode is set to
managed='no', you must manually detach the PCIe device from the host and
then manually attach it to the vfio-pci driver.
For example, to detach:
To reattach:
Alternatively, you can use Cockpit to attach and remove host devices. For more
details, see Add or Remove VM Host Devices in the Oracle Linux: Using the
Cockpit Web Console guide.
7. On the host system, enable guest management for virtual PCIe pass-through.
5-16
Chapter 5
KVM Network Configuration
The PCIe device is successfully assigned to the KVM guest and the guest OS now has
exclusive control over its capabilities.
5-17
Chapter 5
KVM Network Configuration
1. Verify if the Intel VT-d or AMD IOMMU options are enabled in the system firmware at the
BIOS/UEFI level. For more details, see the applicable Oracle server model documentation.
2. Verify if the Intel VT-d or AMD IOMMU options are activated in the kernel. If these kernel
options haven't been enabled, perform the following.
• For Intel virtualization, add the intel_iommu=on and iommu=pt parameters to the
end of the GRUB_CMDLINX_LINUX line, within the quotes, in the /etc/default/
grub.cfg file.
Note:
A symlink exists between /etc/sysconfig/grub and /etc/default/
grub, therefore, you could alternatively choose to configure the /etc/
sysconfig/grub.cfg file.
• For AMD virtualization, add the intel_iommu=on and iommu=pt parameters to the end
of the GRUB_CMDLINX_LINUX line, within the quotes, in the /etc/default/grub.cfg file.
Regenerate grub.cfg file and then reboot the system for the changes to take affect.
grub2-mkconfig -o /etc/grub.cfg
3. Use the lspci command to verify if an SR-IOV capable PCIe device is detected on the
host system. For example:
Where:
• lspci lists all PCIe devices.
• -D option lists the PCIe domain numbers for each device.
• awk is a scripting language that manipulates the device IDs into a format usable by the
virsh command.
For example, the output might look as follows:
5-18
Chapter 5
KVM Network Configuration
Note:
For a list of SR-IOV compatible PCIe devices, see SR-IOV Enabled PCIe
Devices .
In the previous example in Step 4, igb is name of the driver. To find the device
driver name, use the ethtool command. For example:
b. Start the module with max_vfs set to 7 (or up to the maximum number allowed).
For example:
Where:
– N is the number of VFs that you want the kernel driver to create.
– ${PF_DEV} is the PCI bus/device/function ID for the physical device. For example:
“0000:02:00.0” (as shown in the example output of Step 3.)
6. Use the lspci | grep command to list the newly added VFs.
5-19
Chapter 5
KVM Network Configuration
For example, the following output lists VFs associated with the 82576 Network Controller.
The physical functions (PFs) correspond to 0b:00.0 and 0b:00.1 entries. Where all the
VFs appear as a Virtual Function entry in the description.
7. Verify libvirt can detect the SR-IOV device by using the virsh nodedev-list |
grep command.
For the Intel 82576 network device example, the filtered output appears as follows:
5-20
Chapter 5
KVM Network Configuration
pci_0000_0b_11_2
pci_0000_0b_11_3
pci_0000_0b_11_4
pci_0000_0b_11_5
Note that libvirt uses a similar notation to the lspci output. Punctuation characters,
for example, such as a semicolon (;) and a period (.), appear in lspci output as
underscores (_).
8. Use virsh nodedev-dumpxml command to review the SR-IOV physical and virtual
functions device details.
For example, advanced output shows details associated with the pci_0000_0b_00_0
physical function and its first corresponding virtual function ( pci_0000_0b_10_0_),
Note the bus, slot and function parameters of the VF. These parameters are required
in the next step to assign a VF to a KVM guest.
5-21
Chapter 5
KVM Network Configuration
Note:
...
<devices>
...
<interface type='hostdev' managed='yes'>
<source><address type='pci' domain='0' bus='11' slot='16'
function='0'/>
</source><mac address='52:54:00:6d:90:02'><vlan><tag id='42'/>
</vlan><virtualport type='802.1Qbh'>
<parameters profileid='finance'/>
</virtualport></interface>
...
</devices>
9. Using the new-interface.xml file created in the previous step, and the virsh
attach-device command, assign a VF of a SR-IOV PCIe device to a KVM guest.
For example:
The --config option ensures that the new VF is available after future restarts of KVM
guest.
5-22
Chapter 5
KVM Storage Configuration
Note:
Because of the continuous development of new SR-IOV PCIe devices and the Linux
kernel, other SR-IOV capable PCIe devices might be available over time and aren't
captured in the following table.
5-23
Chapter 5
KVM Storage Configuration
You can use the default directory-based storage and take advantage of manually mounted
storage at the default locations.
We recommend using Oracle Linux Virtualization Manager to easily manage and configure
complex storage requirements for KVM environments. Alternatively, you can use Cockpit to
manage KVM storage. For more details, see Storage Management Tasks in Oracle Linux:
Using the Cockpit Web Console.
For more details on how to use the command line to manage storage configurations for KVM
use, see these topics:
• Storage Pools: Create and Manage
• Storage Volumes: Create and Manage
• Virtual Disks: Create and Manage
For most use cases, consider creating persistent storage pools. Persistent storage pools are
defined as a configuration entry that's stored within /etc/libvirt. Persistent storage pools
can be stopped and started and can be configured to start when the host system boots. Libvirt
can take care of automatically mounting and enabling access to network based resources
when persistent storage is configured. Persistent storage pools are created using the virsh
pool-define command, and usually need to be started after they have been created before
you can use them.
For more details on how to use the command line to create and manage storage pools for
KVM use, see these topics:
• Creating a Storage Pool
• Creating a Storage Pool from XML
• Removing a Storage Pool
5-24
Chapter 5
KVM Storage Configuration
Where:
• pool_name – The name you assign to the pool.
• type – The storage type the pool uses.
See libvirt documentation for details about the storage types you can specify:
• Storage pool and volume XML format
• Storage Management
The following table provides examples of different pool types you can define:
virsh pool-define-as pool_name dir \ Creates a pool with the name pool_name for a
--target /share/storage_pool directory that's at /share/storage_pool on the
host system.
5-25
Chapter 5
KVM Storage Configuration
After you create a pool, you can create a storage volume within the pool. See Creating a
Storage Volume for more information.
You can also indicate which pool to use when you create a VM using virt-install. Include
the --disk argument and the pool and size sub options. For example:
virt-install
...
--disk pool=pool_name, size=80
<pool type='iscsi'>
<name>pool_name</name>
<source>
<host name='192.0.2.1'/>
<device path='iqn.2024-12.com.mycompany:my-iscsi-host'/>
</source>
<target>
<path>/dev/disk/by-path</path>
</target>
</pool>
The previous example assumes that an iSCSI server is already configured and running on
a host with IP address 192.0.2.1 and that the iSCSI Qualified Name (IQN) is
iqn.2024-12.com.mycompany:my-iscsi-host.
2. Run virsh pool-define to load the configuration information from the XML file into libvirt.
For example, to load the pool_definition.xml file from the previous step, run:
5-26
Chapter 5
KVM Storage Configuration
Note:
The directory must be empty for this command to delete the directory.
5-27
Chapter 5
KVM Storage Configuration
be used although some formats, such as qcow2, might require extra tools such as qemu-img
for creation.
For disk based pools, standard partition type labels are used to represent individual volumes;
while for pools based on the logical volume manager, the volumes themselves are presented
individually within the pool.
Storage volumes can be sparsely allocated when they're created by setting the allocation value
for the initial size of the volume to a value lower than the capacity of the volume. The allocation
indicates the initial or current physical size of the volume, while the capacity indicates the size
of the virtual disk as it's presented to the KVM. Sparse allocation is often used to over-
subscribe physical disk space where KVMs might eventually require more disk space than is
initially available. For a non-sparsely allocated volume, the allocation matches or exceeds the
capacity of the volume. Exceeding the capacity of the disk provides space for metadata, if
required.
You can use the --pool option if you have volumes with matching names in different pools on
the same system and you need to specify the pool to use for any virsh volume operation.
This practice is replicated across subsequent examples.
For more details on how to use the command line to create and manage storage volumes for
KVM use, see these topics:
• Creating a Storage Volume
• Creating a Storage Volume from XML
• Cloning a Storage Volume
• Resizing a Storage Volume
• Deleting a Storage Volume
virsh vol-create-as \
--pool pool_name \
--name volume_name \
--capacity 10G
Many of the available options, such as the allocation or format have default values set, so
you can typically only specify the name of the storage pool where the volume should be
created, the name of the volume and the capacity that you require.
2. Verify the creation of the storage volume.
5-28
Chapter 5
KVM Storage Configuration
Name: volume_name
Type: file
Capacity: 9.31 GiB
Allocation: 8.00 GiB
<volume>
<name>volume1</name>
<allocation>0</allocation>
<capacity unit="G">10</capacity>
<target>
<path>/home/testuser/.local/share/libvirt/images/volume1.qcow2</
path>
<permissions>
<owner>107</owner>
<group>107</group>
<mode>0744</mode>
<label>virt_image_t</label>
</permissions>
</target>
</volume>
For more information, see Storage pool and volume XML format in the libvirt
documentation.
2. Run virsh vol-create and include the pool and source XML file as required arguments.
For example, to create a volume in storage pool named pooldir with an XML file named
volume1.xml, run the following command:
1. Run the virsh vol-clone command and include the name of the original volume and
the name of the cloned volume as required arguments.
For example:
5-29
Chapter 5
KVM Storage Configuration
The clone is created in the same storage pool with identical parameters.
2. Verify the creation of the cloned volume.
• Run the virsh vol-resize command and provide the volume and capacity as required
arguments.
For example:
Caution:
Reducing the size of an existing volume can risk destroying data. However, if you
need to resize a volume to reduce it, you must specify the --shrink option with
the new size value.
• Run virsh vol-delete and provide the volume name as a required argument.
For example, to delete the volume named volume1 in the storage pool named pool_name,
run the following command:
Note:
Command line tools available for managing virtual disks aren't completely consistent
in terms of their handling of storage volumes and storage pools.
For more details about how to create and manage virtual disks for KVM use, see these topics:
• Attaching a Virtual Disk to an Existing VM
• Attaching a Virtual Disk when Creating a VM
5-30
Chapter 5
KVM Storage Configuration
Name Path
--------------------------------------------------------------------
volume1 /share/disk-images/volume1.qcow2
2. Attach the disk image within the existing VM configuration so that it is persistent and
attaches itself on each subsequent restart of the VM:
This command requires that you provide the path to the disk image when you attach it to
the VM.
You can use the following options:
• --live – temporarily attach a disk image to a running VM.
• --persistent – attach a disk image to a running VM and also update its configuration
so that the disk is attached on each subsequent restart.
virt-install \
--name guest \
--disk vol=storage_pool/volume1.qcow2
...
5-31
Chapter 5
KVM Storage Configuration
To create a virtual disk as a volume within an existing storage pool automatically at install,
include the pool option. In this case, the size option is also required. For example:
virt-install \
--name guest \
--disk pool=storage_pool size=10
...
Caution:
Before you detach a disk from a running VM, ensure that you perform the appropriate
actions within the guest OS to offline the disk correctly first. Otherwise, you might
corrupt the file system. For example, unmount the disk in the guest OS so that it
performs any sync operations that might still be remaining before you detach the
disk.
1. Display a list of the block devices attached to a guest to identify the disk target.
5-32
Chapter 5
KVM Memory and CPU Allocation Configuration
2. Find the path to the disk image and note the location.
3. Run virsh blockresize and include the guest name, path to the disk, and intended
size as required arguments.
For example, to increase the size of the disk image at the source location /share/disk-
images/volume1.qcow2 on the running VM named guest1 to 20 GB, run:
The value you provide for size is a scaled integer which defaults to KiB if you omit a suffix.
The virsh blockresize command enables you to scale up a disk on a live VM, but it
doesn't guarantee that the VM can immediately identify that the additional disk resource is
available. For some guest operating systems, restarting the VM might be required before
the guest can identify the additional resources available.
Individual partitions and file systems on the block device aren't scaled using this command.
You need to perform these operations manually from within the guest, as required.
4. Verify that resizing has worked as expected by checking the block device information of the
VM again.
For example:
5-33
Chapter 5
KVM Memory and CPU Allocation Configuration
Where:
• setvcpu: Sets the state of individual vCPUs using the hot(un)plug mechanism.
Note:
The count value entered can't exceed the number of CPUs assigned to a KVM
guest. Also, the allowable count value for vCPUs can vary depending on the
following factors: host logical CPUs, hypervisor manufacturer, KVM guest OS,
and so on.
You must specify the size as a scaled integer in kibibytes and the new value can't exceed the
amount you specified for the KVM. Values lower than 64 MB are unlikely to work with most
KVM guest operating systems. A higher maximum memory value doesn't affect active KVMs. If
the new value is lower than the available memory, it shrinks memory usage possibly causing
the KVM to crash.
Use following command options to allocate memory to a KVM instance:
• domain
5-34
Chapter 5
KVM Memory and CPU Allocation Configuration
You must specify the size as a scaled integer in kibibytes unless you also specify a supported
memory unit, which are the same as for the virsh setmem command.
All other options for virsh setmaxmem are the same as for virsh setmem with one caveat.
If you specify the --live option be aware that not all hypervisors support live changes to the
maximum memory limit.
5-35
6
KVM Known Issues
The following topics describe known issues for Oracle Linux KVM. Note that when a
workaround is available that information is also provided.
• KVM Not Starting After Upgrade On QEMU
• KVM Guest With vTPM Fails
• Downgrade Stream Conflict Error Messages
Workaround:
To work around this issue so that KVM guests can run the updated qemu version, edit the XML
file of each KVM guest, adding the caching_mode='on' parameter to the iommu model='intel'
section for each driver sub-element, as shown in the following example:
For example:
<iommu model='intel'>
<driver aw_bits='48' caching_mode='on'/>
</iommu>
(Bug ID 32312933)
6-1
Chapter 6
KVM Guest With vTPM Fails
6-2