Virtualization
- WHAT?
By means of virtualization, you can run multiple virtual machines on a single bare-metal host.
- WHY?
Sharing host hardware between multiple virtualized guests significantly saves resources.
- EFFORT
It takes less than 15 minutes of your time to understand the concept of virtualization.
1 Introduction to virtualization #
Virtualization is a technology that provides a way for a machine (VM Host Server) to run another operating system (VM Guest) on top of the host operating system.
1.1 How does virtualization work? #
The primary component of VM Host Server that enables virtualization is a hypervisor. A hypervisor is a layer of software that runs directly on VM Host Server's hardware. It controls platform resources, sharing them among multiple VM Guests and their operating systems by presenting virtualized hardware interfaces to each VM Guest.
1.2 Benefits of virtualization #
Virtualization brings a lot of advantages while providing the same service as a hardware server.
Virtualization reduces the cost of your infrastructure. Servers are mainly used to provide a service to a customer. A virtualized operating system can provide the same service but with the following advantages:
Less hardware: you can run several operating systems on one host, therefore all hardware maintenance is reduced.
Less power/cooling: less hardware means you do not need to invest more in electric power, backup power, and cooling if you need more service.
Save space: your data center space is saved because you do not need more hardware servers (fewer servers than services running).
Less management: using a VM Guest simplifies the administration of your infrastructure.
Agility and productivity: virtualization provides migration capabilities, live migration and snapshots. These features reduce downtime and bring an easy way to move your service from one place to another without any service interruption.
2 Installation of virtualization components #
To run a virtualization server (VM Host Server) that can host multiple guest systems (VM Guests), you need to install required virtualization components on the server. These components vary depending on which virtualization technology you want to use.
You can install the virtualization tools required to run a VM Host Server either when installing the system (see the manual installation), or from an alerady installed system by installing a virtualization pattern. The later option is described bellow:
>sudozypper install -t pattern PATTERN_NAME
Replace the PATTERN_NAME with one of the following values:
kvm_serverInstalls a basic VM Host Server with the KVM and QEMU environments.
kvm_toolsInstalls
libvirttools for managing and monitoring VM Guests in the KVM environment.
3 Virtualization modes #
Virtualization is a technology that provides a way for a machine (VM Host Server) to run another operating system (VM Guest) on top of the host operating system. There are two basic modes of hosting VM Guests on virtual machines—full virtualization mode and paravirtual mode.
- Full virtualization (FV)
FV lets virtual machines run unmodified operating systems. It uses either Binary Translation or hardware-assisted virtualization technology, such as AMD* Virtualization or Intel* Virtualization Technology, to improve performance on processors that support it. In FV mode, VM Guest is also called the Hardware Virtual Machine (HVM).
TipCertain guest operating systems hosted in full virtualization mode can be configured to use drivers from the SUSE Virtual Machine Drivers Pack (VMDP) instead of drivers included in the operating system. Running virtual machine drivers improves performance on guest operating systems, such as Windows Server.
- Paravirtualization (PV)
PV normally requires that guest operating systems are modified for the virtualization environment. VM Guests running in paravirtual mode have better performance than those running under full virtualization. Operating systems currently modified to run in paravirtual mode are called paravirtualized operating systems and include SLES.
- PV on HVM (PVHVM)
PVHVM enhances HVM (see Full virtualization (FV)) with paravirtualized drivers, and handling of paravirtualized interrupts and timers.
4 Virtualization limits and support #
Virtualization limits and support
QEMU is only supported when used for virtualization together with the KVM hypervisors. The TCG accelerator is not supported, even when it is distributed within SUSE products. Users must not rely on QEMU TCG to provide guest isolation, or for any security guarantees. See also https://qemu-project.gitlab.io/qemu/system/security.html.
4.1 Architecture support #
4.1.1 KVM hardware requirements #
SUSE supports KVM full virtualization on AMD64/Intel 64, AArch64, IBM Z and IBM LinuxONE hosts.
On the AMD64/Intel 64 architecture, KVM is designed around hardware virtualization features included in AMD* (AMD-V) and Intel* (VT-x) CPUs. It supports virtualization features of chipsets and PCI devices, such as an I/O Memory Mapping Unit (IOMMU) and Single Root I/O Virtualization (SR-IOV). You can test whether your CPU supports hardware virtualization with the following command:
>egrep '(vmx|svm)' /proc/cpuinfoIf this command returns no output, your processor either does not support hardware virtualization, or this feature has been disabled in the BIOS or firmware.
The following Web sites identify AMD64/Intel 64 processors that support hardware virtualization: https://ark.intel.com/Products/VirtualizationTechnology (for Intel CPUs), and https://products.amd.com/ (for AMD CPUs).
On the Arm architecture, Armv8-A processors include support for virtualization.
On the Arm architecture, we only support running QEMU/KVM via the CPU model
host(it is namedhost-passthroughin Virtual Machine Manager orlibvirt).
The KVM kernel modules only load if the CPU hardware virtualization features are available.
However, additional RAM for each virtualized guest is needed. It should at least be the same amount that is needed for a physical installation. It is also strongly recommended having at least one processor core or hyper-thread for each running guest.
AArch64 is a continuously evolving platform. It does not have a traditional standards and compliance certification program to enable interoperability with operating systems and hypervisors. Ask your vendor for the support statement on SUSE Linux Enterprise Server.
Running KVM hypervisor on the POWER platform is not supported.
4.2 Hypervisor limits #
New features and virtualization limits for KVM are outlined in the Release Notes for each Service Pack (SP).
Only packages that are part of the official repositories for SUSE Linux Enterprise Server are
supported. Conversely, all optional subpackages and plug-ins (for QEMU,
libvirt) provided at
packagehub are
not supported.
For the maximum total virtual CPUs per host. The total number of virtual CPUs should be proportional to the number of available physical CPUs.
4.2.1 KVM limits #
Supported (and tested) virtualization limits of a SUSE Linux Enterprise Server 16.0 host running Linux guests on AMD64/Intel 64. For other operating systems, refer to the specific vendor.
|
Maximum virtual CPUs per VM |
768 |
|
Maximum memory per VM |
8 TiB |
KVM host limits are identical to SUSE Linux Enterprise Server (see the corresponding section of release notes), except for:
Maximum virtual CPUs per VM: see recommendations in the Virtualization Best Practices Guide regarding the overcommitment of physical CPUs. The total virtual CPUs should be proportional to the available physical CPUs.
4.3 Guest VM restrictions and limitations (secure VM) #
Please be aware of the following functionalities and features that are not available or have limitations for guest VMs, especially when deployed within secure VM environments. These limitations are crucial for maintaining the enhanced security provided by the underlying hardware and software configurations.
Secure Boot (AMD side): Secure Boot functionality is not supported on the AMD platform for guest VMs within this secure environment. This means that guest VMs cannot leverage the UEFI Secure Boot mechanism to verify the digital signatures of boot components, which typically helps prevent the loading of unauthorized or malicious software during the boot process. Users should consider alternative methods for ensuring software integrity post-boot.
VM migration: The live migration of virtual machines between hosts is currently not supported. This implies that planned maintenance, load balancing, or disaster recovery scenarios requiring VM movement without downtime will need to involve a full shutdown and restart of the guest VM on the new host. This limitation is often a consequence of maintaining the cryptographic isolation and attestation state of secure VMs.
Suspend/restore: The ability to suspend a VM's execution state to disk and later restore it is not available. This impacts operational flexibility, as VMs cannot be paused and resumed seamlessly. Any interruption to a guest VM's operation will require a full shutdown and a fresh boot cycle, losing the immediate operational state.
Pass-through devices: Direct pass-through of host devices (such as GPUs, network cards, or storage controllers) to the guest VM is not supported. This limitation restricts scenarios where guest VMs require exclusive, high-performance access to specific hardware components. Workloads that heavily rely on direct hardware interaction, like certain graphical applications or specialized I/O operations, may experience reduced performance or incompatibility.
VM reboot: The internal reboot functionality for guest VMs is not supported. If a guest VM requires a restart, it must be fully shut down and then started again from the host management interface. This ensures that the secure state of the VM is properly re-established upon each boot, rather than relying on an internal reset that might bypass certain security checks.
Memory ballooning: Memory ballooning, which allows dynamic adjustment of VM memory by reclaiming unused guest memory back to the host, is not supported. This means that the allocated memory for a guest VM will remain fixed, regardless of its actual usage. Consequently, memory overcommitment strategies, where the sum of allocated VM memory exceeds the physical host memory, cannot be effectively utilized, potentially leading to less efficient memory utilization on the host.
Hotplug CPU/memory: The hotplugging (adding or removing) of CPU cores or memory modules while the VM is running is not supported. Any changes to the vCPU or memory configuration of a guest VM will require a full shutdown and a restart of the VM for the changes to take effect. This affects the agility and flexibility in dynamically scaling resources for running workloads.
Virtio graphics: Only Virtio block devices (for storage) and network devices are supported. Virtio graphics are not available for guest VMs in this environment. This implies that guest VMs will rely on basic graphics emulation, which may not provide optimal performance for graphically intensive applications, user interfaces, or remote desktop protocols requiring accelerated graphics.
Huge pages: The use of huge pages for memory allocation within the guest VM is not supported. Huge pages can improve performance by reducing Translation Lookaside Buffer (TLB) misses, especially for applications with large memory footprints. Without huge page support, memory management might incur slightly higher overhead, which could subtly impact the performance of memory-intensive applications.
vCPU limit (AMD SNP): The number of virtual CPUs (vCPUs) that can be assigned to a guest VM is limited to 255 when utilizing AMD Secure Nested Paging (SNP). This specific limitation is imposed by the AMD SNP architecture to maintain the integrity and performance characteristics of the secure execution environment. Workloads requiring more than 255 vCPUs cannot be deployed on these secure VMs.
4.4 Supported host environments (hypervisors) #
This section describes the support status of SUSE Linux Enterprise Server 16.0 running as a guest operating system on top of different virtualization hosts (hypervisors).
|
SUSE Linux Enterprise Server |
Hypervisors |
|---|---|
|
SUSE Linux Enterprise Server 12 SP5 |
KVM (SUSE Linux Enterprise Server 15 SP6 guest must use UEFI boot) |
|
SUSE Linux Enterprise Server 15 SP3 to SP7 |
KVM |
Windows Server 2019, 2022, 2025
You can also search in the SUSE YES certification database.
Support for SUSE host operating systems is full L3 (both for the guest and host), according to the respective product lifecycle.
SUSE provides full L3 support for SUSE Linux Enterprise Server guests within third-party host environments.
Support for the host and cooperation with SUSE Linux Enterprise Server guests must be provided by the host system's vendor.
4.5 Supported guest operating systems #
This section lists the support status for guest operating systems virtualized on top of SUSE Linux Enterprise Server 16.0 for KVM hypervisors.
Microsoft Windows guests can be rebooted by libvirt/virsh only if
paravirtualized drivers are installed in the guest. Refer to
https://www.suse.com/products/vmdriverpack/ for
more details on downloading and installing PV drivers.
SUSE Linux Enterprise Server 12 SP5
SUSE Linux Enterprise Server 15 SP3, 15 SP4, 15 SP5, 15 SP6, 15 SP6
SUSE Linux Enterprise Micro 6.0, 6.1, 6.2
Windows Server 2022, 2025
Oracle Linux 7, 8
SLED 15 SP3
Windows 10 / 11
Refer to the SUSE Multi-Linux Support documentation at https://documentation.suse.com/liberty for the list of available combinations and supported releases. In other cases, they are supported on a limited basis (L2, fixes if reasonable).
In other combinations, L2 support is provided but fixes are available only if feasible. SUSE fully supports the host OS (hypervisor). The guest OS issues need to be supported by the respective OS vendor. If an issue fix involves both the host and guest environments, the customer needs to approach both SUSE and the guest VM OS vendor.
All guest operating systems are supported both fully virtualized and paravirtualized. The exception is Windows systems, which are only supported fully virtualized (but they can use PV drivers: https://www.suse.com/products/vmdriverpack/), and OES operating systems, which are supported only paravirtualized.
All guest operating systems are supported both in 32-bit and 64-bit environments, unless stated otherwise.
4.5.1 Availability of paravirtualized drivers #
To improve the performance of the guest operating system, paravirtualized drivers are provided when available. Although they are not required, it is strongly recommended to use them.
The paravirtualized drivers are available as follows:
- Red Hat
Available since Red Hat Enterprise Linux 5.4. Starting from Red Hat Enterprise Linux 7.2, Red Hat removed the PV drivers.
- Windows
SUSE has developed Virtio-based drivers for Windows, which are available in the Virtual Machine Driver Pack (VMDP). For more information, see https://www.suse.com/products/vmdriverpack/.
4.6 Supported VM migration scenarios #
SUSE Linux Enterprise Server supports migrating a virtual machine from one physical host to another.
4.6.1 Offline migration scenarios #
SUSE supports offline migration, powering off a guest VM, then moving it to a host running a different SLE product, from SLE 12 to SLE 15 SPX. The following host operating system combinations are fully supported (L3) for migrating guests from one host to another:
| Target SLES host | 12 SP3 | 12 SP4 | 12 SP5 | 15 GA | 15 SP1 | 15 SP2 | 15 SP3 | 15 SP4 | 15 SP5 | 15 SP6 |
|---|---|---|---|---|---|---|---|---|---|---|
| Source SLES host | ||||||||||
| 12 SP3 | ✓ | ✓ | ✓ | ✓ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| 12 SP4 | ❌ | ✓ | ✓ | ✓1 | ✓ | ❌ | ❌ | ❌ | ❌ | ❌ |
| 12 SP5 | ❌ | ❌ | ✓ | ❌ | ✓ | ✓ | ❌ | ❌ | ❌ | ❌ |
| 15 GA | ❌ | ❌ | ❌ | ❌ | ✓ | ✓ | ✓ | ❌ | ❌ | ❌ |
| 15 SP1 | ❌ | ❌ | ❌ | ❌ | ✓ | ✓ | ✓ | ❌ | ❌ | ❌ |
| 15 SP2 | ❌ | ❌ | ❌ | ❌ | ❌ | ✓ | ✓ | ✓ | ❌ | ❌ |
| 15 SP3 | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✓ | ✓ | ✓ | ✓ |
| 15 SP4 | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✓ | ✓ | ✓ |
| 15 SP5 | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✓ | ✓ |
| 15 SP6 | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✓ |
| ✓ |
Fully compatible and fully supported |
| ✓1 |
Supported for KVM hypervisor only |
| ❌ |
Not supported |
4.6.2 Live migration scenarios #
This section lists support status of live migration scenarios when running virtualized on top of SLES. The following host operating system combinations are fully supported (L3 according to the respective product life cycle).
SUSE always supports live migration of virtual machines between hosts running SLES with successive service pack numbers. For example, from SLES 16 to 16.1.
SUSE strives to support live migration of virtual machines from a host running a service pack under LTSS to a host running a newer service pack, within the same major version of SUSE Linux Enterprise Server. SUSE only performs minimal testing of LTSS-to-newer migration scenarios and recommends thorough on-site testing before attempting to migrate critical virtual machines.
SLES 15 SP6 includes kernel patches and tooling to enable Intel TDX Confidential Computing technology in the product. As this technology is not yet fully ready for a production environment, it is provided as a technology preview.
| Target SLES host | 15 SP7 | 16 |
|---|---|---|
| Source SLES host | ||
| 15 SP7 | ✓ | ❌ |
| 16 | ❌ | ✓2 |
| ✓ |
Fully compatible and fully supported |
| ✓2 |
When available |
| ❌ |
Not supported |
4.7 Feature support #
Nested virtualization allows you to run a virtual machine inside another VM while still using hardware acceleration from the host. It has low performance and adds more complexity while debugging. Nested virtualization is normally used for testing purposes. In SUSE Linux Enterprise Server, nested virtualization is a technology preview. It is only provided for testing and is not supported. Bugs can be reported, but they are treated with low priority. Any attempt to live migrate or to save or restore VMs in the presence of nested virtualization is also explicitly unsupported.
Post-copy is a method to live migrate virtual machines that is intended to get VMs running as soon as possible on the destination host, and have the VM RAM transferred gradually in the background over time as needed. Under certain conditions, this can be an optimization compared to the traditional pre-copy method. However, this comes with a major drawback: An error occurring during the migration (especially a network failure) can cause the whole VM RAM contents to be lost. Therefore, we recommend using pre-copy only in production, while post-copy can be used for testing and experimentation in case losing the VM state is not a major concern.
4.7.1 Guest feature support #
Hotplugging of virtual network and virtual block devices, and resizing, shrinking and restoring dynamic virtual memory are supported in KVM only when PV drivers are used (VMDP).
For machines that support Intel FlexMigration, CPU-ID masking and faulting allow for more flexibility in cross-CPU migration.
For KVM, a detailed description of supported limits, features,
recommended settings and scenarios, and other useful information is
maintained in kvm-supported.txt. This file is
part of the KVM package and can be found in
/usr/share/doc/packages/qemu-kvm.
| Features | KVM FV guest | ||
|---|---|---|---|
| Virtual network and virtual block device hotplugging | ✓ | ||
| Virtual CPU Hotplug | ❌ | ||
| Virtual CPU Overcommit | ✓ | ||
| Dynamic virtual memory resize | ✓ | ||
| VM save and restore | ✓ | ||
| VM Live Migration | ✓ | ||
| VM snapshot | ✓ | ||
| Advanced debugging with GDBC | ✓ | ||
| Memory ballooning | ❌ | ||
| PCI Pass-Through | ✓ | ||
| AMD SEV ans SEV-SNP | ✓ [3] |
| ✓ |
Fully compatible and fully supported |
| ❌ |
Not supported |
| [1] | NetWare guests are excluded. |
| [2] | See https://documentation.suse.com/sles/html/SLES-amd-sev/article-amd-sev.html. |
5 libvirt daemons #
A libvirt deployment for accessing KVM requires one or more
daemons to be installed and active on the host. libvirt provides two
daemon deployment options: monolithic or modular daemons. libvirt has
always provided the single monolithic daemon libvirtd. It includes the
primary hypervisor drivers and all secondary drivers needed for managing
storage, networking, node devices, etc. The monolithic libvirtd also
provides secure remote access for external clients. Over time, libvirt
added support for modular daemons, where each driver runs in its own
daemon, allowing users to customize their libvirt deployment. Modular
daemons are enabled by default, but a deployment can be switched to the
traditional monolithic daemon by disabling the individual daemons and
enabling libvirtd.
The modular daemon deployment is useful in scenarios where minimal
libvirt support is needed. For example, if virtual machine storage and
networking is not provided by libvirt, the
libvirt-daemon-driver-storage and
libvirt-daemon-driver-network packages are not
required. Kubernetes is an example of an extreme case, where it handles all
networking, storage, cgroups and namespace integration, etc. Only the
libvirt-daemon-driver-QEMU package, providing
virtqemud, needs to be installed.
Modular daemons allow configuring a custom libvirt deployment containing
only the components required for the use case.
5.1 Starting and stopping the modular daemons #
The modular daemons are named after the driver which they are running,
with the pattern “virtDRIVERd”.
They are configured via the files
/etc/libvirt/virtDRIVERd.conf.
SUSE supports the virtqemud
hypervisor daemons, along with all the secondary daemons:
virtnetworkd - The virtual network management daemon which provides
libvirt's virtual network management APIs. For example, virtnetworkd can be used to create a NAT virtual network on the host for use by virtual machines.virtnodedevd - The host physical device management daemon which provides
libvirt's node device management APIs. For example, virtnodedevd can be used to detach a PCI device from the host for use by a virtual machine.virtnwfilterd - The host firewall management daemon which provides
libvirt's firewall management APIs. For example, virtnwfilterd can be used to configure network traffic filtering rules for virtual machines.virtsecretd - The host secret management daemon which provides
libvirt's secret management APIs. For example, virtsecretd can be used to store a key associated with a LUKs volume.virtstoraged - The host storage management daemon which provides
libvirt's storage management APIs. virtstoraged can be used to create storage pools and create volumes from those pools.virtinterfaced - The host NIC management daemon which provides
libvirt's host network interface management APIs. For example, virtinterfaced can be used to create a bonded network device on the host. SUSE discourages the use oflibvirt's interface management APIs in favor of default networking tools like wicked or NetworkManager. It is recommended to disable virtinterfaced.virtproxyd - A daemon to proxy connections between the traditional
libvirtdsockets and the modular daemon sockets. With a modularlibvirtdeployment, virtproxyd allows remote clients to access thelibvirtAPIs similar to the monolithiclibvirtd. It can also be used by local clients that connect to the monolithiclibvirtdsockets.virtlogd - A daemon to manage logs from virtual machine consoles. virtlogd is also used by the monolithic
libvirtd. The monolithic daemon and virtqemudsystemdunit files require virtlogd, so it is not necessary to explicitly start virtlogd.virtlockd - A daemon to manage locks held against virtual machine resources such as disks. virtlockd is also used by the monolithic
libvirtd. The monolithic daemon, virtqemud,systemdunit files require virtlockd, so it is not necessary to explicitly start virtlockd.
virtlogd and
virtlockd are also used by the
monolithic libvirtd. These daemons have always been separate from
libvirtd for security reasons.
By default, the modular daemons listen for connections on the
/var/run/libvirt/virtDRIVERd-sock
and
/var/run/libvirt/virtDRIVERd-sock-ro
Unix Domain Sockets. The client library prefers these sockets over the
traditional /var/run/libvirt/libvirtd-sock. The
virtproxyd daemon is available for remote clients or local clients
expecting the traditional libvirtd socket.
The virtqemud and
virtnetworkd,
virtnodedevd,
virtnwfilterd,
virtstoraged and
virtsecretd are also enabled in
the presets, ensuring the daemons are enabled and available when the
corresponding packages are installed. Although enabled in presets for
convenience, the modular daemons can also be managed with their systemd
unit files:
virtDRIVERd.service - The main unit file for launching the virtDRIVERd daemon. We recommend configuring the service to start on boot if VMs are also configured to start on host boot.
virtDRIVERd.socket - The unit file corresponding to the main read-write UNIX socket
/var/run/libvirt/virtDRIVERd-sock. We recommend starting this socket on boot by default.virtDRIVERd-ro.socket - The unit file corresponding to the main read-only UNIX socket
/var/run/libvirt/virtDRIVERd-sock-ro. We recommend starting this socket on boot by default.virtDRIVERd-admin.socket - The unit file corresponding to the administrative UNIX socket
/var/run/libvirt/virtDRIVERd-admin-sock. We recommend starting this socket on boot by default.
When systemd socket activation is used, several configuration settings
in virtDRIVERd.conf are no longer honored.
Instead, these settings must be controlled via the system unit files:
unix_sock_group - UNIX socket group owner, controlled via the
SocketGroupparameter in thevirtDRIVERd.socketandvirtDRIVERd-ro.socketunit files.unix_sock_ro_perms - Read-only UNIX socket permissions, controlled via the
SocketModeparameter in thevirtDRIVERd-ro.socketunit file.unix_sock_rw_perms - Read-write UNIX socket permissions, controlled via the
SocketModeparameter in thevirtDRIVERd.socketunit file.unix_sock_admin_perms - Admin UNIX socket permissions, controlled via the
SocketModeparameter in thevirtDRIVERd-admin.socketunit file.unix_sock_dir - Directory in which all UNIX sockets are created, independently controlled via the
ListenStreamparameter in any of thevirtDRIVERd.socket,virtDRIVERd-ro.socketandvirtDRIVERd-admin.socketunit files.
5.2 Starting and stopping the monolithic daemon #
The monolithic daemon is known as libvirtd and is configured via
/etc/libvirt/libvirtd.conf. libvirtd is managed
with several systemd unit files:
libvirtd.service - The main
systemdunit file for launchinglibvirtd. We recommend configuringlibvirtd.serviceto start on boot if VMs are also configured to start on host boot.libvirtd.socket - The unit file corresponding to the main read-write UNIX socket
/var/run/libvirt/libvirt-sock. We recommend enabling this unit on boot.libvirtd-ro.socket - The unit file corresponding to the main read-only UNIX socket
/var/run/libvirt/libvirt-sock-ro. We recommend enabling this unit on boot.libvirtd-admin.socket - The unit file corresponding to the administrative UNIX socket
/var/run/libvirt/libvirt-admin-sock. We recommend enabling this unit on boot.libvirtd-tcp.socket - The unit file corresponding to the TCP 16509 port for non-TLS remote access. This unit should not be configured to start on boot until the administrator has configured a suitable authentication mechanism.
libvirtd-tls.socket - The unit file corresponding to the TCP 16509 port for TLS remote access. This unit should not be configured to start on boot until the administrator has deployed x509 certificates and optionally configured a suitable authentication mechanism.
When systemd socket activation is used, certain configuration settings
in libvirtd.conf are no longer honored. Instead,
these settings must be controlled via the system unit files:
listen_tcp - TCP socket usage is enabled by starting the
libvirtd-tcp.socketunit file.listen_tls - TLS socket usage is enabled by starting the
libvirtd-tls.socketunit file.tcp_port - Port for the non-TLS TCP socket, controlled via the
ListenStreamparameter in thelibvirtd-tcp.socketunit file.tls_port - Port for the TLS TCP socket, controlled via the
ListenStreamparameter in thelibvirtd-tls.socketunit file.listen_addr - IP address to listen on, independently controlled via the
ListenStreamparameter in thelibvirtd-tcp.socketorlibvirtd-tls.socketunit files.unix_sock_group - UNIX socket group owner, controlled via the
SocketGroupparameter in thelibvirtd.socketandlibvirtd-ro.socketunit files.unix_sock_ro_perms - Read-only UNIX socket permissions, controlled via the
SocketModeparameter in thelibvirtd-ro.socketunit file.unix_sock_rw_perms - Read-write UNIX socket permissions, controlled via the
SocketModeparameter in thelibvirtd.socketunit file.unix_sock_admin_perms - Admin UNIX socket permissions, controlled via the
SocketModeparameter in thelibvirtd-admin.socketunit file.unix_sock_dir - Directory in which all UNIX sockets are created, independently controlled via the
ListenStreamparameter in any of thelibvirtd.socket,libvirtd-ro.socketandlibvirtd-admin.socketunit files.
5.3 Switching to the monolithic daemon #
Several services need to be changed when switching from modular to the monolithic daemon. It is recommended to stop or evict any running virtual machines before switching between the daemon options.
Stop the modular daemons and their sockets. The following example disables the QEMU daemon for KVM and several secondary daemons.
for drv in qemu network nodedev nwfilter secret storage do
>sudosystemctl stop virt${drv}d.service>sudosystemctl stop virt${drv}d{,-ro,-admin}.socket doneDisable future start of the modular daemons
for drv in qemu network nodedev nwfilter secret storage do
>sudosystemctl disable virt${drv}d.service>sudosystemctl disable virt${drv}d{,-ro,-admin}.socket doneEnable the monolithic
libvirtdservice and sockets>sudosystemctl enable libvirtd.service>sudosystemctl enable libvirtd{,-ro,-admin}.socketStart the monolithic
libvirtdsockets>sudosystemctl start libvirtd{,-ro,-admin}.socket
6 Preparing the VM Host Server #
Before you can install guest virtual machines, you need to prepare the VM Host Server to provide the guests with the resources that they need for their operation. Specifically, you need to configure:
Networking so that guests can make use of the network connection provided the host.
A storage pool reachable from the host so that the guests can store their disk images.
6.1 Configuring networks #
There are two common network configurations to provide a VM Guest with a network connection:
A network bridge. This is the default and recommended way of providing the guests with network connection.
A virtual network with forwarding enabled.
6.1.1 Network bridge #
The network bridge configuration provides a Layer 2 switch for VM Guests, switching Layer 2 Ethernet packets between ports on the bridge based on MAC addresses associated with the ports. This gives the VM Guest Layer 2 access to the VM Host Server's network. This configuration is analogous to connecting the VM Guest's virtual Ethernet cable into a hub that is shared with the host and other VM Guests running on the host. The configuration is often referred to as shared physical device.
The network bridge configuration is the default configuration of SUSE Linux Enterprise Server when configured as a KVM hypervisor. It is the preferred configuration when you simply want to connect VM Guests to the VM Host Server's LAN.
6.1.1.1 Managing network bridges from the command line #
This section includes procedures to add or remove network bridges using the command line.
6.1.1.1.1 Adding a network bridge #
To add a new network bridge device on VM Host Server, follow these steps:
Log in as
rooton the VM Host Server where you want to create a new network bridge.Choose a name for the new bridge—virbr_test in our example—and run
#ip link add name VIRBR_TEST type bridgeCheck if the bridge was created on VM Host Server:
#bridge vlan [...] virbr_test 1 PVID Egress Untaggedvirbr_testis present, but is not associated with any physical network interface.Bring the network bridge up and add a network interface to the bridge:
#ip link set virbr_test up#ip link set eth1 master virbr_testImportant: Network interface must be unusedYou can only assign a network interface that is not yet used by another network bridge.
Optionally, enable STP (see Spanning Tree Protocol):
#bridge link set dev virbr_test cost 4
6.1.1.1.2 Deleting a network bridge #
To delete an existing network bridge device on VM Host Server from the command line, follow these steps:
Log in as
rooton the VM Host Server where you want to delete an existing network bridge.List existing network bridges to identify the name of the bridge to remove:
#bridge vlan [...] virbr_test 1 PVID Egress UntaggedDelete the bridge:
#ip link delete dev virbr_test
6.1.1.2 Adding a network bridge with nmcli #
This section includes procedures to add a network bridge with NetworkManager's
command line tool nmcli.
List active network connections:
>sudonmcli connection show --active NAME UUID TYPE DEVICE Ethernet connection 1 84ba4c22-0cfe-46b6-87bb-909be6cb1214 ethernet eth0Add a new bridge device named
br0and verify its creation:>sudonmcli connection add type bridge ifname br0 Connection 'bridge-br0' (36e11b95-8d5d-4a8f-9ca3-ff4180eb89f7) \ successfully added.>sudonmcli connection show --active NAME UUID TYPE DEVICE bridge-br0 36e11b95-8d5d-4a8f-9ca3-ff4180eb89f7 bridge br0 Ethernet connection 1 84ba4c22-0cfe-46b6-87bb-909be6cb1214 ethernet eth0Optionally, you can view the bridge settings:
>sudonmcli -f bridge connection show bridge-br0 bridge.mac-address: -- bridge.stp: yes bridge.priority: 32768 bridge.forward-delay: 15 bridge.hello-time: 2 bridge.max-age: 20 bridge.ageing-time: 300 bridge.group-forward-mask: 0 bridge.multicast-snooping: yes bridge.vlan-filtering: no bridge.vlan-default-pvid: 1 bridge.vlans: --Link the bridge device to the physical Ethernet device
eth0:>sudonmcli connection add type bridge-slave ifname eth0 master br0Disable the
eth0interface and enable the new bridge:>sudonmcli connection down "Ethernet connection 1">sudonmcli connection up bridge-br0 Connection successfully activated (master waiting for slaves) \ (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/9)
6.1.1.3 Using VLAN interfaces #
Sometimes it is necessary to create a private connection either between two VM Host Servers or between VM Guest systems. For example, to migrate a VM Guest to hosts in a different network segment. Or to create a private bridge that only VM Guest systems may connect to (even when running on different VM Host Server systems). An easy way to build such connections is to set up VLAN networks.
VLAN interfaces are commonly set up on the VM Host Server. They either interconnect the different VM Host Server systems, or they may be set up as a physical interface to an otherwise virtual-only bridge. It is even possible to create a bridge with a VLAN as a physical interface that has no IP address in the VM Host Server. That way, the guest systems have no possibility to access the host over this network.
It is also possible to use the VLAN interface as a physical interface of a bridge. This makes it possible to connect several VM Host Server-only networks and allows live migration of VM Guest systems that are connected to such a network.
6.1.2 Virtual networks #
libvirt-managed virtual networks are similar to bridged networks, but
typically have no Layer 2 connection to the VM Host Server. Connectivity to
the VM Host Server's physical network is accomplished with Layer 3
forwarding, which introduces additional packet processing on the
VM Host Server as compared to a Layer 2 bridged network. Virtual networks
also provide DHCP and DNS services for VM Guests. For more information
on libvirt virtual networks, see the Network XML
format documentation at
https://libvirt.org/formatnetwork.html.
A standard libvirt installation on SUSE Linux Enterprise Server already comes with a
predefined virtual network named default. It
provides DHCP and DNS services for the network, along with connectivity
to the VM Host Server's physical network using the network address
translation (NAT) forwarding mode. Although it is predefined, the
default virtual network needs to be explicitly
enabled by the administrator. For more information on the forwarding
modes supported by libvirt, see the
Connectivity section of the Network
XML format documentation at
https://libvirt.org/formatnetwork.html#elementsConnect.
libvirt-managed virtual networks can be used to satisfy a wide range
of use cases, but are commonly used on VM Host Servers that have a wireless
connection or dynamic/sporadic network connectivity, such as laptops.
Virtual networks are also useful when the VM Host Server's network has
limited IP addresses, allowing forwarding of packets between the
virtual network and the VM Host Server's network. However, most server use
cases are better suited for the network bridge configuration, where
VM Guests are connected to the VM Host Server's LAN.
Enabling forwarding mode in a libvirt virtual network enables
forwarding in the VM Host Server by setting
/proc/sys/net/ipv4/ip_forward and
/proc/sys/net/ipv6/conf/all/forwarding to 1,
which turns the VM Host Server into a router. Restarting the VM Host Server's
network may reset the values and disable forwarding. To avoid this
behavior, explicitly enable forwarding in the VM Host Server by editing the
/etc/sysctl.conf file and adding:
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
6.1.2.1 Managing virtual networks with Virtual Machine Manager #
You can define, configure and operate virtual networks with Virtual Machine Manager.
6.1.2.1.1 Defining virtual networks #
Start Virtual Machine Manager. In the list of available connections, right-click the name of the connection for which you need to configure the virtual network, and then select .
In the window, click the tab. You can see the list of all virtual networks available for the current connection. On the right, there are details of the selected virtual network.
Figure 2: Connection details #To add a new virtual network, click .
Specify a name for the new virtual network.
Figure 3: Create virtual network #Specify the networking mode. For the and types, you can specify to which device to forward network communications. While (network address translation) remaps the virtual network address space and allows sharing a single IP address, forwards packets from the virtual network to the VM Host Server's physical network with no translation.
If you need IPv4 networking, activate and specify the IPv4 network address. If you need a DHCP server, activate and specify the assignable IP address range.
If you need IPv6 networking, activate and specify the IPv6 network address. If you need a DHCP server, activate and specify the assignable IP address range.
To specify a different domain name than the name of the virtual network, select under and enter it here.
Click to create the new virtual network. On the VM Host Server, a new virtual network bridge
virbrXis available, which corresponds to the newly created virtual network. You can check withbridge link.libvirtautomatically adds iptables rules to allow traffic to/from guests attached to the new virbrX device.
6.1.2.1.2 Starting virtual networks #
To start a virtual network that is temporarily stopped, follow these steps:
Start Virtual Machine Manager. In the list of available connections, right-click the name of the connection for which you need to configure the virtual network, and then select .
In the window, click the tab. You can see the list of all virtual networks available for the current connection.
To start the virtual network, click .
6.1.2.1.3 Stopping virtual networks #
To stop an active virtual network, follow these steps:
Start Virtual Machine Manager. In the list of available connections, right-click the name of the connection for which you need to configure the virtual network, and then select .
In the window, click the tab. You can see the list of all virtual networks available for the current connection.
Select the virtual network to be stopped, then click .
6.1.2.1.4 Deleting virtual networks #
To delete a virtual network from VM Host Server, follow these steps:
Start Virtual Machine Manager. In the list of available connections, right-click the name of the connection for which you need to configure the virtual network, and then select .
In the window, click the tab. You can see the list of all virtual networks available for the current connection.
Select the virtual network to be deleted, then click .
6.1.2.1.5 Obtaining IP addresses with nsswitch for NAT networks (in KVM) #
On VM Host Server, install libvirt-nss, which provides NSS support for libvirt:
>sudozypper in libvirt-nssAdd
libvirtto/etc/nsswitch.conf:... hosts: files libvirt mdns_minimal [NOTFOUND=return] dns ...
If NSCD is running, restart it:
>sudosystemctl restart nscd
Now you can reach the guest system by name from the host.
The NSS module has limited functionality. It reads
/var/lib/libvirt/dnsmasq/*.status files to
find the host name and corresponding IP addresses in a JSON record
describing each lease provided by dnsmasq. Host
name translation can only be done on those VM Host Servers using a
libvirt-managed bridged network backed by
dnsmasq.
6.1.2.2 Managing virtual networks with virsh #
You can manage libvirt-provided virtual networks with the
virsh command line tool. To view all network
related virsh commands, run
>sudovirsh help network Networking (help keyword 'network'): net-autostart autostart a network net-create create a network from an XML file net-define define (but don't start) a network from an XML file net-destroy destroy (stop) a network net-dumpxml network information in XML net-edit edit XML configuration for a network net-event Network Events net-info network information net-list list networks net-name convert a network UUID to network name net-start start a (previously defined) inactive network net-undefine undefine an inactive network net-update update parts of an existing network's configuration net-uuid convert a network name to network UUID
To view brief help information for a specific
virsh command, run virsh help
VIRSH_COMMAND:
>sudovirsh help net-create NAME net-create - create a network from an XML file SYNOPSIS net-create <file> DESCRIPTION Create a network. OPTIONS [--file] <string> file containing an XML network description
6.1.2.2.1 Creating a network #
To create a new running virtual network, run
>sudovirsh net-create VNET_DEFINITION.xml
The VNET_DEFINITION.xml XML file
includes the definition of the virtual network that libvirt
accepts.
To define a new virtual network without activating it, run
>sudovirsh net-define VNET_DEFINITION.xml
The following examples illustrate definitions of different types of virtual networks.
The following configuration allows VM Guests outgoing connectivity if it is available on the VM Host Server. Without VM Host Server networking, it allows guests to talk directly to each other.
<network> <name>vnet_nated</name>1 <bridge name="virbr1"/>2 <forward mode="nat"/>3 <ip address="192.168.122.1" netmask="255.255.255.0">4 <dhcp> <range start="192.168.122.2" end="192.168.122.254"/>5 <host mac="52:54:00:c7:92:da" name="host1.testing.com" \ ip="192.168.1.101"/>6 <host mac="52:54:00:c7:92:db" name="host2.testing.com" \ ip="192.168.1.102"/> <host mac="52:54:00:c7:92:dc" name="host3.testing.com" \ ip="192.168.1.103"/> </dhcp> </ip> </network>
The name of the new virtual network. | |
The name of the bridge device used to construct the virtual
network. When defining a new network with a <forward>
mode of | |
Inclusion of the <forward> element indicates that the
virtual network is connected to the physical LAN. The
| |
The IP address and netmask for the network bridge. | |
Enable DHCP server for the virtual network, offering IP
addresses ranging from the specified | |
The optional <host> elements specify hosts that are
given names and predefined IP addresses by the built-in DHCP
server. Any IPv4 host element must specify the following: the
MAC address of the host to be assigned a given name, the IP
to be assigned to that host, and the name to be given to that
host by the DHCP server. An IPv6 host element differs
slightly from that for IPv4: there is no
|
The following configuration routes traffic from the virtual network to the LAN without applying any NAT. The IP address range must be preconfigured in the routing tables of the router on the VM Host Server network.
<network>
<name>vnet_routed</name>
<bridge name="virbr1"/>
<forward mode="route" dev="eth1"/>1
<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>
The guest traffic may only go out via the
|
This configuration provides an isolated private network. The guests can talk to each other, and to VM Host Server, but cannot reach any other machines on the LAN, as the <forward> element is missing in the XML description.
<network> <name>vnet_isolated</name> <bridge name="virbr3"/> <ip address="192.168.152.1" netmask="255.255.255.0"> <dhcp> <range start="192.168.152.2" end="192.168.152.254"/> </dhcp> </ip> </network>
This configuration shows how to use an existing VM Host Server's
network bridge br0. VM Guests are directly
connected to the physical network. Their IP addresses are all on
the subnet of the physical network, and there are no restrictions
on incoming or outgoing connections.
<network>
<name>host-bridge</name>
<forward mode="bridge"/>
<bridge name="br0"/>
</network>6.1.2.2.2 Listing networks #
To list all virtual networks available to libvirt, run:
>sudovirsh net-list --all Name State Autostart Persistent ---------------------------------------------------------- crowbar active yes yes vnet_nated active yes yes vnet_routed active yes yes vnet_isolated inactive yes yes
To list available domains, run:
>sudovirsh list Id Name State ---------------------------------------------------- 1 nated_sles12sp3 running ...
To get a list of interfaces of a running domain, run
domifaddr DOMAIN, or
optionally specify the interface to limit the output to this
interface. By default, it additionally outputs their IP and MAC
addresses:
>sudovirsh domifaddr nated_sles12sp3 --interface vnet0 --source lease Name MAC address Protocol Address ------------------------------------------------------------------------------- vnet0 52:54:00:9e:0d:2b ipv6 fd00:dead:beef:55::140/64 - - ipv4 192.168.100.168/24
To print brief information of all virtual interfaces associated with the specified domain, run:
>sudovirsh domiflist nated_sles12sp3 Interface Type Source Model MAC --------------------------------------------------------- vnet0 network vnet_nated virtio 52:54:00:9e:0d:2b
6.1.2.2.3 Getting details about a network #
To get detailed information about a network, run:
>sudovirsh net-info vnet_routed Name: vnet_routed UUID: 756b48ff-d0c6-4c0a-804c-86c4c832a498 Active: yes Persistent: yes Autostart: yes Bridge: virbr5
6.1.2.2.4 Starting a network #
To start an inactive network that was already defined, find its name (or unique identifier, UUID) with:
>sudovirsh net-list --inactive Name State Autostart Persistent ---------------------------------------------------------- vnet_isolated inactive yes yes
Then run:
>sudovirsh net-start vnet_isolated Network vnet_isolated started
6.1.2.2.5 Stopping a network #
To stop an active network, find its name (or unique identifier, UUID) with:
>sudovirsh net-list --inactive Name State Autostart Persistent ---------------------------------------------------------- vnet_isolated active yes yes
Then run:
>sudovirsh net-destroy vnet_isolated Network vnet_isolated destroyed
6.1.2.2.6 Removing a network #
To remove the definition of an inactive network from VM Host Server permanently, run:
>sudovirsh net-undefine vnet_isolated Network vnet_isolated has been undefined
6.2 Configuring a storage pool #
When managing a VM Guest on the VM Host Server itself, you can access the
complete file system of the VM Host Server to attach or create virtual hard
disks or to attach existing images to the VM Guest. However, this is not
possible when managing VM Guests from a remote host. For this reason,
libvirt supports so called “Storage Pools”, which can be
accessed from remote machines.
To be able to access CD/DVD ISO images on the VM Host Server from remote clients, they also need to be placed in a storage pool.
libvirt knows two different types of storage: volumes and pools.
- Storage volume
A storage volume is a storage device that can be assigned to a guest—a virtual disk or a CD/DVD/floppy image. Physically, it can be a block device, for example, a partition or a logical volume, or a file on the VM Host Server.
- Storage pool
A storage pool is a storage resource on the VM Host Server that can be used for storing volumes, similar to network storage for a desktop machine. Physically it can be one of the following types:
- File system directory ()
A directory for hosting image files. The files can be either one of the supported disk formats (raw or qcow2), or ISO images.
- Physical disk device ()
Use a complete physical disk as storage. A partition is created for each volume that is added to the pool.
- Pre-formatted block device ()
Specify a partition to be used in the same way as a file system directory pool (a directory for hosting image files). The only difference to using a file system directory is that
libvirttakes care of mounting the device.- iSCSI target (iscsi)
Set up a pool on an iSCSI target. You need to have been logged in to the volume once before to use it with
libvirt. Volume creation on iSCSI pools is not supported; instead, each existing Logical Unit Number (LUN) represents a volume. Each volume/LUN also needs a valid (empty) partition table or disk label before you can use it. If missing, usefdiskto add it:>sudofdisk -cu /dev/disk/by-path/ip-192.168.2.100:3260-iscsi-iqn.2010-10.com.example:[...]-lun-2 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xc15cdc4e. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.- LVM volume group (logical)
Use an LVM volume group as a pool. You can either use a predefined volume group, or create a group by specifying the devices to use. Storage volumes are created as partitions on the volume.
Warning: Deleting the LVM-based poolWhen the LVM-based pool is deleted in the Storage Manager, the volume group is deleted as well. This results in a non-recoverable loss of all data stored on the pool.
- Multipath devices ()
At the moment, multipathing support is limited to assigning existing devices to the guests. Volume creation or configuring multipathing from within
libvirtis not supported.- Network exported directory ()
Specify a network directory to be used in the same way as a file system directory pool (a directory for hosting image files). The only difference to using a file system directory is that
libvirttakes care of mounting the directory. The supported protocol is NFS.- SCSI host adapter ()
Use an SCSI host adapter in almost the same way as an iSCSI target. We recommend to use a device name from
/dev/disk/by-*rather than/dev/sdX. The latter can change, for example, when adding or removing hard disks. Volume creation on iSCSI pools is not supported. Instead, each existing LUN (Logical Unit Number) represents a volume.
To avoid data loss or data corruption, do not attempt to use resources
such as LVM volume groups, iSCSI targets, etc., that are also used to
build storage pools on the VM Host Server. There is no need to connect to
these resources from the VM Host Server or to mount them on the
VM Host Server—libvirt takes care of this.
Do not mount partitions on the VM Host Server by label. Under certain circumstances it is possible that a partition is labeled from within a VM Guest with a name existing on the VM Host Server.
6.2.1 Managing storage with virsh #
Managing storage from the command line is also possible by using
virsh. However, creating storage pools is currently
not supported by SUSE. Therefore, this section is restricted to
documenting functions such as starting, stopping and deleting pools,
and volume management.
A list of all virsh subcommands for managing pools
and volumes is available by running virsh help pool
and virsh help volume, respectively.
6.2.1.1 Listing pools and volumes #
List all pools currently active by executing the following command.
To also list inactive pools, add the option --all:
> virsh pool-list --details
Details about a specific pool can be obtained with the
pool-info subcommand:
> virsh pool-info POOLBy default, volumes can only be listed per pool. To list all volumes from a pool, enter the following command.
> virsh vol-list --details POOL
At the moment virsh offers no tools to show
whether a volume is used by a guest or not. The following procedure
describes a way to list volumes from all pools that are currently
used by a VM Guest.
Create an XSLT stylesheet by saving the following content to a file, for example, ~/libvirt/guest_storage_list.xsl:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="text()"/> <xsl:strip-space elements="*"/> <xsl:template match="disk"> <xsl:text> </xsl:text> <xsl:value-of select="(source/@file|source/@dev|source/@dir)[1]"/> <xsl:text> </xsl:text> </xsl:template> </xsl:stylesheet>Run the following commands in a shell. It is assumed that the guest's XML definitions are all stored in the default location (
/etc/libvirt/qemu).xsltprocis provided by the packagelibxslt.SSHEET="$HOME/libvirt/guest_storage_list.xsl" cd /etc/libvirt/qemu for FILE in *.xml; do basename $FILE .xml xsltproc $SSHEET $FILE done
6.2.1.2 Starting, stopping, and deleting pools #
Use the virsh pool subcommands to start, stop or
delete a pool. Replace POOL with the
pool's name or its UUID in the following examples:
- Stopping a pool
>virsh pool-destroy POOLNote: A pool's state does not affect attached volumesVolumes from a pool attached to VM Guests are always available, regardless of the pool's state ( (stopped) or (started)). The state of the pool solely affects the ability to attach volumes to a VM Guest via remote management.
- Deleting a pool
>virsh pool-delete POOL- Starting a pool
>virsh pool-start POOL- Enable autostarting a pool
>virsh pool-autostart POOLOnly pools that are marked to autostart are automatically started if the VM Host Server reboots.
- Disable autostarting a pool
>virsh pool-autostart POOL --disable
6.2.1.3 Adding volumes to a storage pool #
virsh offers two ways to add volumes to storage
pools: either from an XML definition with
vol-create and vol-create-from
or via command line arguments with vol-create-as.
The first two methods are currently not supported by SUSE,
therefore this section focuses on the subcommand
vol-create-as.
To add a volume to an existing pool, enter the following command:
> virsh vol-create-as POOL1NAME2 12G --format3raw|qcow24 --allocation 4G5Name of the pool to which the volume should be added | |
Name of the volume | |
Size of the image, in this example 12 gigabytes. Use the suffixes k, M, G, T for kilobyte, megabyte, gigabyte, and terabyte, respectively. | |
Format of the volume. SUSE currently supports
| |
Optional parameter. By default,
When not specifying this parameter, a sparse image file with no
allocation is generated. To create a non-sparse volume, specify
the whole image size with this parameter (would be
|
6.2.1.3.1 Cloning existing volumes #
Another way to add volumes to a pool is to clone an existing volume. The new instance is always created in the same pool as the original.
> virsh vol-clone NAME_EXISTING_VOLUME1NAME_NEW_VOLUME2 --pool POOL36.2.1.4 Deleting volumes from a storage pool #
To permanently delete a volume from a pool, use the subcommand
vol-delete:
> virsh vol-delete NAME --pool POOL
--pool is optional. libvirt tries to locate the
volume automatically. If that fails, specify this parameter.
A volume is deleted in any case, regardless of whether it is currently used in an active or inactive VM Guest. There is no way to recover a deleted volume.
Whether a volume is used by a VM Guest can only be detected by using by the method described in Procedure 1, “Listing all storage volumes currently used on a VM Host Server”.
6.2.1.5 Attaching volumes to a VM Guest #
After you create a volume as described in Section 6.2.1.3, “Adding volumes to a storage pool”, you can attach it to a virtual machine and use it as a hard disk:
> virsh attach-disk DOMAIN SOURCE_IMAGE_FILE TARGET_DISK_DEVICEFor example:
> virsh attach-disk sles12sp3 /virt/images/example_disk.qcow2 sda2
To check if the new disk is attached, inspect the result of the
virsh dumpxml command:
# virsh dumpxml sles12sp3
[...]
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/virt/images/example_disk.qcow2'/>
<backingStore/>
<target dev='sda2' bus='scsi'/>
<alias name='scsi0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
[...]6.2.1.5.1 Hotplug or persistent change #
You can attach disks to both active and inactive domains. The
attachment is controlled by the --live and
--config options:
--liveHotplugs the disk to an active domain. The attachment is not saved in the domain configuration. Using
--liveon an inactive domain is an error.--configChanges the domain configuration persistently. The attached disk is then available after the next domain start.
--live--configHotplugs the disk and adds it to the persistent domain configuration.
virsh attach-device
virsh attach-device is the more generic form
of virsh attach-disk. You can use it to attach
other types of devices to a domain.
6.2.1.6 Detaching volumes from a VM Guest #
To detach a disk from a domain, use virsh
detach-disk:
# virsh detach-disk DOMAIN TARGET_DISK_DEVICEFor example:
# virsh detach-disk sles12sp3 sda2
You can control the attachment with the --live and
--config options as described in
Section 6.2.1.5, “Attaching volumes to a VM Guest”.
6.2.2 Managing storage with Virtual Machine Manager #
The Virtual Machine Manager provides a graphical interface—the Storage Manager—to manage storage volumes and pools. To access it, either right-click a connection and choose , or highlight a connection and choose › . Select the tab.
6.2.2.1 Adding a storage pool #
To add a storage pool, proceed as follows:
Click in the bottom left corner. The dialog appears.
Provide a for the pool (consisting of only alphanumeric characters and
_,-or.) and select a .Specify the required details below. They depend on the type of pool you are creating.
ImportantZFS pools are not supported.
- Type
: specify an existing directory.
- Type
: format of the device's partition table. Using should normally work. If not, get the required format by running the command
parted-lon the VM Host Server.: path to the device. It is recommended to use a device name from
/dev/disk/by-*rather than the simple/dev/sdX, since the latter can change, for example, when adding or removing hard disks. You need to specify the path that resembles the whole disk, not a partition on the disk (if existing).
- Type
: mount point on the VM Host Server file system.
file system format of the device. The default value
autoshould work.: path to the device file. It is recommended to use a device name from
/dev/disk/by-*rather than/dev/sdX, because the latter can change, for example, when adding or removing hard disks.
- Type
Get the necessary data by running the following command on the VM Host Server:
>sudoiscsiadm --mode nodeIt returns a list of iSCSI volumes with the following format. The elements in bold text are required:
IP_ADDRESS:PORT,TPGT TARGET_NAME_(IQN)
: the directory containing the device file. Use
/dev/disk/by-path(default) or/dev/disk/by-id.: host name or IP address of the iSCSI server.
: the iSCSI target name (iSCSI Qualified Name).
: the iSCSI initiator name.
- Type
: specify the device path of an existing volume group.
- Type
: support for multipathing is currently limited to making all multipath devices available. Therefore, specify an arbitrary string here. The path is required, otherwise the XML parser fails.
- Type
: mount point on the VM Host Server file system.
: IP address or host name of the server exporting the network file system.
: directory on the server that is being exported.
- Type
: host name of the server with an exported RADOS block device.
: name of the RADOS block device on the server.
- Type
: directory containing the device file. Use
/dev/disk/by-path(default) or/dev/disk/by-id.: name of the SCSI adapter.
Note: File browsingUsing the file browser by clicking is not possible when operating remotely.
Click to add the storage pool.
6.2.2.2 Managing storage pools #
Virtual Machine Manager's Storage Manager lets you create or delete volumes in a pool. You may also temporarily deactivate or permanently delete existing storage pools. Changing the basic configuration of a pool is currently not supported by SUSE.
6.2.2.2.1 Starting, stopping, and deleting pools #
The purpose of storage pools is to provide block devices located on the VM Host Server that can be added to a VM Guest when managing it from remote. To make a pool temporarily inaccessible from remote, click in the bottom left corner of the Storage Manager. Stopped pools are marked with and are grayed out in the list pane. By default, a newly created pool is automatically started of the VM Host Server.
To start an inactive pool and make it available from remote again, click in the bottom left corner of the Storage Manager.
Volumes from a pool attached to VM Guests are always available, regardless of the pool's state ( (stopped) or (started)). The state of the pool solely affects the ability to attach volumes to a VM Guest via remote management.
To permanently make a pool inaccessible, click in the bottom left corner of the Storage Manager. You can only delete inactive pools. Deleting a pool does not physically erase its contents on VM Host Server—it only deletes the pool configuration. However, you need to be extra careful when deleting pools, especially when deleting LVM volume group-based tools:
Deleting storage pools based on local file system directories, local partitions or disks has no effect on the availability of volumes from these pools currently attached to VM Guests.
Volumes located in pools of type iSCSI, SCSI, LVM group or Network Exported Directory become inaccessible from the VM Guest if the pool is deleted. Although the volumes themselves are not deleted, the VM Host Server can no longer access the resources.
Volumes on iSCSI/SCSI targets or Network Exported Directory become accessible again when creating an adequate new pool or when mounting/accessing these resources directly from the host system.
When deleting an LVM group-based storage pool, the LVM group definition is erased and the LVM group no longer exists on the host system. The configuration is not recoverable and all volumes from this pool are lost.
6.2.2.2.2 Adding volumes to a storage pool #
Virtual Machine Manager lets you create volumes in all storage pools, except in pools
of types Multipath, iSCSI or SCSI. A volume in these pools is
equivalent to a LUN and cannot be changed from within libvirt.
A new volume can either be created using the Storage Manager or while adding a new storage device to a VM Guest. In either case, select a storage pool from the left panel, then click .
Specify a for the image and choose an image format.
SUSE currently only supports
raworqcow2images. The latter option is not available on LVM group-based pools.Next to , specify the maximum size that the disk image is allowed to reach. Unless you are working with a
qcow2image, you can also set an amount for that should be allocated initially. If the two values differ, a sparse image file is created, which grows on demand.For
qcow2images, you can use a (also called “backing file”), which constitutes a base image. The newly createdqcow2image then only records the changes that are made to the base image.Start the volume creation by clicking .
6.2.2.2.3 Deleting volumes from a storage pool #
Deleting a volume can only be done from the Storage Manager, by selecting a volume and clicking . Confirm with .
Volumes can be deleted even if they are currently used in an active or inactive VM Guest. There is no way to recover a deleted volume.
Whether a volume is used by a VM Guest is indicated in the column in the Storage Manager.
7 Guest installation #
A VM Guest consists of an image containing an operating system and data files and a configuration file describing the VM Guest's virtual hardware resources. VM Guests are hosted on and controlled by the VM Host Server. This section provides generalized instructions for installing a VM Guest. For a list of supported VM Guests refer to Section 4.5, “Supported guest operating systems”.
Virtual machines have few if any requirements above those required to run the operating system. If the operating system has not been optimized for the virtual machine host environment, it can only run on hardware-assisted virtualization computer hardware, in full virtualization mode, and requires specific device drivers to be loaded. The hardware that is presented to the VM Guest depends on the configuration of the host.
You should be aware of any licensing issues related to running a single licensed copy of an operating system on multiple virtual machines. Consult the operating system license agreement for more information.
7.1 GUI-based guest installation #
You can change default values that are applied when creating new virtual machines. For example, to set UEFI as the default firmware type for new virtual machines, select › from Virtual Machine Manager's main menu, click and set as the firmware default.
The wizard helps you through the steps required to create a virtual machine and install its operating system. To start it, open the Virtual Machine Manager and select › .
Start the with Virtual Machine Manager.
Choose an installation source—either a locally available media or a network installation source. To set up your VM Guest from an existing image, choose .
Depending on your choice in the previous step, you need to provide the following data:
Specify the path on the VM Host Server to an ISO image containing the installation data. If it is available as a volume in a libvirt storage pool, you can also select it using .
Alternatively, choose a physical CD-ROM or DVD inserted in the optical drive of the VM Host Server.
Provide the pointing to the installation source. Valid URL prefixes are, for example,
ftp://,http://andhttps://.Under , provide a path to an auto-installation file (AutoYaST or Kickstart, for example) and kernel parameters. Having provided a URL, the operating system should be automatically detected correctly. If this is not the case, deselect and manually select the and .
To set up the VM Guest from an existing image, you need to specify the path on the VM Host Server to the image. If it is available as a volume in a libvirt storage pool, you can also select it using .
This installation method is suitable to create a virtual machine, manually configure its components and install its OS later. To adjust the VM to a specific product version, start typing its name, for example,
sles—and select the desired version when a match appears.
Choose the memory size and number of CPUs for the new virtual machine.
This step is omitted when is chosen in the first step.
Set up a virtual hard disk for the VM Guest. Either create a new disk image or choose an existing one from a storage pool If you choose to create a disk, a
qcow2image is created and stored under/var/lib/libvirt/imagesby default.Setting up a disk is optional. If you are running a live system directly from CD or DVD, for example, you can omit this step by deactivating .
On the last screen of the wizard, specify the name for the virtual machine. To be offered the possibility to review and make changes to the virtualized hardware selection, activate . Specify the network device under . When using , the first bridge found on the host is pre-filled. To use a different bridge, manually update the text box with its name.
Click .
(Optional) If you kept the defaults in the previous step, the installation starts. If you selected , a VM Guest configuration dialog opens.
When you are done configuring, click .
The installation starts in a Virtual Machine Manager console window. Certain key combinations, such as Ctrl–Alt–F1, are recognized by the VM Host Server but are not passed to the virtual machine. To bypass the VM Host Server, Virtual Machine Manager provides the “sticky key” functionality. Pressing Ctrl, Alt, or Shift three times makes the key sticky, then you can press the remaining keys to pass the combination to the virtual machine.
For example, to pass Ctrl–Alt–F2 to a Linux virtual machine, press Ctrl three times, then press Alt–F2. You can also press Alt three times, then press Ctrl–F2.
The sticky key functionality is available in the Virtual Machine Manager during and after installing a VM Guest.
7.1.1 Configuring the virtual machine for PXE boot #
PXE boot enables your virtual machine to boot from the installation media via the network, instead of from a physical medium or an installation disk image.
To let your VM boot from a PXE server, follow these steps:
Start the installation wizard as described in Section 7.1, “GUI-based guest installation”.
Select the method.
Proceed to the last step of the wizard and activate . Confirm with .
On the screen, select .
Inspect and select .
To retain as the default boot option, confirm with .
To force the virtual machine to use PXE as the default boot option:
Select the NIC device in the boot menu configuration.
Move it to the top using the arrow signs on the right.
Confirm with .
Start the installation by clicking . Now press Esc for boot menu and choose . If a PXE server is properly configured, the PXE menu screen appears.
7.2 Installing from the command line with virt-install #
virt-install is a command-line tool that helps you create new virtual
machines using the libvirt library. It is useful if you cannot use the graphical user
interface, or need to automatize the process of creating virtual machines.
virt-install is a complex script with a lot of command line switches. The
following are required. For more information, see the man page of
virt-install (1).
- General options
--name VM_GUEST_NAME: Specify the name of the new virtual machine. The name must be unique across all guests known to the hypervisor on the same connection. It is used to create and name the guest’s configuration file and you can access the guest with this name fromvirsh. Alphanumeric and_-.:+characters are allowed.--memory REQUIRED_MEMORY: Specify the amount of memory to allocate for the new virtual machine in megabytes.--vcpus NUMBER_OF_CPUS: Specify the number of virtual CPUs. For best performance, the number of virtual processors should be less than or equal to the number of physical processors.
- Virtualization type
--paravirt: set up a paravirtualized guest. This is the default if the VM Host Server supports paravirtualization and full virtualization.--hvm: set up a fully virtualized guest.--virt-type HYPERVISOR: Specify the hypervisor. Supported values iskvm.
- Guest storage
Specify one of
--disk,--filesystemor--nodisksthe type of the storage for the new virtual machine. For example,--disk size=10creates a 10 GB disk in the default image location for the hypervisor and uses it for the VM Guest.--filesystem /export/path/on/vmhostspecifies the directory on the VM Host Server to be exported to the guest. And--nodiskssets up a VM Guest without a local storage (good for Live CDs).- Installation method
Specify the installation method using one of
--location,--cdrom,--pxe,--import, or--boot.- Accessing the installation
Use the
--graphics VALUEoption to specify how to access the installation. SUSE Linux Enterprise Server supports the valuesvncornone.If using VNC,
virt-installtries to launchvirt-viewer. If it is not installed or cannot be run, connect to the VM Guest manually with your preferred viewer. To explicitly preventvirt-installfrom launching the viewer, use--noautoconsole. To define a password for accessing the VNC session, use the following syntax:--graphics vnc,password=PASSWORD.In case you are using
--graphics none, you can access the VM Guest through operating system supported services, such as SSH or VNC. Refer to the operating system installation manual on how to set up these services in the installation system.- Passing kernel and initrd files
It is possible to directly specify the Kernel and Initrd of the installer, for example, from a network source.
To pass additional boot parameters, use the
--extra-argsoption. This can be used to specify a network configuration.Example 5: Loading kernel and initrd from HTTP server ##virt-install--location "http://example.tld/REPOSITORY/DVD1/" \ --extra-args="textmode=1" --name "SLES15" --memory 2048 --virt-type kvm\ --connect qemu:///system --disk size=10 --graphics vnc \ --network network=vnet_nated- Enabling the console
By default, the console is not enabled for new virtual machines installed using
virt-install. To enable it, use--extra-args="console=ttyS0 textmode=1"as in the following example:>virt-install --virt-type kvm --name sles12 --memory 1024 \ --disk /var/lib/libvirt/images/disk1.qcow2 --os-variant sles12 --extra-args="console=ttyS0 textmode=1" --graphics noneAfter the installation finishes, the
/etc/default/grubfile in the VM image is updated with theconsole=ttyS0option on theGRUB_CMDLINE_LINUX_DEFAULTline.- Using UEFI Secure Boot
- Note
SUSE supports UEFI Secure Boot on AMD64/Intel 64 KVM guests only.
By default, new virtual machines installed using
virt-installare configured with a legacy BIOS. They can be configured to use UEFI with--boot firmware=efi. A firmware that supports UEFI Secure Boot and has Microsoft keys enrolled will be selected. If secure boot is undesirable, the option--boot firmware=efi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=nocan be used to select a UEFI firmware without secure boot support.It is also possible to explicitly specify a UEFI firmware image. See Section 7.3.1, “Advanced UEFI configuration” for advanced information and examples on using UEFI with virtual machines.
virt-install command line #The following command line example creates a new SUSE Linux Enterprise 15 SP2 virtual machine with a virtio accelerated disk and network card. It creates a new 10 GB qcow2 disk image as a storage, the source installation media being the host CD-ROM drive. It uses VNC graphics, and it automatically launches the graphical client.
- KVM
>virt-install --connect qemu:///system --virt-type kvm \ --name sle15sp2 --memory 1024 --disk size=10 --cdrom /dev/cdrom --graphics vnc \ --os-variant sle15sp2
7.3 Advanced guest installation scenarios #
This section provides instructions for operations exceeding the scope of a normal installation, such as manually configuring UEFI firmware, memory ballooning and installing add-on products.
7.3.1 Advanced UEFI configuration #
The UEFI firmware used by virtual machines is provided by OVMF (Open Virtual Machine Firmware). The qemu-ovmf-x86_64 package provides firmware for AMD64/Intel 64 VM Guests. Firmware for AArch64 VM Guests is provided by the qemu-uefi-aarch64 package. Both packages include several firmware variants, each supporting a different set of features and capabilities. The packages also include JSON firmware descriptor files, which describe the features and capabilities of each variant.
libvirt supports two methods of selecting virtual machine UEFI firmware: automatic and
manual. With automatic selection, libvirt will select a firmware based on an optional set
of features specified by the user. If no explicit features are specified, libvirt will
select a firmware with secure boot enabled and Microsoft keys enrolled. When using manual
selection, the full path of the firmware and any optional settings must be explicitly
specified. Users can reference the JSON descriptor files to find a firmware that satisfies
their requirements.
The directory /usr/share/qemu/firmware contains all the JSON files
used by libvirt. This file gives you detailed information about the firmware,
including the capabilities of the features.
When using virt-install, automatic firmware selection is enabled by
specifying the firmware=efi parameter to the boot
option, for example, --boot firmware=efi. The selection process can be
influenced by requesting the presence or absence of firmware features. The following
example illustrates automatic firmware selection with UEFI Secure Boot disabled.
> virt-install --connect qemu:///system --virt-type kvm \
--name sle15sp5 --memory 1024 --disk size=10 --cdrom /dev/cdrom --graphics vnc \
--boot firmware=efi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=no \
--os-variant sle15sp5
To ensure persistent VM Guests use the same firmware and variable store throughout their
lifetime, libvirt will record automatically selected firmware in the VM Guest XML
configuration. Automatic firmware selection is a one-time activity. Once firmware has
been selected, it will only change if the VM Guest administrator explicitly does so
using the manual firmware selection method.
The loader and nvram parameters are used for manual firmware selection. loader is required, and nvram defines an optional UEFI variable store. The following example illustrates manual firmware selection with secure boot enabled.
> virt-install --connect qemu:///system --virt-type kvm \
--name sle15sp5 --memory 1024 --disk size=10 --cdrom /dev/cdrom --graphics vnc \
--boot loader=/usr/share/qemu/ovmf-x86_64-smm-code.bin,loader.readonly=yes,loader.type=pflash,loader.secure=yes,nvram.template=/usr/share/qemu/ovmf-x86_64-smm-vars.bin \
--os-variant sle15sp5
libvirt cannot modify any characteristics of the UEFI firmware. For example, it cannot
disable UEFI Secure Boot in a firmware that has UEFI Secure Boot enabled, even when specifying
loader.secure=no. libvirt will ensure the specified firmware can
satisfy any specified features. For example, it will reject configuration that disables
secure boot with loader.secure=no, but specifies a firmware that has
UEFI Secure Boot enabled.
The qemu-ovmf-x86_64 package contains several UEFI firmware images. For example, the following subset supports SMM, UEFI Secure Boot, and has either Microsoft, openSUSE or SUSE UEFI CA keys enrolled:
#rpm -ql qemu-ovmf-x86_64[...] /usr/share/qemu/ovmf-x86_64-smm-ms-code.bin /usr/share/qemu/ovmf-x86_64-smm-ms-vars.bin /usr/share/qemu/ovmf-x86_64-smm-opensuse-code.bin /usr/share/qemu/ovmf-x86_64-smm-opensuse-vars.bin /usr/share/qemu/ovmf-x86_64-smm-suse-code.bin /usr/share/qemu/ovmf-x86_64-smm-suse-vars.bin [...]
For the AArch64 architecture, the package is named qemu-uefi-aarch32:
#rpm -ql qemu-uefi-aarch32[...] /usr/share/qemu/aavmf-aarch32-code.bin /usr/share/qemu/aavmf-aarch32-vars.bin /usr/share/qemu/firmware /usr/share/qemu/firmware/60-aavmf-aarch32.json /usr/share/qemu/qemu-uefi-aarch32.bin
The *-code.bin files are the UEFI firmware files. The
*-vars.bin files are corresponding variable store images that can be
used as a template for a per-VM non-volatile store. libvirt copies the specified
vars template to a per-VM path under
/var/lib/libvirt/qemu/nvram/ when first creating the VM. Files without
code or vars in the name can be used as a single UEFI
image. They are not as useful, since no UEFI variables persist across power cycles of the
VM.
The *-ms*.bin files contain UEFI CA keys as found on real hardware.
Therefore, they are configured as the default in libvirt. Likewise, the
*-suse*.bin files contain preinstalled SUSE keys. There is also a
set of files with no preinstalled keys.
For more details on OVMF, see http://www.linux-kvm.org/downloads/lersek/ovmf-whitepaper-c770f8c.txt.
7.3.2 Memory ballooning with Windows guests #
Memory ballooning is a method to change the amount of memory used by VM Guest at runtime. KVM hypervisors provides this method, but it needs to be supported by the guest as well.
While openSUSE and SLE-based guests support memory ballooning, Windows guests need the Virtual Machine Driver Pack (VMDP) to provide ballooning. To set the maximum memory greater than the initial memory configured for Windows guests, follow these steps:
Install the Windows guest with the maximum memory equal or less than the initial value.
Install the Virtual Machine Driver Pack in the Windows guest to provide required drivers.
Shut down the Windows guest.
Reset the maximum memory of the Windows guest to the required value.
Start the Windows guest again.
7.3.3 Including add-on products in the installation #
Certain operating systems, such as SUSE Linux Enterprise Server, offer to include add-on products in the installation process. If the add-on product installation source is provided via SUSE Customer Center, no special VM Guest configuration is needed. If it is provided via CD/DVD or ISO image, it is necessary to provide the VM Guest installation system with both the standard installation medium image and the image of the add-on product.
If you are using the GUI-based installation, select in the last step of the wizard and add the add-on product ISO image via › . Specify the path to the image and set the to .
If you are installing from the command line, you need to set up the virtual CD/DVD drives
with the --disk parameter rather than with --cdrom. The
device that is specified first is used for booting.
8 Configuring virtual machines with virsh #
You can use virsh to configure virtual machines (VM) on the command
line as an alternative to using the Virtual Machine Manager. With virsh, you can
control the state of a VM, edit the configuration of a VM or even
migrate a VM to another host. The following sections describe how to
manage VMs by using virsh.
8.1 Editing the VM configuration #
The configuration of a VM is stored in an XML file in
/etc/libvirt/qemu/ and looks like this:
<domain type='kvm'>
<name>sles15</name>
<uuid>ab953e2f-9d16-4955-bb43-1178230ee625</uuid>
<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
<vcpu placement='static'>2</vcpu>
<os>
<type arch='x86_64' machine='pc-q35-2.0'>hvm</type>
</os>
<features>...</features>
<cpu mode='custom' match='exact' check='partial'>
<model fallback='allow'>Skylake-Client-IBRS</model>
</cpu>
<clock>...</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<pm>
<suspend-to-mem enabled='no'/>
<suspend-to-disk enabled='no'/>
</pm>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type='file' device='disk'>...</disk>
</devices>
...
</domain>To edit the configuration of a VM Guest, check if it is offline:
>sudovirsh list --inactive
If your VM Guest is in this list, you can safely edit its configuration:
>sudovirsh edit NAME_OF_VM_GUEST
Before saving the changes, virsh validates your input against a RelaxNG
schema.
8.2 Changing the machine type #
When installing with the virt-install tool, the
machine type for a VM Guest is pc-q35 by default.
The machine type is stored in the VM Guest's configuration file in the
type element:
<type arch='x86_64' machine='pc-q35-2.3'>hvm</type>
As an example, the following procedure shows how to change this value to
the machine type q35. The value q35
is an Intel* chipset and includes
PCIe, supports up to 12 USB ports, and
has support for SATA and
IOMMU.
Check whether your VM Guest is inactive:
>sudovirsh list --inactiveId Name State ---------------------------------------------------- - sles15 shut offEdit the configuration for this VM Guest:
>sudovirsh edit sles15Replace the value of the
machineattribute withpc-q35-2.0:<type arch='x86_64' machine='pc-q35-2.0'>hvm</type>
Restart the VM Guest:
>sudovirsh start sles15Check if the machine type has changed. Log in to the VM Guest and run the following command:
>sudodmidecode | grep ProductProduct Name: Standard PC (Q35 + ICH9, 2009)
Whenever the QEMU version on the host system is upgraded, for example,
when upgrading the VM Host Server to a new service pack, upgrade the machine
type of the VM Guests to the latest available version. To check, use
the command qemu-system-x86_64 -M help on the
VM Host Server.
The default machine type pc-i440fx, for example, is
regularly updated. If your VM Guest still runs with a machine type of
pc-i440fx-1.X, we
strongly recommend an update to
pc-i440fx-2.X. This
allows taking advantage of the most recent updates and corrections in
machine definitions, and ensures better future compatibility.
8.3 Configuring hypervisor features #
libvirt automatically enables a default set of
hypervisor features that are sufficient in most circumstances, but also
allows enabling and disabling features as needed.
Hypervisor features can be
configured with virsh. Look for the <features> element
in the VM Guest's configuration file and adjust its features as
required.
See the Hypervisor features section of the libvirt Domain XML format manual at https://libvirt.org/formatdomain.html#elementsFeatures for more information.
8.4 Configuring CPU #
Many aspects of the virtual CPUs presented to VM Guests are configurable
with virsh. The number of current and maximum CPUs allocated to a
VM Guest can be changed, as well as the model of the CPU and its feature
set. The following subsections describe how to change the common CPU
settings of a VM Guest.
8.4.1 Configuring the number of CPUs #
The number of allocated CPUs is stored in the VM Guest's XML
configuration file in /etc/libvirt/qemu/ in the
vcpu element:
<vcpu placement='static'>1</vcpu>
In this example, the VM Guest has only one allocated CPU. The following procedure shows how to change the number of allocated CPUs for the VM Guest:
Check whether your VM Guest is inactive:
>sudovirsh list --inactiveId Name State ---------------------------------------------------- - sles15 shut offEdit the configuration for an existing VM Guest:
>sudovirsh edit sles15Change the number of allocated CPUs:
<vcpu placement='static'>2</vcpu>
Restart the VM Guest:
>sudovirsh start sles15Check if the number of CPUs in the VM has changed.
>sudovirsh vcpuinfo sled15VCPU: 0 CPU: N/A State: N/A CPU time N/A CPU Affinity: yy VCPU: 1 CPU: N/A State: N/A CPU time N/A CPU Affinity: yy
You can also change the number of CPUs while the VM Guest is running. CPUs can be hotplugged until the maximum number configured at VM Guest start is reached. Likewise, they can be hot-unplugged until the lower limit of 1 is reached. The following example shows changing the active CPU count from 2 to a predefined maximum of 4.
Check the current live vcpu count:
>sudovirsh vcpucount sles15 | grep livemaximum live 4 current live 2Change the current, or active, number of CPUs to 4:
>sudovirsh setvcpus sles15 --count 4 --liveCheck that the current live vcpu count is now 4:
>sudovirsh vcpucount sles15 | grep livemaximum live 4 current live 4
8.4.2 Configuring the CPU model #
The CPU model exposed to a VM Guest can often influence the workload
running within it. The default CPU model is derived from a CPU mode
known as host-model.
<cpu mode='host-model'/>
When starting a VM Guest with the CPU mode host-model,
libvirt copies its model of the host CPU into the VM Guest
definition. The host CPU model and features copied to the VM Guest
definition can be observed in the output of the virsh
capabilities.
Another interesting CPU mode is host-passthrough.
<cpu mode='host-passthrough'/>
When starting a VM Guest with the CPU mode
host-passthrough, it is presented with a CPU that is
exactly the same as the VM Host Server CPU. This can be useful when the
VM Guest workload requires CPU features not available in libvirt's
simplified host-model CPU. The
host-passthrough CPU mode comes with the
disadvantage of reduced migration flexibility. A VM Guest with
host-passthrough CPU mode can only be migrated to a
VM Host Server with identical hardware.
When using the host-passthrough CPU mode, it is
still possible to disable undesirable features. The following
configuration presents the VM Guest with a CPU that is exactly the
same as the host CPU but with the vmx feature
disabled.
<cpu mode='host-passthrough'> <feature policy='disable' name='vmx'/> </cpu>
The custom CPU mode is another common mode used to
define a normalized CPU that can be migrated throughout dissimilar
hosts in a cluster. For example, in a cluster with hosts containing
Nehalem, IvyBridge and SandyBridge CPUs, the VM Guest can be
configured with a custom CPU mode that contains a
Nehalem CPU model.
<cpu mode='custom' match='exact'> <model fallback='allow'>Nehalem</model> <feature policy='require' name='vme'/> <feature policy='require' name='ds'/> <feature policy='require' name='acpi'/> <feature policy='require' name='ss'/> <feature policy='require' name='ht'/> <feature policy='require' name='tm'/> <feature policy='require' name='pbe'/> <feature policy='require' name='dtes64'/> <feature policy='require' name='monitor'/> <feature policy='require' name='ds_cpl'/> <feature policy='require' name='vmx'/> <feature policy='require' name='est'/> <feature policy='require' name='tm2'/> <feature policy='require' name='xtpr'/> <feature policy='require' name='pdcm'/> <feature policy='require' name='dca'/> <feature policy='require' name='rdtscp'/> <feature policy='require' name='invtsc'/> </cpu>
For more information on libvirt's CPU model and topology options, see
the CPU model and topology documentation at
https://libvirt.org/formatdomain.html#cpu-model-and-topology.
8.6 Configuring memory allocation #
The amount of memory allocated for the VM Guest can also be configured
with virsh. It is stored in the memory element and defines
the maximum allocation of memory for the VM Guest at boot time. The
optional currentMemory element defines the actual memory
allocated to the VM Guest. currentMemory can be less than
memory, allowing for increasing (or
ballooning) the memory while the VM Guest is
running. If currentMemory is omitted, it defaults to the same
value as the memory element.
You can adjust memory settings by editing the VM Guest configuration, but be aware that changes do not take place until the next boot. The following steps demonstrate changing a VM Guest to boot with 4G of memory, but allow later expansion to 8G:
Open the VM Guest's XML configuration:
>sudovirsh edit sles15Search for the
memoryelement and set to 8G:... <memory unit='KiB'>8388608</memory> ...
If the
currentMemoryelement does not exist, add it below thememoryelement, or change its value to 4G:[...] <memory unit='KiB'>8388608</memory> <currentMemory unit='KiB'>4194304</currentMemory> [...]
Changing the memory allocation while the VM Guest is running can be done
with the setmem subcommand. The following example
shows increasing the memory allocation to 8G:
Check VM Guest existing memory settings:
>sudovirsh dominfo sles15 | grep memoryMax memory: 8388608 KiB Used memory: 4194608 KiBChange the used memory to 8G:
>sudovirsh setmem sles15 8388608Check the updated memory settings:
>sudovirsh dominfo sles15 | grep memoryMax memory: 8388608 KiB Used memory: 8388608 KiB
VM Guests with memory requirements of 4 TB or more must either
use the host-passthrough CPU mode, or explicitly
specify the virtual CPU address size when using
host-model or custom CPU modes.
The default virtual CPU address size may not be sufficient for memory
configurations of 4 TB or more. The following example shows how to
use the VM Host Server's physical CPU address size when using the
host-model CPU mode.
[...] <cpu mode='host-model' check='partial'> <maxphysaddr mode='passthrough'> </cpu> [...]
For more information on specifying virtual CPU address size, see the
maxphysaddr option in the CPU model and
topology documentation at
https://libvirt.org/formatdomain.html#cpu-model-and-topology.
8.7 Adding a PCI device #
To assign a PCI device to VM Guest with virsh, follow these steps:
Identify the host PCI device to assign to the VM Guest. In the following example, we are assigning a DEC network card to the guest:
>sudolspci -nn[...] 03:07.0 Ethernet controller [0200]: Digital Equipment Corporation DECchip \ 21140 [FasterNet] [1011:0009] (rev 22) [...]Write down the device ID,
03:07.0in this example.Gather detailed information about the device using
virsh nodedev-dumpxml ID. To get the ID, replace the colon and the period in the device ID (03:07.0) with underscores. Prefix the result with “pci_0000_”:pci_0000_03_07_0.>sudovirsh nodedev-dumpxml pci_0000_03_07_0<device> <name>pci_0000_03_07_0</name> <path>/sys/devices/pci0000:00/0000:00:14.4/0000:03:07.0</path> <parent>pci_0000_00_14_4</parent> <driver> <name>tulip</name> </driver> <capability type='pci'> <domain>0</domain> <bus>3</bus> <slot>7</slot> <function>0</function> <product id='0x0009'>DECchip 21140 [FasterNet]</product> <vendor id='0x1011'>Digital Equipment Corporation</vendor> <numa node='0'/> </capability> </device>Write down the values for domain, bus and function (see the previous XML code printed in bold).
Detach the device from the host system before attaching it to the VM Guest:
>sudovirsh nodedev-detach pci_0000_03_07_0Device pci_0000_03_07_0 detachedTip: Multi-function PCI devicesWhen using a multi-function PCI device that does not support FLR (function level reset) or PM (power management) reset, you need to detach all its functions from the VM Host Server. The whole device must be reset for security reasons.
libvirtrefuses to assign the device if one of its functions is still in use by the VM Host Server or another VM Guest.Convert the domain, bus, slot, and function value from decimal to hexadecimal. In our example, domain = 0, bus = 3, slot = 7, and function = 0. Ensure that the values are inserted in the right order:
>printf "<address domain='0x%x' bus='0x%x' slot='0x%x' function='0x%x'/>\n" 0 3 7 0This results in:
<address domain='0x0' bus='0x3' slot='0x7' function='0x0'/>
Run
virsh editon your domain, and add the following device entry in the<devices>section using the result from the previous step:<hostdev mode='subsystem' type='pci' managed='yes'> <source> <address domain='0x0' bus='0x03' slot='0x07' function='0x0'/> </source> </hostdev>Tip:managedcompared tounmanagedlibvirtrecognizes two modes for handling PCI devices: they can bemanagedorunmanaged. In the managed case,libvirthandles all details of unbinding the device from the existing driver if needed, resetting the device, binding it tovfio-pcibefore starting the domain, etc. When the domain is terminated or the device is removed from the domain,libvirtunbinds fromvfio-pciand rebinds to the original driver when using a managed device. If the device is unmanaged, the user must ensure that all these management aspects of the device are done before assigning it to a domain, and after the device is no longer used by the domain.In the example above, the
managed='yes'option means that the device is managed. To switch the device mode to unmanaged, setmanaged='no'in the listing above. If you do so, you need to take care of the related driver with thevirsh nodedev-detachandvirsh nodedev-reattachcommands. Before starting the VM Guest, you need to detach the device from the host by runningvirsh nodedev-detach pci_0000_03_07_0. In case the VM Guest is not running, you can make the device available for the host by runningvirsh nodedev-reattach pci_0000_03_07_0.Shut down the VM Guest and disable SELinux if it is running on the host.
>sudosetsebool -P virt_use_sysfs 1Start your VM Guest to make the assigned PCI device available:
>sudovirsh start sles15
On a newer QEMU machine type (pc-i440fx-2.0 or higher) with SLES 11
SP4 KVM guests, the acpiphp
module is not loaded by default in the guest. This module must be
loaded to enable hotplugging of disk and network devices. To load the
module manually, use the command modprobe acpiphp.
It is also possible to autoload the module by adding install
acpiphp /bin/true to the
/etc/modprobe.conf.local file.
KVM guests using the QEMU Q35 machine type have a PCI topology that
includes a pcie-root controller and seven
pcie-root-port controllers. The
pcie-root controller does not support hotplugging.
Each pcie-root-port controller supports hotplugging
a single PCIe device. PCI controllers cannot be hotplugged, so plan
accordingly and add more pcie-root-ports to hotplug
more than seven PCIe devices. A pcie-to-pci-bridge
controller can be added to support hotplugging legacy PCI devices. See
https://libvirt.org/pci-hotplug.html for more
information about PCI topology between QEMU machine types.
8.7.1 PCI Pass-Through for IBM Z #
To support IBM Z, QEMU extended PCI representation by allowing the user to
configure extra attributes. Two more
attributes—uid and
fid—were added to the
<zpci/> libvirt specification.
uid represents user-defined identifier, while
fid represents PCI function identifier. These
attributes are optional and if you do not specify them, they are
automatically generated with non-conflicting values.
To include zPCI attribute in your domain specification, use the following example definition:
<controller type='pci' index='0' model='pci-root'/>
<controller type='pci' index='1' model='pci-bridge'>
<model name='pci-bridge'/>
<target chassisNr='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'>
<zpci uid='0x0001' fid='0x00000000'/>
</address>
</controller>
<interface type='bridge'>
<source bridge='virbr0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x01' slot='0x01' function='0x0'>
<zpci uid='0x0007' fid='0x00000003'/>
</address>
</interface>8.8 Adding a USB device #
To assign a USB device to VM Guest using virsh, follow these steps:
Identify the host USB device to assign to the VM Guest:
>sudolsusb[...] Bus 001 Device 003: ID 0557:2221 ATEN International Co., Ltd Winbond Hermon [...]Write down the vendor and product IDs. In our example, the vendor ID is
0557and the product ID is2221.Run
virsh editon your domain, and add the following device entry in the<devices>section using the values from the previous step:<hostdev mode='subsystem' type='usb'> <source startupPolicy='optional'> <vendor id='0557'/> <product id='2221'/> </source> </hostdev>Tip: Vendor/product or device's addressInstead of defining the host device with
<vendor/>and<product/>IDs, you can use the<address/>element as described for host PCI devices in Section 8.7, “Adding a PCI device”.Shut down the VM Guest and disable SELinux if it is running on the host:
>sudosetsebool -P virt_use_sysfs 1Start your VM Guest to make the assigned PCI device available:
>sudovirsh start sles15
8.9 Adding SR-IOV devices #
Single Root I/O Virtualization capable PCIe devices can replicate their resources, so they appear as multiple devices. Each of these “pseudo-devices” can be assigned to a VM Guest.
SR-IOV; is an industry specification that was created by the Peripheral Component Interconnect Special Interest Group (PCI-SIG) consortium. It introduces physical functions (PF) and virtual functions (VF). PFs are full PCIe functions used to manage and configure the device. PFs also can move data. VFs lack the configuration and management part—they only can move data and a reduced set of configuration functions. As VFs do not have all PCIe functions, the host operating system or the Hypervisor must support SR-IOV; to access and initialize VFs. The theoretical maximum for VFs is 256 per device (consequently the maximum for a dual-port Ethernet card would be 512). In practice, this maximum is much lower, since each VF consumes resources.
8.9.1 Requirements #
The following requirements must be met to use SR-IOV;:
An SR-IOV; capable network card (as of SUSE Linux Enterprise Server 15, only network cards support SR-IOV;)
An AMD64/Intel 64 host supporting hardware virtualization (AMD-V or Intel VT-x), see Section 4.1.1, “KVM hardware requirements” for more information
A chipset that supports device assignment (AMD-Vi or Intel VT-d)
libvirt0.9.10 or betterSR-IOV; drivers must be loaded and configured on the host system
A host configuration that meets the requirements
A list of the PCI addresses of the VFs assigned to VM Guests
The information whether a device is SR-IOV-capable can be obtained
from its PCI descriptor by running lspci. A device
that supports SR-IOV; reports a capability
similar to the following:
Capabilities: [160 v1] Single Root I/O Virtualization
Before adding an SR-IOV device to a VM Guest when initially setting it up, the VM Host Server already needs to be configured as described in Section 8.9.2, “Loading and configuring the SR-IOV host drivers”.
8.9.2 Loading and configuring the SR-IOV host drivers #
To access and initialize VFs, an SR-IOV-capable driver needs to be loaded on the host system.
Before loading the driver, make sure the card is properly detected by running
lspci. The following example shows thelspcioutput for the dual-port Intel 82576NS network card:>sudo/sbin/lspci | grep 8257601:00.0 Ethernet controller: Intel Corporation 82576NS Gigabit Network Connection (rev 01) 01:00.1 Ethernet controller: Intel Corporation 82576NS Gigabit Network Connection (rev 01) 04:00.0 Ethernet controller: Intel Corporation 82576NS Gigabit Network Connection (rev 01) 04:00.1 Ethernet controller: Intel Corporation 82576NS Gigabit Network Connection (rev 01)In case the card is not detected, the hardware virtualization support in the BIOS/EFI may not have been enabled. To check if hardware virtualization support is enabled, look at the settings in the host's BIOS.
Check whether the SR-IOV; driver is already loaded by running
lsmod. In the following example, a check for the igb driver (for the Intel 82576NS network card) returns a result. That means the driver is already loaded. If the command returns nothing, the driver is not loaded.>sudo/sbin/lsmod | egrep "^igb "igb 185649 0Skip the following step if the driver is already loaded. If the SR-IOV; driver is not yet loaded, the non-SR-IOV; driver needs to be removed first, before loading the new driver. Use
rmmodto unload a driver. The following example unloads the non-SR-IOV; driver for the Intel 82576NS network card:>sudo/sbin/rmmod igbvfLoad the SR-IOV; driver subsequently using the
modprobecommand—the VF parameter (max_vfs) is mandatory:>sudo/sbin/modprobe igb max_vfs=8
As an alternative, you can also load the driver via SYSFS:
Find the PCI ID of the physical NIC by listing Ethernet devices:
>sudolspci | grep Eth06:00.0 Ethernet controller: Emulex Corporation OneConnect NIC (Skyhawk) (rev 10) 06:00.1 Ethernet controller: Emulex Corporation OneConnect NIC (Skyhawk) (rev 10)To enable VFs, echo the number of desired VFs to load to the
sriov_numvfsparameter:>sudoecho 1 > /sys/bus/pci/devices/0000:06:00.1/sriov_numvfsVerify that the VF NIC was loaded:
>sudolspci | grep Eth06:00.0 Ethernet controller: Emulex Corporation OneConnect NIC (Skyhawk) (rev 10) 06:00.1 Ethernet controller: Emulex Corporation OneConnect NIC (Skyhawk) (rev 10) 06:08.0 Ethernet controller: Emulex Corporation OneConnect NIC (Skyhawk) (rev 10)Obtain the maximum number of VFs available:
>sudolspci -vvv -s 06:00.1 | grep 'Initial VFs'Initial VFs: 32, Total VFs: 32, Number of VFs: 0, Function Dependency Link: 01Create a
/etc/systemd/system/before.servicefile which loads VF via SYSFS on boot:[Unit] Before= [Service] Type=oneshot RemainAfterExit=true ExecStart=/bin/bash -c "echo 1 > /sys/bus/pci/devices/0000:06:00.1/sriov_numvfs" # beware, executable is run directly, not through a shell, check the man pages # systemd.service and systemd.unit for full syntax [Install] # target in which to start the service WantedBy=multi-user.target #WantedBy=graphical.target
Before starting the VM, it is required to create another service file (
after-local.service) pointing to the/etc/init.d/after.localscript that detaches the NIC. Otherwise the VM would fail to start:[Unit] Description=/etc/init.d/after.local Compatibility After=libvirtd.service Requires=libvirtd.service [Service] Type=oneshot ExecStart=/etc/init.d/after.local RemainAfterExit=true [Install] WantedBy=multi-user.target
Copy it to
/etc/systemd/system.#! /bin/sh # ... virsh nodedev-detach pci_0000_06_08_0
Save it as
/etc/init.d/after.local.Reboot the machine and check if the SR-IOV driver is loaded by re-running the
lspcicommand from the first step of this procedure. If the SR-IOV driver was loaded successfully you should see additional lines for the VFs:01:00.0 Ethernet controller: Intel Corporation 82576NS Gigabit Network Connection (rev 01) 01:00.1 Ethernet controller: Intel Corporation 82576NS Gigabit Network Connection (rev 01) 01:10.0 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 01:10.1 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 01:10.2 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) [...] 04:00.0 Ethernet controller: Intel Corporation 82576NS Gigabit Network Connection (rev 01) 04:00.1 Ethernet controller: Intel Corporation 82576NS Gigabit Network Connection (rev 01) 04:10.0 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 04:10.1 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 04:10.2 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) [...]
8.9.3 Adding a VF network device to a VM Guest #
When the SR-IOV; hardware is properly set up on the VM Host Server, you can add VFs to VM Guests. To do so, you need to collect specific data first.
The following procedure uses example data. Replace it with appropriate data from your setup.
Use the
virsh nodedev-listcommand to get the PCI address of the VF you want to assign and its corresponding PF. Numerical values from thelspcioutput shown in Section 8.9.2, “Loading and configuring the SR-IOV host drivers”, for example,01:00.0or04:00.1, are transformed by adding the prefixpci_0000_and by replacing colons and dots with underscores. So a PCI ID listed as04:00.0bylspciis listed aspci_0000_04_00_0by virsh. The following example lists the PCI IDs for the second port of the Intel 82576NS network card:>sudovirsh nodedev-list | grep 0000_04_pci_0000_04_00_0 pci_0000_04_00_1 pci_0000_04_10_0 pci_0000_04_10_1 pci_0000_04_10_2 pci_0000_04_10_3 pci_0000_04_10_4 pci_0000_04_10_5 pci_0000_04_10_6 pci_0000_04_10_7 pci_0000_04_11_0 pci_0000_04_11_1 pci_0000_04_11_2 pci_0000_04_11_3 pci_0000_04_11_4 pci_0000_04_11_5The first two entries represent the PFs, whereas the other entries represent the VFs.
Run the following
virsh nodedev-dumpxmlcommand on the PCI ID of the VF you want to add:>sudovirsh nodedev-dumpxml pci_0000_04_10_0<device> <name>pci_0000_04_10_0</name> <parent>pci_0000_00_02_0</parent> <capability type='pci'> <domain>0</domain> <bus>4</bus> <slot>16</slot> <function>0</function> <product id='0x10ca'>82576 Virtual Function</product> <vendor id='0x8086'>Intel Corporation</vendor> <capability type='phys_function'> <address domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> </capability> </capability> </device>The following data is needed for the next step:
<domain>0</domain><bus>4</bus><slot>16</slot><function>0</function>
Create a temporary XML file, for example,
/tmp/vf-interface.xml, containing the data necessary to add a VF network device to an existing VM Guest. The minimal content of the file needs to look like the following:<interface type='hostdev'>1 <source> <address type='pci' domain='0' bus='11' slot='16' function='0'2/>2 </source> </interface>
VFs do not get a fixed MAC address; it changes every time the host reboots. When adding network devices the “traditional” way with
hostdev, it would require to reconfigure the VM Guest's network device after each reboot of the host, because of the MAC address change. To avoid this kind of problem,libvirtintroduced thehostdevvalue, which sets up network-specific data before assigning the device.Specify the data you acquired in the previous step here.
In case a device is already attached to the host, it cannot be attached to a VM Guest. To make it available for guests, detach it from the host first:
>sudovirsh nodedev-detach pci_0000_04_10_0Add the VF interface to an existing VM Guest:
>sudovirsh attach-device GUEST /tmp/vf-interface.xml --OPTIONGUEST needs to be replaced by the domain name, ID or UUID of the VM Guest. --OPTION can be one of the following:
--persistentThis option always adds the device to the domain's persistent XML. If the domain is running, the device is hotplugged.
--configThis option affects the persistent XML only, even if the domain is running. The device appears in the VM Guest on next boot.
--liveThis option affects a running domain only. If the domain is inactive, the operation fails. The device is not persisted in the XML and becomes available in the VM Guest on next boot.
--currentThis option affects the current state of the domain. If the domain is inactive, the device is added to the persistent XML and becomes available on next boot. If the domain is active, the device is hotplugged but not added to the persistent XML.
To detach a VF interface, use the
virsh detach-devicecommand, which also takes the options listed above.
8.9.4 Dynamic allocation of VFs from a pool #
If you define the PCI address of a VF into a VM Guest's configuration statically as described in Section 8.9.3, “Adding a VF network device to a VM Guest”, it is hard to migrate such guest to another host. The host must have identical hardware in the same location on the PCI bus, or the VM Guest configuration must be modified before each start.
Another approach is to create a libvirt network with a device pool
that contains all the VFs of an SR-IOV; device.
The VM Guest then references this network, and each time it is
started, a single VF is dynamically allocated to it. When the VM Guest
is stopped, the VF is returned to the pool, available for another
guest.
8.9.4.1 Defining network with pool of VFs on VM Host Server #
The following example of network definition creates a pool of all VFs
for the SR-IOV; device with its physical
function (PF) at the network interface eth0 on the
host:
<network>
<name>passthrough</name>
<forward mode='hostdev' managed='yes'>
<pf dev='eth0'/>
</forward>
</network>
To use this network on the host, save the above code to a file, for
example /tmp/passthrough.xml, and execute the
following commands. Remember to replace eth0 with
the real network interface name of your SR-IOV;
device's PF:
>sudovirsh net-define /tmp/passthrough.xml>sudovirsh net-autostart passthrough>sudovirsh net-start passthrough
8.9.4.2 Configuring VM Guests to use VF from the pool #
The following example of VM Guest device interface definition uses a
VF of the SR-IOV; device from the pool created
in Section 8.9.4.1, “Defining network with pool of VFs on VM Host Server”. libvirt
automatically derives the list of all VFs associated with that PF the
first time the guest is started.
<interface type='network'> <source network='passthrough'> </interface>
After the first VM Guest starts that uses the network with the pool
of VFs, verify the list of associated VFs. Do so by running
virsh net-dumpxml passthrough on the host.
<network connections='1'>
<name>passthrough</name>
<uuid>a6a26429-d483-d4ed-3465-4436ac786437</uuid>
<forward mode='hostdev' managed='yes'>
<pf dev='eth0'/>
<address type='pci' domain='0x0000' bus='0x02' slot='0x10' function='0x1'/>
<address type='pci' domain='0x0000' bus='0x02' slot='0x10' function='0x3'/>
<address type='pci' domain='0x0000' bus='0x02' slot='0x10' function='0x5'/>
<address type='pci' domain='0x0000' bus='0x02' slot='0x10' function='0x7'/>
<address type='pci' domain='0x0000' bus='0x02' slot='0x11' function='0x1'/>
<address type='pci' domain='0x0000' bus='0x02' slot='0x11' function='0x3'/>
<address type='pci' domain='0x0000' bus='0x02' slot='0x11' function='0x5'/>
</forward>
</network>8.10 Listing attached devices #
Although there is no mechanism in virsh to list all VM Host Server's devices
that have already been attached to its VM Guests, you can list all
devices attached to a specific VM Guest by running the following
command:
virsh dumpxml VMGUEST_NAME | xpath -e /domain/devices/hostdev
For example:
>sudovirsh dumpxml sles16-clone | xpath -e /domain/devices/hostdev Found 1 nodes in stdin: -- NODE -- <hostdev mode="subsystem" type="pci" managed="yes"> <source> <address domain="0x0000" bus="0x01" slot="0x00" function="0x0" /> </source> <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0" /> </hostdev>
<interface type='hostdev'>
For SR-IOV devices that are attached to the VM Host Server via
<interface type='hostdev'>, you need to use a
different XPath query:
virsh dumpxml VMGUEST_NAME | xpath -e /domain/devices/interface/@type
8.11 Configuring storage devices #
Storage devices are defined within the disk element. The usual
disk element supports several attributes. The following two
attributes are the most important:
The
typeattribute describes the source of the virtual disk device. Valid values arefile,block,dir,network, orvolume.The
deviceattribute shows how the disk is exposed to the VM Guest OS. As an example, possible values can includefloppy,disk,cdrom, and others.
The following child elements are the most important:
drivercontains the driver and the bus. These are used by the VM Guest to work with the new disk device.The
targetelement contains the device name under which the new disk is shown in the VM Guest. It also contains the optional bus attribute, which defines the type of bus on which the new disk should operate.
The following procedure shows how to add storage devices to the VM Guest:
Edit the configuration for an existing VM Guest:
>sudovirsh edit sles15Add a
diskelement inside thedeviceselement together with the attributestypeanddevice:<disk type='file' device='disk'>
Specify a
driverelement and use the default values:<driver name='qemu' type='qcow2'/>
Create a disk image as a source for the new virtual disk device:
>sudoqemu-img create -f qcow2 /var/lib/libvirt/images/sles15.qcow2 32GAdd the path for the disk source:
<source file='/var/lib/libvirt/images/sles15.qcow2'/>
Define the target device name in the VM Guest and the bus on which the disk should work:
<target dev='vda' bus='virtio'/>
Restart your VM:
>sudovirsh start sles15
Your new storage device should be available in the VM Guest OS.
8.12 Configuring controller devices #
libvirt manages controllers automatically
based on the type of virtual devices used by the VM Guest. If the
VM Guest contains PCI and SCSI devices, PCI and SCSI controllers are
created and managed automatically. libvirt also models
controllers that are hypervisor-specific, for example, a
virtio-serial controller for KVM. Although the
default controllers and their configuration are generally fine, there may
be use cases where controllers or their attributes need to be adjusted
manually.
The default of 32 is enough in most circumstances, but a VM Guest with multiple I/O devices and an I/O-intensive workload may experience performance issues because of grant frame exhaustion.
See the Controllers section of the libvirt Domain XML format manual at https://libvirt.org/formatdomain.html#elementsControllers for more information.
8.13 Configuring video devices #
When using the Virtual Machine Manager, only the Video device model can be defined. The amount of allocated VRAM or 2D/3D acceleration can only be changed in the XML configuration.
8.13.1 Changing the amount of allocated VRAM #
Edit the configuration for an existing VM Guest:
>sudovirsh edit sles15Change the size of the allocated VRAM:
<video> <model type='vga' vram='65535' heads='1'> ... </model> </video>
Check if the amount of VRAM in the VM has changed by looking at the amount in the Virtual Machine Manager.
8.13.2 Changing the state of 2D/3D acceleration #
Edit the configuration for an existing VM Guest:
>sudovirsh edit sles15To enable/disable 2D/3D acceleration, change the value of
accel3dandaccel2daccordingly:<video> <model> <acceleration accel3d='yes' accel2d='no'> </model> </video>
Only virtio and vbox video
devices are capable of 2D/3D acceleration. You cannot enable it on
other video devices.
8.14 Configuring network devices #
This section describes how to configure specific aspects of virtual
network devices by using virsh.
Find more details about libvirt network interface specification in
https://libvirt.org/formatdomain.html#elementsDriverBackendOptions.
8.14.1 Scaling network performance with multiqueue virtio-net #
The multiqueue virtio-net feature scales the network performance by allowing the VM Guest's virtual CPUs to transfer packets in parallel.
To enable multiqueue virtio-net for a specific VM Guest, edit its XML configuration as described in Section 8.1, “Editing the VM configuration” and modify its network interface as follows:
<interface type='network'> [...] <model type='virtio'/> <driver name='vhost' queues='NUMBER_OF_QUEUES'/> </interface>
8.15 Using macvtap to share VM Host Server network interfaces #
Macvtap provides direct attachment of a VM Guest virtual interface to a host network interface. The macvtap-based interface extends the VM Host Server network interface and has its own MAC address on the same Ethernet segment. Typically, this is used to make both the VM Guest and the VM Host Server show up directly on the switch that the VM Host Server is connected to.
Macvtap cannot be used with network interfaces already connected to a Linux bridge. Before attempting to create the macvtap interface, remove the interface from the bridge.
When using macvtap, a VM Guest can communicate with other VM Guests, and with other external hosts on the network. But it cannot communicate with the VM Host Server on which the VM Guest runs. This is the defined behavior of macvtap, because of the way the VM Host Server's physical Ethernet is attached to the macvtap bridge. Traffic from the VM Guest into that bridge that is forwarded to the physical interface cannot be bounced back up to the VM Host Server's IP stack. Similarly, traffic from the VM Host Server's IP stack that is sent to the physical interface cannot be bounced back up to the macvtap bridge for forwarding to the VM Guest.
Virtual network interfaces based on macvtap are supported by libvirt by
specifying an interface type of direct. For example:
<interface type='direct'> <mac address='aa:bb:cc:dd:ee:ff'/> <source dev='eth0' mode='bridge'/> <model type='virtio'/> </interface>
The operation mode of the macvtap device can be controlled with the
mode attribute. The following list shows its possible
values and a description for each:
vepa: all VM Guest packets are sent to an external bridge. Packets whose destination is a VM Guest on the same VM Host Server as where the packet originates from are sent back to the VM Host Server by the VEPA capable bridge (today's bridges are typically not VEPA capable).bridge: packets whose destination is on the same VM Host Server as where they originate from are directly delivered to the target macvtap device. Both origin and destination devices need to be inbridgemode for direct delivery. If either of them is invepamode, a VEPA capable bridge is required.private: all packets are sent to the external bridge and delivered to a target VM Guest on the same VM Host Server if they are sent through an external router or gateway and that device sends them back to the VM Host Server. This procedure is followed if either the source or destination device is in private mode.passthrough: a special mode that gives more power to the network interface. All packets are forwarded to the interface, allowing virtio VM Guests to change the MAC address or set promiscuous mode to bridge the interface or create VLAN interfaces on top of it. A network interface is not shareable inpassthroughmode. Assigning an interface to a VM Guest disconnects it from the VM Host Server. For this reason SR-IOV virtual functions are often assigned to the VM Guest inpassthroughmode.
8.16 Disabling a memory balloon device #
Memory Balloon has become a default option for KVM. The device is added to
the VM Guest explicitly, so you do not need to add this element in the
VM Guest's XML configuration. To disable Memory Balloon in the VM Guest
for any reason, set model='none' as shown below:
<devices> <memballoon model='none'/> </device>
8.17 Configuring multiple monitors (dual head) #
libvirt supports a dual head configuration to display the video output
of the VM Guest on multiple monitors.
While the virtual machine is running, verify that the xf86-video-qxl package is installed in the VM Guest:
>rpm -q xf86-video-qxlShut down the VM Guest and start editing its configuration XML as described in Section 8.1, “Editing the VM configuration”.
Verify that the model of the virtual graphics card is “qxl”:
<video> <model type='qxl' ... />
Increase the
headsparameter in the graphics card model specification from the default1to2, for example:<video> <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='2' primary='yes'/> <alias name='video0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/> </video>
Configure the virtual machine to use the Spice display instead of VNC:
<graphics type='spice' port='5916' autoport='yes' listen='0.0.0.0'> <listen type='address' address='0.0.0.0'/> </graphics>
Start the virtual machine and connect to its display with
virt-viewer, for example:>virt-viewer --connect qemu+ssh://USER@VM_HOST/systemFrom the list of VMs, select the one whose configuration you have modified and confirm with .
After the graphical subsystem (Xorg) loads in the VM Guest, select › › to open a new window with the second monitor's output.
8.18 Crypto adapter pass-through to KVM guests on IBM Z #
8.18.1 Introduction #
IBM Z machines include cryptographic hardware with useful functions such as random number generation, digital signature generation, or encryption. KVM allows dedicating these crypto adapters to guests as pass-through devices. The means that the hypervisor cannot observe communications between the guest and the device.
8.18.2 What is covered #
This section describes how to dedicate a crypto adapter and domains on an IBM Z host to a KVM guest. The procedure includes the following basic steps:
Mask the crypto adapter and domains from the default driver on the host.
Load the
vfio-apdriver.Assign the crypto adapter and domains to the
vfio-apdriver.Configure the guest to use the crypto adapter.
8.18.3 Requirements #
You need to have the QEMU /
libvirtvirtualization environment correctly installed and functional.The
vfio_apandvfio_mdevmodules for the running kernel need to be available on the host operating system.
8.18.4 Dedicate a crypto adapter to a KVM host #
Verify that the
vfio_apandvfio_mdevkernel modules are loaded on the host:>lsmod | grep vfio_If any of them is not listed, load it manually, for example:
>sudomodprobe vfio_mdevCreate a new MDEV device on the host and verify that it was added:
uuid=$(uuidgen) $ echo ${uuid} | sudo tee /sys/devices/vfio_ap/matrix/mdev_supported_types/vfio_ap-passthrough/create dmesg | tail [...] [272197.818811] iommu: Adding device 24f952b3-03d1-4df2-9967-0d5f7d63d5f2 to group 0 [272197.818815] vfio_mdev 24f952b3-03d1-4df2-9967-0d5f7d63d5f2: MDEV: group_id = 0Identify the device on the host's logical partition that you intend to dedicate to a KVM guest:
>ls -l /sys/bus/ap/devices/ [...] lrwxrwxrwx 1 root root 0 Nov 23 03:29 00.0016 -> ../../../devices/ap/card00/00.0016/ lrwxrwxrwx 1 root root 0 Nov 23 03:29 card00 -> ../../../devices/ap/card00/In this example, it is card
0queue16. To match the Hardware Management Console (HMC) configuration, you need to convert from16hexadecimal to22decimal.Mask the adapter from the
zcryptuse:>lszcrypt CARD.DOMAIN TYPE MODE STATUS REQUEST_CNT ------------------------------------------------- 00 CEX5C CCA-Coproc online 5 00.0016 CEX5C CCA-Coproc online 5Mask the adapter:
>cat /sys/bus/ap/apmask 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff echo -0x0 | sudo tee /sys/bus/ap/apmask 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffMask the domain:
>cat /sys/bus/ap/aqmask 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff echo -0x0 | sudo tee /sys/bus/ap/aqmask 0xfffffdffffffffffffffffffffffffffffffffffffffffffffffffffffffffffAssign adapter 0 and domain 16 (22 decimal) to
vfio-ap:>sudoecho +0x0 > /sys/devices/vfio_ap/matrix/${uuid}/assign_adapter>echo +0x16 | sudo tee /sys/devices/vfio_ap/matrix/${uuid}/assign_domain>echo +0x16 | sudo tee /sys/devices/vfio_ap/matrix/${uuid}/assign_control_domainVerify the matrix that you have configured:
>cat /sys/devices/vfio_ap/matrix/${uuid}/matrix 00.0016Either create a new VM and wait until it is initialized, or use an existing VM. In both cases, make sure the VM is shut down.
Change its configuration to use the MDEV device:
>sudovirsh edit VM_NAME [...] <hostdev mode='subsystem' type='mdev' model='vfio-ap'> <source> <address uuid='24f952b3-03d1-4df2-9967-0d5f7d63d5f2'/> </source> </hostdev> [...]Restart the VM:
>sudovirsh reboot VM_NAMELog in to the guest and verify that the adapter is present:
>lszcrypt CARD.DOMAIN TYPE MODE STATUS REQUEST_CNT ------------------------------------------------- 00 CEX5C CCA-Coproc online 1 00.0016 CEX5C CCA-Coproc online 1
8.18.5 Further reading #
The
vfio_aparchitecture is detailed in https://www.kernel.org/doc/Documentation/s390/vfio-ap.txt.A general outline together with a detailed procedure is described in https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1787405.
The architecture of VFIO Mediated devices (MDEVs) is detailed in https://www.kernel.org/doc/html/latest/driver-api/vfio-mediated-device.html.
9 Configuring virtual machines with Virtual Machine Manager #
Virtual Machine Manager's view offers in-depth information about the VM Guest's complete configuration and hardware equipment. Using this view, you can also change the guest configuration or add and modify virtual hardware. To access this view, open the guest's console in Virtual Machine Manager and either choose › from the menu, or click in the toolbar.
The left panel of the window lists VM Guest overview and already installed
hardware. After clicking an item on the list, you can access its detailed
settings in the details view. You can change the hardware parameters to
match your needs, then click to confirm them.
Certain changes take effect immediately, while others need a reboot of the
machine—and virt-manager warns you about that
fact.
To remove installed hardware from a VM Guest, select the appropriate list entry in the left panel and then click in the bottom right of the window.
To add new hardware, click below the left panel, then select the type of the hardware you want to add in the window. Modify its parameters and confirm with .
The following sections describe configuration options for the specific hardware type being added. They do not focus on modifying an existing piece of hardware, as the options are identical.
9.1 Machine setup #
This section describes the setup of the virtualized processor and memory hardware. These components are vital to a VM Guest, therefore you cannot remove them. It also shows how to view the overview and performance information, and how to change boot parameters.
9.1.1 Overview #
shows basic details about VM Guest and the hypervisor.
, , and are editable and help you identify VM Guest in the list of machines.
shows the universally unique identifier of the virtual machine, while shows its current status—, , or .
The section shows the hypervisor type, CPU architecture, used emulator, and chipset type. None of the hypervisor parameters can be changed.
9.1.2 Performance #
shows regularly updated charts of CPU and memory usage, and disk and network I/O.
Not all the charts in the view are enabled by default. To enable these charts, go to › , then select › › , and check the charts that you want to see regularly updated.
9.1.3 Processor #
includes detailed information about VM Guest processor configuration.
In the section, you can configure the number of virtual CPUs allocated to the VM Guest. shows the number of online and usable CPUs on the VM Host Server.
The section lets you configure the CPU model and topology.
When activated, the
option uses the host CPU model for VM Guest. You can see the details
of the host CPU model in the output of the virsh
capabilities command. When deactivated, the CPU model needs
to be specified from the models available in the drop-down box.
The host CPU model provides a good trade-off between CPU
features and the ability to migrate the VM Guest. libvirt does not model
every aspect of each CPU, so the VM Guest CPU does not match the
VM Host Server CPU exactly. But the ABI provided to the VM Guest is
reproducible and during migration the complete CPU model definition is
transferred to the destination VM Host Server, ensuring the migrated
VM Guest can see the exact same CPU model on the destination.
The host-passthrough model provides the VM Guest
with a CPU that is exactly the same as the VM Host Server CPU. This can be
useful when the VM Guest workload requires CPU features not available
in libvirt's simplified host-model CPU. The
host-passthrough model comes with the disadvantage
of reduced migration capability. A VM Guest with
host-passthrough model CPU can only be migrated to a
VM Host Server with identical hardware.
For more information on libvirt's CPU model and topology options, see
the CPU model and topology documentation at
https://libvirt.org/formatdomain.html#cpu-model-and-topology.
After you activate , you can specify a custom number of sockets, cores and threads for the CPU.
9.1.4 Memory #
contains information about the memory that is available to VM Guest.
Total amount of memory installed on VM Host Server.
The amount of memory currently available to VM Guest. You can hotplug more memory by increasing this value up to the value of .
Specify if the virtual machine can use shared memory via the
memfdbacked. It is a requirement for using the virtiofs file system. Find more details in https://libvirt.org/kbase/virtiofs.html.The maximum value to which you can hotplug the currently available memory. Any change to this value takes effect after the next VM Guest reboot.
- Enable launch security
If the VM Host Server supports AMD-SEV technology, activating this option enables a secured guest with encrypted memory. This option requires a virtual machine with chipset type Q35. For more details, refer to https://documentation.suse.com/sles/html/SLES-amd-sev/article-amd-sev.html.
VM Guests with memory requirements of 4 TB or more must either
use the host-passthrough CPU mode, or explicitly
specify the virtual CPU address size when using
host-model or custom CPU modes.
The default virtual CPU address size for these modes may not be
sufficient for memory configurations of 4 TB or more. The address size
can only be specified by editing the VM Guests XML configuration.
See Section 8.6, “Configuring memory allocation” for more
information on specifying virtual CPU address size.
9.1.5 Boot options #
introduces options affecting the VM Guest boot process.
In the section, you can specify whether the virtual machine should automatically start during the VM Host Server boot phase.
In the , activate the devices used for booting VM Guest. You can change their order with the up and down arrow buttons on the right side of the list. To choose from a list of bootable devices on VM Guest start, activate .
To boot a different kernel than the one on the boot device, activate and specify the paths to the alternative kernel and initrd placed on the VM Host Server file system. You can also specify kernel arguments that are passed to the loaded kernel.
9.2 Storage #
This section gives you a detailed description of configuration options for storage devices. It includes both hard disks and removable media, such as USB or CD-ROM drives.
Below the left panel, click to open the window. There, select .
Figure 13: Add a new storage #To create a
qcow2disk image in the default location, activate and specify its size in gigabytes.To gain more control over the disk image creation, activate and click to manage storage pools and images. The window opens, which has almost identical functionality as the tab described in Section 6.2.2, “Managing storage with Virtual Machine Manager”.
Tip: Supported storage formatsSUSE only supports the following storage formats:
rawandqcow2.After you create and specify the disk image file, specify the . It can be one of the following options:
: does not allow using .
: does not allow using .
: required to use an existing SCSI storage directly without adding it into a storage pool.
Select the for your device. The list of available options depends on the device type you selected in the previous step. The types based on use paravirtualized drivers.
In the section, select the preferred .
Confirm your settings with . A new storage device appears in the left panel.
9.3 Controllers #
This section focuses on adding and configuring new controllers.
Below the left panel, click to open the window. There, select .
Figure 14: Add a new controller #Select the type of the controller. You can choose from , , , , (paravirtualized), , or (smart card devices).
Optionally, for a USB or SCSI controller, select a controller model.
Confirm your settings with . A new controller appears in the left panel.
9.4 Networking #
This section describes how to add and configure new network devices.
Below the left panel, click to open the window. There, select .
Figure 15: Add a new network interface #From the list, select the source for the network connection. The list includes VM Host Server's available physical network interfaces, network bridges, or network bonds. You can also assign the VM Guest to an already defined virtual network. See Section 6.1, “Configuring networks” for more information on setting up virtual networks with Virtual Machine Manager.
Specify a for the network device. While Virtual Machine Manager pre-fills a random value for your convenience, it is recommended to supply a MAC address appropriate for your network environment to avoid network conflicts.
Select a device model from the list. You can either leave the , or specify one of , , or models. virtio uses paravirtualized drivers.
Confirm your settings with . A new network device appears in the left panel.
9.5 Input devices #
This section focuses on adding and configuring new input devices, such as a mouse, a keyboard or a tablet.
Below the left panel, click to open the window. There, select .
Figure 16: Add a new input device #Select a device type from the list.
Confirm your settings with . A new input device appears in the left panel.
When you click within a VM Guest's console with the mouse, the pointer is captured by the console window and cannot be used outside the console unless it is explicitly released (by pressing Alt–Ctrl). To prevent the console from grabbing the key and to enable seamless pointer movement between host and guest instead, follow the instructions in Procedure 8, “Adding a new input device” to add an to the VM Guest.
Adding a tablet has the additional advantage of synchronizing the mouse pointer movement between VM Host Server and VM Guest when using a graphical environment on the guest. With no tablet configured on the guest, you may often see two pointers with one dragging behind the other.
9.6 Video #
This section describes how to add and configure new video devices.
Below the left panel, click to open the window. There, select .
- Figure 17: Add a new video device #
Select a model from the drop-down box.
Note: Secondary video devicesOnly and can be added as secondary video devices.
Confirm your settings with . A new video device appears in the left panel.
9.7 USB redirectors #
USB devices that are connected to the client machine can be redirected to the VM Guest by using .
Below the left panel, click to open the window. There, select .
Figure 18: Add a new USB redirector #Select a device type from the list. Depending on your configuration, you can either select a or a redirector.
Confirm your settings with . A new USB redirector appears in the left panel.
9.8 Miscellaneous #
- Smartcard
Smartcard functionality can be added via the element. A physical USB smartcard reader can then be passed through to the VM Guest.
- Watchdog
Virtual watchdog devices are also supported. They can be created via the element. The model and the action of the device can be specified.
Tip: Requirements for virtual watchdog devicesQA virtual watchdog devices require a specific driver and daemon to be installed in the VM Guest. Otherwise, the virtual watchdog device does not work.
- TPM
You can use the Host TPM device in the VM Guest by adding TPM functionality via the element.
Tip: Virtual TPMsThe Host TPM can only be used in one VM Guest at a time.
9.9 Adding a CD/DVD-ROM device with Virtual Machine Manager #
KVM supports CD or DVD-ROMs in VM Guest either by directly accessing a
physical drive on the VM Host Server or by accessing ISO images. To create an
ISO image from an existing CD or DVD, use dd:
>sudodd if=/dev/CD_DVD_DEVICE of=my_distro.iso bs=2048
To add a CD/DVD-ROM device to your VM Guest, proceed as follows:
Double-click a VM Guest entry in the Virtual Machine Manager to open its console and switch to the view with › .
Click and choose in the pop-up window.
Change the to .
Select .
To assign the device to a physical medium, enter the path to the VM Host Server's CD/DVD-ROM device, for example,
/dev/cdrom) next to . Alternatively, use to open a file browser and then click to select the device. Assigning the device to a physical medium is only possible when the Virtual Machine Manager was started on the VM Host Server.To assign the device to an existing image, click to choose an image from a storage pool. If the Virtual Machine Manager was started on the VM Host Server, alternatively choose an image from another location on the file system by clicking . Select an image and close the file browser with .
Save the new virtualized device with .
Reboot the VM Guest to make the new device available. For more information, see Section 9.11, “Ejecting and changing floppy or CD/DVD-ROM media with Virtual Machine Manager”.
9.10 Adding a floppy device with Virtual Machine Manager #
Currently, KVM only supports the use of floppy disk images—using a
physical floppy drive is not supported. Create a floppy disk image from
an existing floppy using dd:
>sudodd if=/dev/fd0 of=/var/lib/libvirt/images/floppy.img
To create an empty floppy disk image, use one of the following commands:
- Raw image
>sudodd if=/dev/zero of=/var/lib/libvirt/images/floppy.img bs=512 count=2880- FAT formatted image
>sudomkfs.msdos -C /var/lib/libvirt/images/floppy.img 1440
To add a floppy device to your VM Guest, proceed as follows:
Double-click a VM Guest entry in the Virtual Machine Manager to open its console and switch to the view with › .
Click and choose in the pop-up window.
Change the to .
Choose and click to choose an existing image from a storage pool. If Virtual Machine Manager was started on the VM Host Server, alternatively choose an image from another location on the file system by clicking . Select an image and close the file browser with .
Save the new virtualized device with .
Reboot the VM Guest to make the new device available. For more information, see Section 9.11, “Ejecting and changing floppy or CD/DVD-ROM media with Virtual Machine Manager”.
9.11 Ejecting and changing floppy or CD/DVD-ROM media with Virtual Machine Manager #
Whether you are using the VM Host Server's physical CD/DVD-ROM device or an
ISO/floppy image: before you can change the media or image of an existing
device in the VM Guest, you first need to disconnect
the media from the guest.
Double-click a VM Guest entry in the Virtual Machine Manager to open its console and switch to the view with › .
Choose the Floppy or CD/DVD-ROM device and “eject” the medium by clicking .
To “insert” a new medium, click .
If using the VM Host Server's physical CD/DVD-ROM device, first change the media in the device (this may require unmounting it on the VM Host Server before it can be ejected). Then choose and select the device from the drop-down box.
If you are using an ISO image, choose and select an image by clicking . When connecting from a remote host, you may only choose images from existing storage pools.
Click to finish. The new media can now be accessed in the VM Guest.
9.12 Assigning a host PCI device to a VM Guest #
You can directly assign host-PCI devices to guests (PCI pass-through). When the PCI device is assigned to one VM Guest, it cannot be used on the host or by another VM Guest unless it is reassigned. A prerequisite for this feature is a VM Host Server configuration as described in Important: Requirements for VFIO and SR-IOV.
9.12.1 Adding a PCI device with Virtual Machine Manager #
The following procedure describes how to assign a PCI device from the host machine to a VM Guest using Virtual Machine Manager:
Double-click a VM Guest entry in the Virtual Machine Manager to open its console and switch to the view with › .
Click and choose the category in the left panel. A list of available PCI devices appears in the right part of the window.
Figure 19: Adding a PCI device #From the list of available PCI devices, choose the one you want to pass to the guest. Confirm with .
On a newer QEMU machine type (pc-i440fx-2.0 or higher) with
SLES 11 SP4 KVM guests, the
acpiphp module is not
loaded by default in the guest. This module must be loaded to enable
hotplugging of disk and network devices. To load the module manually,
use the command modprobe acpiphp. It is also
possible to autoload the module by adding install acpiphp
/bin/true to the
/etc/modprobe.conf.local file.
KVM guests using the QEMU Q35 machine type have a PCI topology
that includes a pcie-root controller and seven
pcie-root-port controllers. The
pcie-root controller does not support hotplugging.
Each pcie-root-port controller supports
hotplugging a single PCIe device. PCI controllers cannot be
hotplugged, so plan accordingly and add more
pcie-root-ports for more than seven hotplugged
PCIe devices. A pcie-to-pci-bridge controller can
be added to support hotplugging legacy PCI devices. See
https://libvirt.org/pci-hotplug.html for more
information about PCI topology between QEMU machine types.
9.13 Assigning a host USB device to a VM Guest #
Analogous to assigning host PCI devices (see Section 9.12, “Assigning a host PCI device to a VM Guest”), you can directly assign host USB devices to guests. When the USB device is assigned to one VM Guest, it cannot be used on the host or by another VM Guest unless it is reassigned.
9.13.1 Adding a USB device with Virtual Machine Manager #
To assign a host USB device to VM Guest using Virtual Machine Manager, follow these steps:
Double-click a VM Guest entry in the Virtual Machine Manager to open its console and switch to the view with › .
Click and choose the category in the left panel. A list of available USB devices appears in the right part of the window.
Figure 20: Adding a USB device #From the list of available USB devices, choose the one you want to pass to the guest. Confirm with . The new USB device appears in the left pane of the view.
Tip: USB device removalTo remove the host USB device assignment, click it in the left pane of the view and confirm with .
10 Advanced storage topics #
This chapter introduces advanced topics about manipulating storage from the perspective of the VM Host Server.
10.1 Locking disk files and block devices with virtlockd #
Locking block devices and disk files prevents concurrent writes to these resources from different VM Guests. It provides protection against starting the same VM Guest twice, or adding the same disk to two different virtual machines. This reduces the risk of a virtual machine's disk image becoming corrupted because of a wrong configuration.
The locking is controlled by a daemon called
virtlockd. Since it operates
independently from the libvirtd daemon, locks endure a crash or a
restart of libvirtd. Locks even persist during an update of the
virtlockd itself, since it can
re-execute itself. This ensures that VM Guests do
not need to be restarted upon a
virtlockd update.
virtlockd is supported for
KVM, QEMU.
10.1.1 Enable locking #
Locking virtual disks is not enabled by default on SUSE Linux Enterprise Server. To enable and automatically start it upon rebooting, perform the following steps:
Edit
/etc/libvirt/qemu.confand setlock_manager = "lockd"
Start the
virtlockddaemon with the following command:>sudosystemctl start virtlockdRestart the
libvirtddaemon with:>sudosystemctl restart libvirtdMake sure
virtlockdis automatically started when booting the system:>sudosystemctl enable virtlockd
10.1.2 Configure locking #
By default virtlockd is
configured to automatically lock all disks configured for your
VM Guests. The default setting uses a “direct” lockspace,
where the locks are acquired against the actual file paths associated
with the VM Guest <disk> devices. For example,
flock(2) is called directly on
/var/lib/libvirt/images/my-server/disk0.raw when
the VM Guest contains the following <disk> device:
<disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/my-server/disk0.raw'/> <target dev='vda' bus='virtio'/> </disk>
The virtlockd configuration can
be changed by editing the file
/etc/libvirt/qemu-lockd.conf. It also contains
detailed comments with further information. Make sure to activate
configuration changes by reloading
virtlockd:
>sudosystemctl reload virtlockd
10.1.2.2 Enable locking on LVM or iSCSI volumes #
When wanting to lock virtual disks placed on LVM or iSCSI volumes shared by several hosts, locking needs to be done by UUID rather than by path (which is used by default). Furthermore, the lockspace directory needs to be placed on a shared file system accessible by all hosts sharing the volume. Set the following options for LVM and/or iSCSI:
lvm_lockspace_dir = "/MY_LOCKSPACE_DIRECTORY" iscsi_lockspace_dir = "/MY_LOCKSPACE_DIRECTORY"
10.2 Online resizing of guest block devices #
Sometimes you need to change—extend or shrink—the size of the block device used by your guest system. For example, when the disk space originally allocated is no longer enough, it is time to increase its size. If the guest disk resides on a logical volume, you can resize it while the guest system is running. This is a big advantage over an offline disk resizing as the service provided by the guest is not interrupted by the resizing process. To resize a VM Guest disk, follow these steps:
Inside the guest system, check the current size of the disk (for example
/dev/vda).#fdisk -l /dev/vda Disk /dev/sda: 160.0 GB, 160041885696 bytes, 312581808 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytesOn the host, resize the logical volume holding the
/dev/vdadisk of the guest to the required size, for example, 200 GB.#lvresize -L 200G /dev/mapper/vg00-home Extending logical volume home to 200 GiB Logical volume home successfully resizedOn the host, resize the block device related to the disk
/dev/mapper/vg00-homeof the guest. You can find the DOMAIN_ID withvirsh list.#virsh blockresize --path /dev/vg00/home --size 200G DOMAIN_ID Block device '/dev/vg00/home' is resizedCheck that the new disk size is accepted by the guest.
#fdisk -l /dev/vda Disk /dev/sda: 200.0 GB, 200052357120 bytes, 390727260 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
10.4 Using RADOS block devices with libvirt #
RADOS Block Devices (RBD) store data in a Ceph cluster. They allow
snapshotting, replication and data consistency. You can use an RBD from
your libvirt-managed VM Guests similarly to how you use other block
devices.
For more details, refer to the SUSE Enterprise Storage Administration Guide, chapter Using libvirt with Ceph. The SUSE Enterprise Storage documentation is available from https://documentation.suse.com/ses/.
11 Basic VM Guest management #
Most management tasks, such as starting or stopping a VM Guest, can either
be done using the graphical application Virtual Machine Manager or on the command line using
virsh. Connecting to the graphical console via VNC is
only possible from a graphical user interface.
If started on a VM Host Server, the libvirt tools Virtual Machine Manager,
virsh, and virt-viewer can be used
to manage VM Guests on the host. However, it is also possible to manage
VM Guests on a remote VM Host Server. This requires configuring remote access
for libvirt on the host. For instructions, see
Section 12, “Connecting and authorizing”.
To connect to such a remote host with Virtual Machine Manager, you need to set up a
connection as explained in
Section 12.2.2, “Managing connections with Virtual Machine Manager”. If connecting to a
remote host using virsh or
virt-viewer, you need to specify a connection URI with
the parameter -c, for example, virsh -c
qemu+tls://saturn.example.com/system.
The form of connection URI depends on the
connection type and the hypervisor—see
Section 12.2, “Connecting to a VM Host Server” for details.
Examples in this chapter are all listed without a connection URI.
11.1 Listing VM Guests #
The VM Guest listing shows all VM Guests managed by libvirt on a
VM Host Server.
11.1.1 Listing VM Guests with Virtual Machine Manager #
The main window of the Virtual Machine Manager lists all VM Guests for each VM Host Server it is connected to. Each VM Guest entry contains the machine's name, its status (, , or ) displayed as an icon and literally, and a CPU usage bar.
11.1.2 Listing VM Guests with virsh #
Use the command virsh list to get a
list of VM Guests:
- List all running guests
>virsh list- List all running and inactive guests
>virsh list --all
For more information and further options, see virsh help
list or man 1 virsh.
11.2 Accessing the VM Guest via console #
VM Guests can be accessed via a VNC connection (graphical console) or, if supported by the guest operating system, via a serial console.
11.2.1 Opening a graphical console #
Opening a graphical console to a VM Guest lets you interact with the machine like a physical host via a VNC connection. If accessing the VNC server requires authentication, you are prompted to enter a user name (if applicable) and a password.
When you click into the VNC console, the cursor is “grabbed” and cannot be used outside the console anymore. To release it, press Alt–Ctrl.
To prevent the console from grabbing the cursor and to enable seamless cursor movement, add a tablet input device to the VM Guest.
Certain key combinations such as Ctrl–Alt–Del are interpreted by the host
system and are not passed to the VM Guest. To pass such key
combinations to a VM Guest, open the menu
from the VNC window and choose the desired key combination entry. The
menu is only available when using Virtual Machine Manager and
virt-viewer. With Virtual Machine Manager, you can alternatively use
the “sticky key” feature as explained in
Tip: Passing key combinations to virtual machines.
Principally all VNC viewers can connect to the console of a
VM Guest. However, if you are using SASL authentication and/or
TLS/SSL connection to access the guest, the options are limited.
Common VNC viewers such as tightvnc or
tigervnc support neither SASL authentication nor
TLS/SSL.
11.2.1.1 Opening a graphical console with Virtual Machine Manager #
In the Virtual Machine Manager, right-click a VM Guest entry.
Choose from the pop-up menu.
11.2.1.2 Opening a graphical console with virt-viewer #
virt-viewer is a simple VNC viewer with added
functionality for displaying VM Guest consoles. For example, it can
be started in “wait” mode, where it waits for a
VM Guest to start before it connects. It also supports automatically
reconnecting to a VM Guest that is rebooted.
virt-viewer addresses VM Guests by name, by ID or
by UUID. Use virsh list --all to
get this data.
To connect to a guest that is running or paused, use either the ID, UUID or name. VM Guests that are shut off do not have an ID—you can only connect to them by UUID or name.
- Connect to guest with the ID
8 >virt-viewer 8- Connect to the inactive guest named
sles12; the connection window opens once the guest starts >virt-viewer --wait sles12With the
--waitoption, the connection is upheld even if the VM Guest is not running at the moment. When the guest starts, the viewer is launched.
For more information, see virt-viewer
--help or man 1 virt-viewer.
When using virt-viewer to open a connection to a
remote host via SSH, the SSH password needs to be entered twice.
The first time for authenticating with libvirt, the second time
for authenticating with the VNC server. The second password needs
to be provided on the command line where virt-viewer was started.
11.2.2 Opening a serial console #
Accessing the graphical console of a virtual machine requires a
graphical environment on the client accessing the VM Guest. As an
alternative, virtual machines managed with libvirt can also be accessed
from the shell via the serial console and virsh. To
open a serial console to a VM Guest named “sles12”, run
the following command:
> virsh console sles12
virsh console takes two optional flags:
--safe ensures exclusive access to the console,
--force disconnects any existing sessions before
connecting. Both features need to be supported by the guest operating
system.
Being able to connect to a VM Guest via serial console requires that the guest operating system supports serial console access and is properly supported. Refer to the guest operating system manual for more information.
Serial console access in SUSE Linux Enterprise and openSUSE is disabled by default. To enable it, proceed as follows:
- SLES 15, 16 and openSUSE
Add
console=ttyS0to the Kernel Command Line Parameter.- SLES 11
Add
console=ttyS0to the Kernel Command Line Parameter. Additionally, edit/etc/inittaband uncomment the line with the following content:#S0:12345:respawn:/sbin/agetty -L 9600 ttyS0 vt102
11.3 Changing a VM Guest's state: start, stop, pause #
Starting, stopping or pausing a VM Guest can be done with either Virtual Machine Manager
or virsh. You can also configure a VM Guest to be
automatically started when booting the VM Host Server.
When shutting down a VM Guest, you may either shut it down gracefully, or force the shutdown. The latter is equivalent to pulling the power plug on a physical host and is only recommended if there are no alternatives. Forcing a shutdown may cause file system corruption and loss of data on the VM Guest.
To be able to perform a graceful shutdown, the VM Guest must be configured to support ACPI. If you have created the guest with the Virtual Machine Manager, ACPI should be available in the VM Guest.
Depending on the guest operating system, availability of ACPI may not be sufficient to perform a graceful shutdown. It is strongly recommended to test shutting down and rebooting a guest before using it in production. openSUSE or SUSE Linux Enterprise Desktop, for example, can require Polkit authorization for shutdown and reboot. Make sure this policy is turned off on all VM Guests.
If ACPI was enabled during a Windows XP/Windows Server 2003 guest installation, turning it on in the VM Guest configuration only is not sufficient. For more information, see:
Regardless of the VM Guest's configuration, a graceful shutdown is always possible from within the guest operating system.
11.3.1 Changing a VM Guest's state with Virtual Machine Manager #
Changing a VM Guest's state can be done either from Virtual Machine Manager's main window, or from a VNC window.
Right-click a VM Guest entry.
Choose , , or one of the from the pop-up menu.
Open a VNC Window as described in Section 11.2.1.1, “Opening a graphical console with Virtual Machine Manager”.
Choose , , or one of the options either from the toolbar or from the menu.
11.3.1.1 Automatically starting a VM Guest #
You can automatically start a guest when the VM Host Server boots. This feature is not enabled by default and needs to be enabled for each VM Guest individually. There is no way to activate it globally.
Double-click the VM Guest entry in Virtual Machine Manager to open its console.
Choose › to open the VM Guest configuration window.
Choose and check .
Save the new configuration with .
11.3.2 Changing a VM Guest's state with virsh #
In the following examples, the state of a VM Guest named “sles12” is changed.
- Start
>virsh start sles12- Pause
>virsh suspend sles12- Resume (a suspended VM Guest)
>virsh resume sles12- Reboot
>virsh reboot sles12- Graceful shutdown
>virsh shutdown sles12- Force shutdown
>virsh destroy sles12- Turn on automatic start
>virsh autostart sles12- Turn off automatic start
>virsh autostart --disable sles12
11.4 Saving and restoring the state of a VM Guest #
Saving a VM Guest preserves the exact state of the guest’s memory. The operation is similar to hibernating a computer. A saved VM Guest can be quickly restored to the same running condition prior to the save operation.
When saved, the VM Guest is paused, its current memory state is saved to a file, and then the guest is stopped. The operation does not make a copy of any portion of the VM Guest’s virtual disk. The time required to save the virtual machine depends on the amount of memory allocated. The VM Guest's resources are returned to the VM Host Server following a successful save operation.
The restore operation loads a VM Guest’s previously saved memory state file and starts it. The guest is not booted but instead resumed at the point where it was previously saved. The operation is similar to coming out of hibernation.
libvirt supports several save file formats. The default format is called
raw and consists of a sequential stream of VM Guest
memory pages. The sequential layout of the raw format is
not well suited for multiple readers and writers.
In addition to the raw save file format, libvirt also
supports several compressed formats: zstd,
lzop, gzip, bzip2
and xz. Similar to the raw format, the
compressed formats consist of a sequential stream of VM Guest memory
pages, but are compressed by the named compression algorithm before being written
to or read from the save file. These formats conserve space on the
device holding the save file, but increase save/restore times and host
CPU usage.
The sparse save file format uses pre-calculated, fixed
offsets within the save file to read/write the VM Guest memory pages. This
results in a save file that is roughly the logical size of the VM Guest's
memory, although its on-disk size depends on the VM Guest's actual memory
usage. With fixed offsets for the VM Guest memory pages, the
sparse format is well suited to support multiple readers
and writers, which may improve save and restore times for VM Guests
with large memory allocations.
The default save file format can be changed with the
save_image_format setting in
/etc/libvirt/qemu.conf. The format can also be
specified when performing a save operation using virsh.
See Section 11.4.2, “Saving and restoring with virsh” for more information on
save and restore with virsh.
Because the VM Guest's state is saved to a file, make sure
there is enough space on the device hosting the save file. When
using the sparse save file format, the logical save
file size will be approximately the same as the VM Guest memory
allocation. However, the actual on-disk file size is usually smaller and
depends on the VM Guest memory usage. Unused memory in the VM Guest
is not written to the save file, hence the term sparse.
For the raw save file format, the logical
and on-disk file size are equivalent, and both depend on the
VM Guest's memory usage. Whether using the raw or
sparse format, the on-disk save file size in megabytes
can be estimated by running the following command in the VM Guest:
> free -mh | awk '/^Mem:/ {print $3}'The compressed formats will result in a smaller on-disk size, depending on the efficiency of the specified compression algorithm.
After a successful save operation, booting or starting the VM Guest by means other than a restore operation will render the saved state file obsolete. The save file may contain file system data that has not been flushed to disk. Attempting to restore the saved state after the VM Guest has executed by other means can result in file system corruption.
Always use the same application when saving and restoring VM Guests.
For example, if virsh is used to save a VM Guest,
do not restore it using Virtual Machine Manager. In this case, make sure to restore
using virsh.
If you restore the VM Guest after a long pause (hours) since it was
saved, its time synchronization service, for example,
chronyd, may refuse to synchronize its time. In this case,
manually synchronize VM Guest's time. For example, for KVM hosts,
you can use the QEMU guest agent and instruct the guest with the
guest-set-time.
11.4.1 Saving/restoring with Virtual Machine Manager #
Open a VNC connection window to a VM Guest. Make sure the guest is running.
Choose › › .
Open a VNC connection window to a VM Guest. Make sure the guest is not running.
Choose › .
If the VM Guest was previously saved using Virtual Machine Manager, you are not offered an option to the guest. However, note the caveats on machines saved with
virshoutlined in Warning: Always restore saved guests.
11.4.2 Saving and restoring with virsh #
libvirt provides more control over the save and restore operations
than Virtual Machine Manager. virsh save and virsh
restore support several options to modify the behavior of the
operations. In the most basic form, a VM Guest is saved by providing
its name, ID, or UUID and a file name. For example:
> virsh save openSUSE-Leap /virtual/saves/openSUSE-Leap.vmsavA basic VM Guest restore operation only requires specifying the save file name. For example:
> virsh restore /virtual/saves/openSUSE-Leap.vmsav
As VM Guest memory size increases, save and restore operations may
require additional options to attain satisfactory transfer rates,
particularly when the save image files are backed by high throughput
storage. The VM Host Server file system cache is often counterproductive
in these scenarios and should be avoided with the
bypass-cache option. For example:
> virsh save --bypass-cache openSUSE-Leap /virtual/saves/openSUSE-Leap.vmsav> virsh restore --bypass-cache /virtual/saves/openSUSE-Leap.vmsav
The time required to save and restore VM Guests to high throughput
storage can be improved by using multiple channels to write and read
the VM Guest memory pages. As noted in
Section 11.4, “Saving and restoring the state of a VM Guest”, the sparse
image format is required to use multiple channels. When selecting the
number of channels, care must be taken to ensure the operation does not
adversely affect other workloads running on the VM Host Server. When the
VM Host Server resources are statically partitioned, general advice would be
to use the same number of channels as physical CPUs dedicated to the
VM Guest. The vCPUs of a VM Guest are stopped at the start of a
save operation, thus it would be safe to use those CPU resources
to save VM Guest memory pages.
The following examples save and restore a VM Guest using 4 channels, while also bypassing the VM Host Server file system cache:
> virsh save --bypass-cache --image-format sparse --parallel-channels 4 openSUSE-Leap /virtual/saves/openSUSE-Leap.vmsav> virsh restore --bypass-cache --parallel-channels 4 /virtual/saves/openSUSE-Leap.vmsavThe image format is encoded in the save image file and does not need to be specified during a restore operation.
For more information on save/restore and the supported options, see
virsh help save, virsh help restore
or man 1 virsh.
11.5 Creating and managing snapshots #
VM Guest snapshots are snapshots of the complete virtual machine including the state of CPU, RAM, devices and the content of all writable disks. To use virtual machine snapshots, all the attached hard disks need to use the qcow2 disk image format, and at least one of them needs to be writable.
Snapshots let you restore the state of the machine at a particular point in time. This is useful when undoing a faulty configuration or the installation of a lot of packages. After starting a snapshot that was created while the VM Guest was shut off, you need to boot it. Any changes written to the disk afterward are lost when starting the snapshot.
Snapshots are supported on KVM VM Host Servers only.
11.5.1 Terminology #
There are several specific terms used to describe the types of snapshots:
- Internal snapshots
Snapshots that are saved into the qcow2 file of the original VM Guest. The file holds both the saved state of the snapshot and the changes made since the snapshot was taken. The main advantage of internal snapshots is that they are all stored in one file and therefore it is easy to copy or move them across multiple machines.
- External snapshots
When creating an external snapshot, the original qcow2 file is saved and made read-only, while a new qcow2 file is created to hold the changes. The original file is sometimes called a backing or base file, while the new file with all the changes is called an overlay or derived file. External snapshots are useful when performing backups of VM Guests. However, external snapshots are not supported by Virtual Machine Manager, and cannot be deleted by
virshdirectly.- Live snapshots
Snapshots created when the original VM Guest is running. Internal live snapshots support saving the devices, and memory and disk states, while external live snapshots with
virshsupport saving either the memory state, or the disk state, or both.- Offline snapshots
Snapshots created from a VM Guest that is shut off. This ensures data integrity as all the guest's processes are stopped and no memory is in use.
11.5.2 Creating and managing snapshots with Virtual Machine Manager #
Virtual Machine Manager supports only internal snapshots, either live or offline.
To open the snapshot management view in Virtual Machine Manager, open the VNC window as described in Section 11.2.1.1, “Opening a graphical console with Virtual Machine Manager”. Now either choose › or click in the toolbar.
The list of existing snapshots for the chosen VM Guest is displayed in the left-hand part of the window. The snapshot that was last started is marked with a green tick. The right-hand part of the window shows details of the snapshot currently marked in the list. These details include the snapshot's title and time stamp, the state of the VM Guest at the time the snapshot was taken and a description. Snapshots of running guests also include a screenshot. The can be changed directly from this view. Other snapshot data cannot be changed.
11.5.2.1 Creating a snapshot #
To take a new snapshot of a VM Guest, proceed as follows:
Optionally, shut down the VM Guest to create an offline snapshot.
Click in the bottom left corner of the VNC window.
The window opens.
Provide a and, optionally, a description. The name cannot be changed after the snapshot has been taken. To be able to identify the snapshot later easily, use a “speaking name”.
Confirm with .
11.5.2.2 Deleting a snapshot #
To delete a snapshot of a VM Guest, proceed as follows:
Click in the bottom left corner of the VNC window.
Confirm the deletion with .
11.5.2.3 Starting a snapshot #
To start a snapshot, proceed as follows:
Click in the bottom left corner of the VNC window.
Confirm the start with .
11.5.3 Creating and managing snapshots with virsh #
To list all existing snapshots for a domain
(admin_server in the following), run the
snapshot-list command:
> virsh snapshot-list --domain sle-ha-node1
Name Creation Time State
------------------------------------------------------------
sleha_12_sp2_b2_two_node_cluster 2016-06-06 15:04:31 +0200 shutoff
sleha_12_sp2_b3_two_node_cluster 2016-07-04 14:01:41 +0200 shutoff
sleha_12_sp2_b4_two_node_cluster 2016-07-14 10:44:51 +0200 shutoff
sleha_12_sp2_rc3_two_node_cluster 2016-10-10 09:40:12 +0200 shutoff
sleha_12_sp2_gmc_two_node_cluster 2016-10-24 17:00:14 +0200 shutoff
sleha_12_sp3_gm_two_node_cluster 2017-08-02 12:19:37 +0200 shutoff
sleha_12_sp3_rc1_two_node_cluster 2017-06-13 13:34:19 +0200 shutoff
sleha_12_sp3_rc2_two_node_cluster 2017-06-30 11:51:24 +0200 shutoff
sleha_15_b6_two_node_cluster 2018-02-07 15:08:09 +0100 shutoff
sleha_15_rc1_one-node 2018-03-09 16:32:38 +0100 shutoff
The snapshot that was last started is shown with the
snapshot-current command:
> virsh snapshot-current --domain admin_server
Basic installation incl. SMT for CLOUD4
Details about a particular snapshot can be obtained by running the
snapshot-info command:
> virsh snapshot-info --domain admin_server \
-name "Basic installation incl. SMT for CLOUD4"
Name: Basic installation incl. SMT for CLOUD4
Domain: admin_server
Current: yes
State: shutoff
Location: internal
Parent: Basic installation incl. SMT for CLOUD3-HA
Children: 0
Descendants: 0
Metadata: yes11.5.3.1 Creating internal snapshots #
To take an internal snapshot of a VM Guest, either a live or
offline, use the snapshot-create-as command as
follows:
> virsh snapshot-create-as --domain admin_server1 --name "Snapshot 1"2 \
--description "First snapshot"311.5.3.2 Creating external snapshots #
With virsh, you can take external snapshots of the
guest's memory state, disk state, or both.
To take both live and offline external snapshots of the guest's disk,
specify the --disk-only option:
> virsh snapshot-create-as --domain admin_server --name \
"Offline external snapshot" --disk-only
You can specify the --diskspec option to control how
the external files are created:
> virsh snapshot-create-as --domain admin_server --name \
"Offline external snapshot" \
--disk-only --diskspec vda,snapshot=external,file=/path/to/snapshot_file
To take a live external snapshot of the guest's memory, specify the
--live and --memspec options:
> virsh snapshot-create-as --domain admin_server --name \
"Offline external snapshot" --live \
--memspec snapshot=external,file=/path/to/snapshot_file
To take a live external snapshot of both the guest's disk and memory
states, combine the --live,
--diskspec, and --memspec options:
> virsh snapshot-create-as --domain admin_server --name \
"Offline external snapshot" --live \
--memspec snapshot=external,file=/path/to/snapshot_file
--diskspec vda,snapshot=external,file=/path/to/snapshot_file
Refer to the SNAPSHOT COMMANDS section in
man 1 virsh for more details.
11.5.3.3 Deleting a snapshot #
External snapshots cannot be deleted with virsh.
To delete an internal snapshot of a VM Guest and restore the disk
space it occupies, use the snapshot-delete
command:
> virsh snapshot-delete --domain admin_server --snapshotname "Snapshot 2"11.5.3.4 Starting a snapshot #
To start a snapshot, use the snapshot-revert
command:
> virsh snapshot-revert --domain admin_server --snapshotname "Snapshot 1"
To start the current snapshot (the one the VM Guest was started
off), it is sufficient to use --current rather than
specifying the snapshot name:
> virsh snapshot-revert --domain admin_server --current11.6 Deleting a VM Guest #
By default, deleting a VM Guest using virsh removes
only its XML configuration. Since attached storage is not deleted by
default, you can reuse it with another VM Guest. With Virtual Machine Manager, you can
also delete a guest's storage files as well.
11.6.1 Deleting a VM Guest with Virtual Machine Manager #
In the Virtual Machine Manager, right-click a VM Guest entry.
From the context menu, choose .
A confirmation window opens. Clicking permanently erases the VM Guest. The deletion is not recoverable.
You can also permanently delete the guest's virtual disk by activating . The deletion is not recoverable either.
11.6.2 Deleting a VM Guest with virsh #
To delete a VM Guest, it needs to be shut down first. It is not possible to delete a running guest. For information on shutting down, see Section 11.3, “Changing a VM Guest's state: start, stop, pause”.
To delete a VM Guest with virsh, run
virsh undefine
VM_NAME.
> virsh undefine sles12There is no option to automatically delete the attached storage files. If they are managed by libvirt, delete them as described in Section 6.2.1.4, “Deleting volumes from a storage pool”.
11.7 Monitoring #
11.7.1 Monitoring with Virtual Machine Manager #
After starting Virtual Machine Manager and connecting to the VM Host Server, a CPU usage graph of all the running guests is displayed.
It is also possible to get information about disk and network usage with this tool, however, you must first activate this in :
Run
virt-manager.Select › .
Change the tab from to .
Activate the check boxes for the kind of activity you want to see: , , and .
If desired, also change the update interval using .
Close the dialog.
Activate the graphs that should be displayed under › .
Afterward, the disk and network statistics are also displayed in the main window of the Virtual Machine Manager.
More precise data is available from the VNC window. Open a VNC window as described in Section 11.2.1, “Opening a graphical console”. Choose from the toolbar or the menu. The statistics are displayed from the entry of the left-hand tree menu.
11.7.2 Monitoring with virt-top #
virt-top is a command-line tool similar to the
well-known process monitoring tool top.
virt-top uses libvirt and therefore is capable of
showing statistics for VM Guests running on different hypervisors.
By default virt-top shows statistics for all running
VM Guests. Among the data that is displayed is the percentage of
memory used (%MEM) and CPU (%CPU)
and the uptime of the guest (TIME). The data is
updated regularly (every three seconds by default). The following shows
the output on a VM Host Server with seven VM Guests, four of them inactive:
virt-top 13:40:19 - x86_64 8/8CPU 1283MHz 16067MB 7.6% 0.5%
7 domains, 3 active, 3 running, 0 sleeping, 0 paused, 4 inactive D:0 O:0 X:0
CPU: 6.1% Mem: 3072 MB (3072 MB by guests)
ID S RDRQ WRRQ RXBY TXBY %CPU %MEM TIME NAME
7 R 123 1 18K 196 5.8 6.0 0:24.35 sled12_sp1
6 R 1 0 18K 0 0.2 6.0 0:42.51 sles12_sp1
5 R 0 0 18K 0 0.1 6.0 85:45.67 opensuse_leap
- (Ubuntu_1410)
- (debian_780)
- (fedora_21)
- (sles11sp3)By default the output is sorted by ID. Use the following key combinations to change the sort field:
| Shift–P: CPU usage |
| Shift–M: total memory allocated by the guest |
| Shift–T: time |
| Shift–I: ID |
To use any other field for sorting, press Shift–F and select a field from the list. To toggle the sort order, use Shift–R.
virt-top also supports different views on the
VM Guests data, which can be changed on-the-fly by pressing the
following keys:
| 0: default view |
| 1: show physical CPUs |
| 2: show network interfaces |
| 3: show virtual disks |
virt-top supports more hot keys to change the view
of the data and many command line switches that affect the behavior of
the program. For more information, see man 1
virt-top.
11.7.3 Monitoring with kvm_stat #
kvm_stat can be used to trace KVM performance
events. It monitors /sys/kernel/debug/kvm, so it
needs the debugfs to be mounted. On SUSE Linux Enterprise Server it should be mounted
by default. In case it is not mounted, use the following command:
>sudomount -t debugfs none /sys/kernel/debug
kvm_stat can be used in three different modes:
kvm_stat # update in 1 second intervals
kvm_stat -1 # 1 second snapshot
kvm_stat -l > kvmstats.log # update in 1 second intervals in log format
# can be imported to a spreadsheetkvm_stat #kvm statistics efer_reload 0 0 exits 11378946 218130 fpu_reload 62144 152 halt_exits 414866 100 halt_wakeup 260358 50 host_state_reload 539650 249 hypercalls 0 0 insn_emulation 6227331 173067 insn_emulation_fail 0 0 invlpg 227281 47 io_exits 113148 18 irq_exits 168474 127 irq_injections 482804 123 irq_window 51270 18 largepages 0 0 mmio_exits 6925 0 mmu_cache_miss 71820 19 mmu_flooded 35420 9 mmu_pde_zapped 64763 20 mmu_pte_updated 0 0 mmu_pte_write 213782 29 mmu_recycled 0 0 mmu_shadow_zapped 128690 17 mmu_unsync 46 -1 nmi_injections 0 0 nmi_window 0 0 pf_fixed 1553821 857 pf_guest 1018832 562 remote_tlb_flush 174007 37 request_irq 0 0 signal_exits 0 0 tlb_flush 394182 148
See https://clalance.blogspot.com/2009/01/kvm-performance-tools.html for further information on how to interpret these values.
12 Connecting and authorizing #
Managing several VM Host Servers, each hosting multiple VM Guests, quickly
becomes difficult. One benefit of libvirt is the ability to connect to
several VM Host Servers at once, providing a single interface to manage all
VM Guests and to connect to their graphical console.
To ensure only authorized users can connect, libvirt offers several
connection types (via TLS, SSH, Unix sockets, and TCP) that can be combined
with different authorization mechanisms (socket, Polkit, SASL and Kerberos).
12.1 Authentication #
The power to manage VM Guests and to access their graphical console is something that should be restricted to a well-defined circle of persons. To achieve this goal, you can use the following authentication techniques on the VM Host Server:
Access control for Unix sockets with permissions and group ownership. This method is available for
libvirtdconnections only.Access control for Unix sockets with Polkit. This method is available for local
libvirtdconnections only.User name and password authentication with SASL (Simple Authentication and Security Layer). This method is available for both
libvirtdand VNC connections. Using SASL does not require real user accounts on the server, since it uses its own database to store user names and passwords. Connections authenticated with SASL are encrypted.Kerberos authentication. This method, available for
libvirtdconnections only, is not covered in this manual. Refer to https://libvirt.org/auth.html#ACL_server_kerberos for details.Single password authentication. This method is available for VNC connections only.
libvirtd and VNC needs to be configured separately
Access to the VM Guest's management functions (via libvirtd) and to
its graphical console always needs to be configured separately. When
restricting access to the management tools, these restrictions do
not automatically apply to VNC connections.
When accessing VM Guests from remote via TLS/SSL connections, access can be indirectly controlled on each client by restricting read permissions to the certificate's key file to a certain group. See Section 12.3.2.5, “Restricting access (security considerations)” for details.
12.1.1 libvirtd authentication #
libvirtd authentication is configured in
/etc/libvirt/libvirtd.conf. The configuration made
here applies to all libvirt tools such as the Virtual Machine Manager or
virsh.
libvirt offers two sockets: a read-only socket for monitoring
purposes and a read-write socket to be used for management operations.
Access to both sockets can be configured independently. By default,
both sockets are owned by root.root. Default access
permissions on the read-write socket are restricted to the user
root (0700) and fully open on the read-only
socket (0777).
The following instructions describe how to configure access permissions for the read-write socket. The same instructions also apply to the read-only socket. All configuration steps need to be carried out on the VM Host Server.
The default authentication method on SUSE Linux Enterprise Server is access control
for Unix sockets. Only the user root may authenticate. When
accessing the libvirt tools as a non-root user directly on the
VM Host Server, you need to provide the root password through Polkit
once. You are then granted access for the current and for future
sessions.
Alternatively, you can configure libvirt to allow
“system” access to non-privileged users. See
Section 12.2.1, ““system” access for non-privileged users” for details.
- Local connections
- Remote tunnel over SSH
Section 12.1.1.1, “Access control for Unix sockets with permissions and group ownership”
- Remote TLS/SSL connection
Section 12.1.1.3, “User name and password authentication with SASL”
none (access controlled on the client side by restricting access to the certificates)
12.1.1.1 Access control for Unix sockets with permissions and group ownership #
To grant access for non-root accounts, configure the sockets to
be owned and accessible by a certain group
(libvirt in the following
example). This authentication method can be used for local and remote
SSH connections.
In case it does not exist, create the group that should own the socket:
>sudogroupadd libvirtImportant: Group needs to existThe group must exist before restarting
libvirtd. If not, the restart fails.Add the desired users to the group:
>sudousermod --append --groups libvirt tuxChange the configuration in
/etc/libvirt/libvirtd.confas follows:unix_sock_group = "libvirt"1 unix_sock_rw_perms = "0770"2 auth_unix_rw = "none"3
Restart
libvirtd:>sudosystemctl start libvirtd
12.1.1.2 Local access control for Unix sockets with Polkit #
Access control for Unix sockets with Polkit is the default
authentication method on SUSE Linux Enterprise Server for non-remote connections.
Therefore, no libvirt configuration changes are needed. With Polkit
authorization enabled, permissions on both sockets default to
0777 and each application trying to access a
socket needs to authenticate via Polkit.
Authentication with Polkit can only be used for local connections on the VM Host Server itself, since Polkit does not handle remote authentication.
Two policies for accessing libvirt's sockets exist:
org.libvirt.unix.monitor: accessing the read-only socket
org.libvirt.unix.manage: accessing the read-write socket
By default, the policy for accessing the read-write socket is to
authenticate with the root password once and grant the
privilege for the current and for future sessions.
To grant users access to a socket without having to provide the
root password, you need to create a rule in
/etc/polkit-1/rules.d. Create the file
/etc/polkit-1/rules.d/10-grant-libvirt with the
following content to grant access to the read-write socket to all
members of the group
libvirt:
polkit.addRule(function(action, subject) {
if (action.id == "org.libvirt.unix.manage" && subject.isInGroup("libvirt")) {
return polkit.Result.YES;
}
});12.1.1.3 User name and password authentication with SASL #
SASL provides user name and password authentication and data encryption (digest-md5, by default). Since SASL maintains its own user database, the users do not need to exist on the VM Host Server. SASL is required by TCP connections and on top of TLS/SSL connections.
Using digest-md5 encryption on an otherwise not encrypted TCP connection does not provide enough security for production environments. It is recommended to only use it in testing environments.
Access from remote TLS/SSL connections can be indirectly controlled on the client side by restricting access to the certificate's key file. However, this may prove error-prone when dealing with many clients. Using SASL with TLS adds security by additionally controlling access on the server side.
To configure SASL authentication, proceed as follows:
Change the configuration in
/etc/libvirt/libvirtd.confas follows:To enable SASL for TCP connections:
auth_tcp = "sasl"
To enable SASL for TLS/SSL connections:
auth_tls = "sasl"
Restart
libvirtd:>sudosystemctl restart libvirtdThe libvirt SASL configuration file is located at
/etc/sasl2/libvirtd.conf. Normally, there is no need to change the defaults. However, if using SASL on top of TLS, you may turn off session encryption to avoid additional overhead (TLS connections are already encrypted) by commenting the line setting themech_listparameter. Only do this for TLS/SASL. For TCP connections, this parameter must be set to digest-md5.#mech_list: digest-md5
By default, no SASL users are configured, so no logins are possible. Use the following commands to manage users:
- Add the user
tux saslpasswd2 -a libvirt tux
- Delete the user
tux saslpasswd2 -a libvirt -d tux
- List existing users
sasldblistusers2 -f /etc/libvirt/passwd.db
- Add the user
virsh and SASL authentication
When using SASL authentication, you are prompted for a user name
and password every time you issue a virsh
command. Avoid this by using virsh in shell
mode.
12.1.2 VNC authentication #
Since access to the graphical console of a VM Guest is not controlled
by libvirt, but by the specific hypervisor, it is always
necessary to additionally configure VNC authentication. The main
configuration file is
/etc/libvirt/<hypervisor>.conf. This section
describes the QEMU/KVM hypervisor, so the target configuration file
is /etc/libvirt/qemu.conf.
Two authentication types are available: SASL and single-password
authentication. If you are using SASL for libvirt authentication, it
is strongly recommended to use it for VNC authentication as
well—it is possible to share the same database.
A third method to restrict access to the VM Guest is to enable the use of TLS encryption on the VNC server. This requires the VNC clients to have access to x509 client certificates. By restricting access to these certificates, access can indirectly be controlled on the client side. Refer to Section 12.3.2.4.2, “VNC over TLS/SSL: client configuration” for details.
12.1.2.1 User name and password authentication with SASL #
SASL provides user name and password authentication and data
encryption. Since SASL maintains its own user database, the users do
not need to exist on the VM Host Server. As with SASL authentication for
libvirt, you may use SASL on top of TLS/SSL connections. Refer to
Section 12.3.2.4.2, “VNC over TLS/SSL: client configuration” for
details on configuring these connections.
To configure SASL authentication for VNC, proceed as follows:
Create a SASL configuration file. It is recommended to use the existing
libvirtfile. If you have already configured SASL forlibvirtand are planning to use the same settings, including the same user name and password database, a simple link is suitable:>sudoln -s /etc/sasl2/libvirt.conf /etc/sasl2/qemu.confIf are setting up SASL for VNC only or you are planning to use a different configuration than for
libvirt, copy the existing file to use as a template:>sudocp /etc/sasl2/libvirt.conf /etc/sasl2/qemu.confThen edit it according to your needs.
Change the configuration in
/etc/libvirt/qemu.confas follows:vnc_listen = "0.0.0.0" vnc_sasl = 1 sasldb_path: /etc/libvirt/qemu_passwd.dbThe first parameter enables VNC to listen on all public interfaces (rather than to the local host only), and the second parameter enables SASL authentication.
By default, no SASL users are configured, so no logins are possible. Use the following commands to manage users:
- Add the user
tux >saslpasswd2 -f /etc/libvirt/qemu_passwd.db -a qemu tux- Delete the user
tux >saslpasswd2 -f /etc/libvirt/qemu_passwd.db -a qemu -d tux- List existing users
>sasldblistusers2 -f /etc/libvirt/qemu_passwd.db
- Add the user
Restart
libvirtd:>sudosystemctl restart libvirtdRestart all VM Guests that have been running before changing the configuration. VM Guests that have not been restarted cannot use SASL authentication for VNC connects.
SASL authentication is currently supported by Virtual Machine Manager and
virt-viewer. Both viewers also support
TLS/SSL connections.
12.1.2.2 Single password authentication #
Access to the VNC server may also be controlled by setting a VNC password. You can either set a global password for all VM Guests or set individual passwords for each guest. The latter requires editing the VM Guest's configuration files.
If you are using single password authentication, it is good practice to set a global password even if setting passwords for each VM Guest. This protects your virtual machines with a “fallback” password if you forget to set a per-machine password. The global password is only used if no other password is set for the machine.
Change the configuration in
/etc/libvirt/qemu.confas follows:vnc_listen = "0.0.0.0" vnc_password = "PASSWORD"The first parameter enables VNC to listen on all public interfaces (rather than to the local host only), and the second parameter sets the password. The maximum length of the password is eight characters.
Restart
libvirtd:>sudosystemctl restart libvirtdRestart all VM Guests that have been running before changing the configuration. VM Guests that have not been restarted cannot use password authentication for VNC connects.
Change the configuration in
/etc/libvirt/qemu.confas follows to enable VNC to listen on all public interfaces (rather than to the local host only).vnc_listen = "0.0.0.0"
Open the VM Guest's XML configuration file in an editor. Replace VM_NAME in the following example with the name of the VM Guest. The editor that is used defaults to
$EDITOR. If that variable is not set,viis used.>virsh edit VM_NAMESearch for the element
<graphics>with the attributetype='vnc', for example:<graphics type='vnc' port='-1' autoport='yes'/>
Add the
passwd=PASSWORDattribute, save the file and exit the editor. The maximum length of the password is eight characters.<graphics type='vnc' port='-1' autoport='yes' passwd='PASSWORD'/>
Restart
libvirtd:>sudosystemctl restart libvirtdRestart all VM Guests that have been running before changing the configuration. VM Guests that have not been restarted cannot use password authentication for VNC connects.
The VNC protocol is not considered to be safe. Although the
password is sent encrypted, it may be vulnerable when an attacker
can sniff both the encrypted password and the encryption key.
Therefore, it is recommended to use VNC with TLS/SSL or tunneled
over SSH. virt-viewer, and Virtual Machine Manager
support both methods.
12.2 Connecting to a VM Host Server #
To connect to a hypervisor with libvirt, you need to specify a uniform
resource identifier (URI). This URI is needed with
virsh and virt-viewer (except when
working as root on the VM Host Server) and is optional for the Virtual Machine Manager.
Although the latter can be called with a connection parameter (for
example, virt-manager -c qemu:///system), it also
offers a graphical interface to create connection URIs. See
Section 12.2.2, “Managing connections with Virtual Machine Manager” for details.
HYPERVISOR1+PROTOCOL2://USER@REMOTE3/CONNECTION_TYPE4
Specify the hypervisor. SUSE Linux Enterprise Server currently supports the
following hypervisors: | |
When connecting to a remote host, specify the protocol here. It can
be one of: | |
When connecting to a remote host, specify the user name and the
remote host name. If no user name is specified, the user name that
has called the command ( | |
When connecting to the |
test:///defaultConnect to the local testing hypervisor.
qemu+ssh://tux@mercury.example.com/systemConnect to the QEMU hypervisor on the remote host mercury.example.com. The connection is established via an SSH tunnel.
qemu+tls://saturn.example.com/systemConnect to the QEMU hypervisor on the remote host mercury.example.com. The connection is established using TLS/SSL.
For more details and examples, refer to the libvirt documentation at
https://libvirt.org/uri.html.
A user name needs to be specified when using Unix socket authentication (regardless of whether using the user/password authentication scheme or Polkit). This applies to all SSH and local connections.
There is no need to specify a user name when using SASL authentication (for TCP or TLS connections) or when doing no additional server-side authentication for TLS connections. With SASL, the user name is not evaluated—you are prompted for an SASL user/password combination in any case.
12.2.1 “system” access for non-privileged users #
As mentioned above, a connection to the QEMU hypervisor can be
established using two different protocols: session
and system. A “session” connection is
spawned with the same privileges as the client program. Such a
connection is intended for desktop virtualization, since it is
restricted, for example, no USB/PCI device assignments, no virtual
network setup, limited remote access to libvirtd.
The “system” connection intended for server virtualization
has no functional restrictions but is, by default, only accessible by
root. However, with the addition of the DAC (Discretionary Access
Control) driver to libvirt, it is now possible to grant non-privileged
users “system” access. To grant “system”
access to the user tux, proceed as follows:
Enable access via Unix sockets, as described in Section 12.1.1.1, “Access control for Unix sockets with permissions and group ownership”. In that example, access to libvirt is granted to all members of the group
libvirtandtuxmade a member of this group. This ensures thattuxcan connect usingvirshor Virtual Machine Manager.Edit
/etc/libvirt/qemu.confand change the configuration as follows:user = "tux" group = "libvirt" dynamic_ownership = 1This ensures that the VM Guests are started by
tuxand that resources bound to the guest, for example, virtual disks, can be accessed and modified bytux.Make
tuxa member of the groupkvm:>sudousermod --append --groups kvm tuxThis step is needed to grant access to
/dev/kvm, which is required to start VM Guests.Restart
libvirtd:>sudosystemctl restart libvirtd
12.2.2 Managing connections with Virtual Machine Manager #
The Virtual Machine Manager uses a Connection for every VM Host Server it
manages. Each connection contains all VM Guests on the respective
host. By default, a connection to the local host is already configured
and connected.
All configured connections are displayed in the Virtual Machine Manager main window. Active connections are marked with a small triangle, which you can click to fold or unfold the list of VM Guests for this connection.
Inactive connections are listed gray and are marked with Not
Connected. Either double-click or right-click it and choose
from the context menu. You can also
an existing connection from this menu.
It is not possible to edit an existing connection. To change a connection, create a new one with the desired parameters and delete the “old” one.
To add a new connection in the Virtual Machine Manager, proceed as follows:
Choose ›
Choose the host's ()
(Optional) To set up a remote connection, choose . For more information, see Section 12.3, “Configuring remote connections”.
In case of a remote connection, specify the of the remote machine in the format
USERNAME@REMOTE _HOST.Important: Specifying a user nameThere is no need to specify a user name for TCP and TLS connections: in these cases, it is not evaluated. However, for SSH connections, specifying a user name is necessary when you want to connect as a user other than
root.If you do not want the connection to be automatically started when starting the Virtual Machine Manager, deactivate .
Finish the configuration by clicking .
12.3 Configuring remote connections #
A major benefit of libvirt is the ability to manage VM Guests on
different remote hosts from a central location. This section gives
detailed instructions on how to configure server and client to allow
remote connections.
12.3.1 Remote tunnel over SSH (qemu+ssh) #
Enabling a remote connection that is tunneled over SSH on the VM Host Server
only requires the ability to accept SSH connections. Make sure the SSH
daemon is started (systemctl status sshd) and that
the ports for service SSH are
opened in the firewall.
User authentication for SSH connections can be done using traditional
file user/group ownership and permissions as described in
Section 12.1.1.1, “Access control for Unix sockets with permissions and group ownership”.
Connecting as user tux
(qemu+ssh://tuxsIVname;/system) works
out of the box and does not require additional configuration on the
libvirt side.
When connecting via SSH
qemu+ssh://USER@SYSTEM
you need to provide the password for USER.
This can be avoided by copying your public key to
~USER/.ssh/authorized_keys
on the VM Host Server.
12.3.2 Remote TLS/SSL connection with x509 certificate (qemu+tls #
Using TCP connections with TLS/SSL encryption and authentication via x509 certificates is much more complicated to set up than SSH, but it is a lot more scalable. Use this method if you need to manage several VM Host Servers with a varying number of administrators.
12.3.2.1 Basic concept #
TLS (Transport Layer Security) encrypts the communication between two computers by using certificates. The computer starting the connection is always considered the “client”, using a “client certificate”, while the receiving computer is always considered the “server”, using a “server certificate”. This scenario applies, for example, if you manage your VM Host Servers from a central desktop.
If connections are initiated from both computers, each needs to have a client and a server certificate. This is the case, for example, if you migrate a VM Guest from one host to another.
Each x509 certificate has a matching private key file. Only the combination of certificate and private key file can identify itself correctly. To assure that a certificate was issued by the assumed owner, it is signed and issued by a central certificate called certificate authority (CA). Both the client and the server certificates must be issued by the same CA.
Using a remote TLS/SSL connection only ensures that two computers are allowed to communicate in a certain direction. Restricting access to certain users can indirectly be achieved on the client side by restricting access to the certificates. For more information, see Section 12.3.2.5, “Restricting access (security considerations)”.
libvirt also supports user authentication on the server with
SASL. For more information, see
Section 12.3.2.6, “Central user authentication with SASL for TLS sockets”.
12.3.2.2 Configuring the VM Host Server #
The VM Host Server is the machine receiving connections. Therefore, the
server certificates need to be installed. The CA
certificate needs to be installed, too. When the certificates are in
place, TLS support can be turned on for libvirt.
Create the server certificate and export it together with the respective CA certificate.
Create the following directories on the VM Host Server:
>sudomkdir -p /etc/pki/CA/ /etc/pki/libvirt/private/Install the certificates as follows:
>sudo/etc/pki/CA/cacert.pem>sudo/etc/pki/libvirt/servercert.pem>sudo/etc/pki/libvirt/private/serverkey.pemImportant: Restrict access to certificatesMake sure to restrict access to certificates, as explained in Section 12.3.2.5, “Restricting access (security considerations)”.
Enable TLS support by enabling the relevant socket and restarting
libvirtd:>sudosystemctl stop libvirtd.service>sudosystemctl enable --now libvirtd-tls.socket>sudosystemctl start libvirtd.serviceBy default,
libvirtuses the TCP port 16514 for accepting secure TLS connections. Open this port in the firewall.
libvirtd with TLS enabled
If you enable TLS for libvirt, the server certificates need to be
in place, otherwise restarting libvirtd fails. You also need to
restart libvirtd in case you change the certificates.
12.3.2.3 Configuring the client and testing the setup #
The client is the machine initiating connections. Therefore the client certificates need to be installed. The CA certificate needs to be installed, too.
Create the client certificate and export it together with the respective CA certificate.
Create the following directories on the client:
>sudomkdir -p /etc/pki/CA/ /etc/pki/libvirt/private/Install the certificates as follows:
>sudo/etc/pki/CA/cacert.pem>sudo/etc/pki/libvirt/clientcert.pem>sudo/etc/pki/libvirt/private/clientkey.pemImportant: Restrict access to certificatesMake sure to restrict access to certificates, as explained in Section 12.3.2.5, “Restricting access (security considerations)”.
Test the client/server setup by issuing the following command. Replace mercury.example.com with the name of your VM Host Server. Specify the same fully qualified host name as used when creating the server certificate.
#QEMU/KVM virsh -c qemu+tls://mercury.example.com/system list --allIf your setup is correct, you can see a list of all VM Guests registered with
libvirton the VM Host Server.
12.3.2.4 Enabling VNC for TLS/SSL connections #
Currently, VNC communication over TLS is only supported by a few
tools. Common VNC viewers such as tightvnc or
tigervnc do not support TLS/SSL.
12.3.2.4.1 VNC over TLS/SSL: VM Host Server configuration #
To access the graphical console via VNC over TLS/SSL, you need to configure the VM Host Server as follows:
Open ports for the service
VNCin your firewall.Create a directory
/etc/pki/libvirt-vncand link the certificates into this directory as follows:>sudomkdir -p /etc/pki/libvirt-vnc && cd /etc/pki/libvirt-vnc>sudoln -s /etc/pki/CA/cacert.pem ca-cert.pem>sudoln -s /etc/pki/libvirt/servercert.pem server-cert.pem>sudoln -s /etc/pki/libvirt/private/serverkey.pem server-key.pemEdit
/etc/libvirt/qemu.confand set the following parameters:vnc_listen = "0.0.0.0" vnc_tls = 1 vnc_tls_x509_verify = 1Restart the
libvirtd:>sudosystemctl restart libvirtdImportant: VM Guests need to be restartedThe VNC TLS setting is only set when starting a VM Guest. Therefore, you need to restart all machines that have been running before making the configuration change.
12.3.2.4.2 VNC over TLS/SSL: client configuration #
The only action needed on the client side is to place the x509
client certificates in a location recognized by the client of
choice. However, Virtual Machine Manager and virt-viewer expect
the certificates in a different location. Virtual Machine Manager can either read
from a system-wide location applying to all users, or from a
per-user location.
- Virtual Machine Manager (
virt-manager) To connect to the remote host, Virtual Machine Manager requires the setup explained in Section 12.3.2.3, “Configuring the client and testing the setup”. To be able to connect via VNC, the client certificates also need to be placed in the following locations:
- System-wide location
/etc/pki/CA/cacert.pem/etc/pki/libvirt-vnc/clientcert.pem/etc/pki/libvirt-vnc/private/clientkey.pem- Per-user location
/etc/pki/CA/cacert.pem~/.pki/libvirt-vnc/clientcert.pem~/.pki/libvirt-vnc/private/clientkey.pem
virt-viewervirt-vieweronly accepts certificates from a system-wide location:/etc/pki/CA/cacert.pem/etc/pki/libvirt-vnc/clientcert.pem/etc/pki/libvirt-vnc/private/clientkey.pem
Make sure to restrict access to certificates, as explained in Section 12.3.2.5, “Restricting access (security considerations)”.
12.3.2.5 Restricting access (security considerations) #
Each x509 certificate consists of two pieces: the public certificate and a private key. A client can only authenticate using both pieces. Therefore, any user that has read access to the client certificate and its private key can access your VM Host Server. On the other hand, an arbitrary machine equipped with the full server certificate can pretend to be the VM Host Server. Since this is not desirable, access to at least the private key files needs to be restricted as much as possible. The easiest way to control access to a key file is to use access permissions.
- Server certificates
Server certificates need to be readable for QEMU processes. On SUSE Linux Enterprise Server QEMU, processes started from
libvirttools are owned byroot, so it is sufficient if therootcan read the certificates:>chmod 700 /etc/pki/libvirt/private/>chmod 600 /etc/pki/libvirt/private/serverkey.pemIf you change the ownership for QEMU processes in
/etc/libvirt/qemu.conf, you also need to adjust the ownership of the key file.- System-wide client certificates
To control access to a key file that is available system-wide, restrict read access to a certain group, so that only members of that group can read the key file. In the following example, a group
libvirtis created, and group ownership of theclientkey.pemfile and its parent directory is set tolibvirt. Afterward, the access permissions are restricted to owner and group. Finally, the usertuxis added to the grouplibvirt, and thus can access the key file.CERTPATH="/etc/pki/libvirt/" # create group libvirt groupadd libvirt # change ownership to user root and group libvirt chown root.libvirt $CERTPATH/private $CERTPATH/clientkey.pem # restrict permissions chmod 750 $CERTPATH/private chmod 640 $CERTPATH/private/clientkey.pem # add user tux to group libvirt usermod --append --groups libvirt tux- Per-user certificates
User-specific client certificates for accessing the graphical console of a VM Guest via VNC need to be placed in the user's home directory in
~/.pki. Contrary to SSH, for example, the VNC viewer using these certificates does not check the access permissions of the private key file. Therefore, it is solely the user's responsibility to make sure the key file is not readable by others.
12.3.2.5.1 Restricting access from the server side #
By default, every client that is equipped with appropriate client certificates may connect to a VM Host Server accepting TLS connections. Therefore, it is possible to use additional server-side authentication with SASL as described in Section 12.1.1.3, “User name and password authentication with SASL”.
It is also possible to restrict access with a allowlist of DNs (distinguished names), so only clients with a certificate matching a DN from the list can connect.
Add a list of allowed DNs to tls_allowed_dn_list
in /etc/libvirt/libvirtd.conf. This list may
contain wild cards. Do not specify an empty list, since that would
result in refusing all connections.
tls_allowed_dn_list = [
"C=US,L=Provo,O=SUSE Linux Products GmbH,OU=*,CN=venus.example.com,EMAIL=*",
"C=DE,L=Nuremberg,O=SUSE Linux Products GmbH,OU=Documentation,CN=*"]Get the distinguished name of a certificate with the following command:
> certtool -i --infile /etc/pki/libvirt/clientcert.pem | grep "Subject:"
Restart libvirtd after having changed the configuration:
>sudosystemctl restart libvirtd
12.3.2.6 Central user authentication with SASL for TLS sockets #
A direct user authentication via TLS is not possible—this is
handled indirectly on each client via the read permissions for the
certificates as explained in
Section 12.3.2.5, “Restricting access (security considerations)”. However,
if a central, server-based user authentication is needed, libvirt
also allows to use SASL (Simple Authentication and Security Layer) on
top of TLS for direct user authentication. See
Section 12.1.1.3, “User name and password authentication with SASL” for
configuration details.
12.3.2.7 Troubleshooting #
12.3.2.7.1 Virtual Machine Manager/virsh cannot connect to server #
Check the following in the given order:
| Is it a firewall issue (TCP port 16514 needs to be open on the server)? |
Is the client certificate (certificate and key) readable by the
user that has started Virtual Machine Manager/ virsh?
|
| Has the same full qualified host name as in the server certificate been specified with the connection? |
Is TLS enabled on the server (listen_tls =
1)?
|
Has libvirtd been restarted on the server?
|
12.3.2.7.2 VNC connection fails #
Ensure that you can connect to the remote server using Virtual Machine Manager. If
so, check whether the virtual machine on the server has been
started with TLS support. The virtual machine's name in the
following example is sles.
> ps ax | grep qemu | grep "\-name sles" | awk -F" -vnc " '{ print FS $2 }'If the output does not begin with a string similar to the following, the machine has not been started with TLS support and must be restarted.
-vnc 0.0.0.0:0,tls,x509verify=/etc/pki/libvirt
13 Migrating VM Guests #
One of the major advantages of virtualization is that VM Guests are portable. When a VM Host Server needs maintenance, or when the host becomes overloaded, the guests can be moved to another VM Host Server. KVM even support “live” migrations, during which the VM Guest is constantly available.
13.1 Types of migration #
Depending on the required scenario, there are three ways you can migrate virtual machines (VMs).
- Live migration
The source VM continues to run while its configuration and memory are transferred to the target host. When the transfer is complete, the source VM is suspended and the target VM is resumed.
Live migration is useful for VMs that need to be online without any downtime.
NoteVMs experiencing heavy I/O load or frequent memory page writes are challenging to live migrate. In such cases, consider using non-live or offline migration.
- Non-live migration
The source VM is suspended and its configuration and memory are transferred to the target host. Then the target VM is resumed.
Non-live migration is more reliable than live migration, although it creates downtime for the VM. If downtime is tolerable, non-live migration can be an option for VMs that are difficult to live migrate.
- Offline migration
The VM definition is transferred to the target host. The source VM is not stopped and the target VM is not resumed.
Offline migration can be used to migrate inactive VMs.
ImportantWith offline migration, the
--persistentoption must be used.
13.2 Migration requirements #
To successfully migrate a VM Guest to another VM Host Server, the following requirements need to be met:
The source and target systems must have the same architecture.
Storage devices must be accessible from both machines, for example, via NFS or iSCSI. For more information, see Section 10, “Advanced storage topics”.
This is also true for CD-ROM or floppy images that are connected during the move. However, you can disconnect them before the move as described in Section 9.11, “Ejecting and changing floppy or CD/DVD-ROM media with Virtual Machine Manager”.
libvirtdneeds to run on both VM Host Servers and you must be able to open a remotelibvirtconnection between the target and the source host (or vice versa). Refer to Section 12.3, “Configuring remote connections” for details.If a firewall is running on the target host, ports need to be opened to allow the migration. If you do not specify a port during the migration process,
libvirtchooses one from the range 49152:49215. Make sure that either this range (recommended) or a dedicated port of your choice is opened in the firewall on the target host.The source and target machines should be in the same subnet on the network, otherwise networking fails after the migration.
All VM Host Servers participating in migration must have the same UID for the qemu user and the same GIDs for the kvm, qemu and libvirt groups.
No running or paused VM Guest with the same name must exist on the target host. If a shut-down machine with the same name exists, its configuration is overwritten.
All CPU models, except the host cpu model, are supported when migrating VM Guests.
The SATA disk device type is not migratable.
File system pass-through feature is incompatible with migration.
The VM Host Server and VM Guest need to have proper timekeeping installed.
No physical devices can be passed from host to guest. Live migration is currently not supported when using devices with PCI pass-through or SR-IOV. If live migration needs to be supported, use software virtualization (paravirtualization or full virtualization).
The cache mode setting is an important setting for migration.
Backward migration, for example, from SLES 15 SP2 to 15 SP1, is not supported.
SUSE strives to support live migration of VM Guests from a VM Host Server running a service pack under LTSS to a VM Host Server running a newer service pack within the same SLES major version. For example, VM Guest migration from a SLES 12 SP2 host to a SLES 12 SP5 host. SUSE only performs minimal testing of LTSS-to-newer migration scenarios and recommends thorough on-site testing before attempting to migrate critical VM Guests.
The image directory should be located at the same path on both hosts.
All hosts should be on the same level of microcode (especially the Spectre microcode updates). This can be achieved by installing the latest updates of SUSE Linux Enterprise Server on all hosts.
13.3 Live-migrating with Virtual Machine Manager #
When using the Virtual Machine Manager to migrate VM Guests, it does not matter on which machine it is started. You can start Virtual Machine Manager on the source or the target host or even on a third host. In the latter case, you need to be able to open remote connections to both the target and the source host.
Start Virtual Machine Manager and establish a connection to the target or the source host. If the Virtual Machine Manager was started neither on the target nor the source host, connections to both hosts need to be opened.
Right-click the VM Guest that you want to migrate and choose . Make sure the guest is running or paused—it is not possible to migrate guests that are shut down.
Tip: Increasing the speed of the migrationTo increase the speed of the migration, pause the VM Guest. This is the equivalent of “non-live migration” described in Section 13.1, “Types of migration”.
Choose a for the VM Guest. If the desired target host does not show up, make sure that you are connected to the host.
To change the default options for connecting to the remote host, under , set the , and the target host's (IP address or host name) and . If you specify a , you must also specify an .
Under , choose whether the move should be permanent (default) or temporary, using .
Additionally, there is the option , which allows migrating without disabling the cache of the VM Host Server. This can speed up the migration but only works when the current configuration allows for a consistent view of the VM Guest storage without using
cache="none"/0_DIRECT.Note: Bandwidth optionIn recent versions of Virtual Machine Manager, the option of setting a bandwidth for the migration has been removed. To set a specific bandwidth, use
virshinstead.To perform the migration, click .
When the migration is complete, the window closes and the VM Guest is now listed on the new host in the Virtual Machine Manager window. The original VM Guest is still available on the source host in the shut-down state.
13.4 Migrating with virsh #
To migrate a VM Guest with virsh
migrate, you need to have direct or remote shell access
to the VM Host Server, because the command needs to be run on the host. The
migration command looks like this:
> virsh migrate [OPTIONS] VM_ID_or_NAME CONNECTION_URI [--migrateuri tcp://REMOTE_HOST:PORT]
The most important options are listed below. See virsh help
migrate for a full list.
--liveDoes a live migration. If not specified, the guest is paused during the migration (“non-live migration”).
--suspendLeaves the VM paused on the target host during live or non-live migration.
--persistentPersists the migrated VM on the target host. Without this option, the VM is not included in the list of domains reported by
virsh list --allwhen shut down.--undefinesourceWhen specified, the VM Guest definition on the source host is deleted after a successful migration. However, virtual disks attached to this guest are not deleted.
--parallel --parallel-connections NUM_OF_CONNECTIONSParallel migration can be used to increase migration data throughput in cases where a single migration thread is not capable of saturating the network link between source and target hosts. On hosts with 40 GB network interfaces, it may require four migration threads to saturate the link. With parallel migration, the time required to migrate large memory VMs can be reduced.
The following examples use mercury.example.com as the source system and jupiter.example.com
as the target system; the VM Guest's name is
opensuse131 with ID 37.
- Non-live migration with default parameters
>virsh migrate 37 qemu+ssh://tux@jupiter.example.com/system- Transient live migration with default parameters
>virsh migrate --live opensuse131 qemu+ssh://tux@jupiter.example.com/system- Persistent live migration; delete VM definition on source
>virsh migrate --live --persistent --undefinesource 37 \ qemu+tls://tux@jupiter.example.com/system- Non-live migration using port 49152
>virsh migrate opensuse131 qemu+ssh://tux@jupiter.example.com/system \ --migrateuri tcp://@jupiter.example.com:49152- Live migration transferring all used storage
>virsh migrate --live --persistent --copy-storage-all \ opensuse156 qemu+ssh://tux@jupiter.example.com/systemImportantWhen migrating VM's storage using the
--copy-storage-alloption, the storage must be placed in alibvirtstorage pool. The target storage pool must exist with an identical type and name as the source pool.To obtain the XML representation of the source pool, use the following command:
>sudovirsh pool-dumpxml EXAMPLE_VM > EXAMPLE_POOL.xmlTo create and start the storage pool on the target host, copy its XML representation there and use the following commands:
>sudovirsh pool-define EXAMPLE_POOL.xml>sudovirsh pool-start EXAMPLE_VM
By default, virsh migrate creates a temporary
(transient) copy of the VM Guest on the target host. A shut-down
version of the original guest description remains on the source host. A
transient copy is deleted from the server after it is shut down.
To create a permanent copy of a guest on the target host, use the switch
--persistent. A shut-down version of the original guest
description remains on the source host, too. Use the option
--undefinesource together with
--persistent for a “real” move where a
permanent copy is created on the target host and the version on the
source host is deleted.
It is not recommended to use --undefinesource without
the --persistent option, since this results in the loss
of both VM Guest definitions when the guest is shut down on the target
host.
13.5 Step-by-step example #
13.5.1 Exporting the storage #
First, you need to export the storage to share the guest image between
hosts. This can be done by an NFS server. In the following example, we
want to share the /volume1/VM directory for all
machines that are on the network 10.0.1.0/24. We are using a SUSE Linux Enterprise NFS
server. As root user, edit the /etc/exports file
and add:
/volume1/VM 10.0.1.0/24 (rw,sync,no_root_squash)
You need to restart the NFS server:
>sudosystemctl restart nfsserver>sudoexportfs /volume1/VM 10.0.1.0/24
13.5.2 Defining the pool on the target hosts #
On each host where you want to migrate the VM Guest, the pool must be
defined to be able to access the volume (that contains the Guest image).
Our NFS server IP address is 10.0.1.99, its share is the
/volume1/VM directory, and we want to get it
mounted in the /var/lib/libvirt/images/VM
directory. The pool name is VM. To define this
pool, create a VM.xml file with the following
content:
<pool type='netfs'>
<name>VM</name>
<source>
<host name='10.0.1.99'/>
<dir path='/volume1/VM'/>
<format type='auto'/>
</source>
<target>
<path>/var/lib/libvirt/images/VM</path>
<permissions>
<mode>0755</mode>
<owner>-1</owner>
<group>-1</group>
</permissions>
</target>
</pool>
Then load it into libvirt using the pool-define
command:
# virsh pool-define VM.xml
An alternative way to define this pool is to use the
virsh command:
# virsh pool-define-as VM --type netfs --source-host 10.0.1.99 \
--source-path /volume1/VM --target /var/lib/libvirt/images/VM
Pool VM created
The following commands assume that you are in the interactive shell of
virsh, which can also be reached by using the command
virsh without any arguments. Then the pool can be set
to start automatically at host boot (autostart option):
virsh # pool-autostart VM
Pool VM marked as autostartedTo disable the autostart:
virsh # pool-autostart VM --disable
Pool VM unmarked as autostartedCheck if the pool is present:
virsh #pool-list --all Name State Autostart ------------------------------------------- default active yes VM active yesvirsh #pool-info VM Name: VM UUID: 42efe1b3-7eaa-4e24-a06a-ba7c9ee29741 State: running Persistent: yes Autostart: yes Capacity: 2,68 TiB Allocation: 2,38 TiB Available: 306,05 GiB
Remember: This pool must be defined on each host where you want to be able to migrate your VM Guest.
13.5.3 Creating the volume #
The pool has been defined—now we need a volume that contains the disk image:
virsh # vol-create-as VM sled12.qcow2 8G --format qcow2
Vol sled12.qcow2 createdThe volume names shown are used later to install the guest with virt-install.
13.5.4 Creating the VM Guest #
Let us create a SUSE Linux Enterprise Server VM Guest with the
virt-install command. The VM
pool is specified with the --disk option,
cache=none is recommended if you do not want to use
the --unsafe option while doing the migration.
# virt-install --connect qemu:///system --virt-type kvm --name \
sles15 --memory 1024 --disk vol=VM/sled12.qcow2,cache=none --cdrom \
/mnt/install/ISO/SLE-15-Server-DVD-x86_64-Build0327-Media1.iso --graphics \
vnc --os-variant sled15
Starting install...
Creating domain...13.5.5 Migrating the VM Guest #
Everything is ready to do the migration now. Run the
migrate command on the VM Host Server that is currently
hosting the VM Guest, and choose the target.
virsh # migrate --live sled12 --verbose qemu+ssh://IP/Hostname/system Password: Migration: [ 12 %]
14 I/O virtualization #
VM Guests not only share CPU and memory resources of the host system, but also the I/O subsystem. Because software I/O virtualization techniques deliver less performance than bare metal, hardware solutions that deliver almost “native” performance have been developed recently. SUSE Linux Enterprise Server supports the following I/O virtualization techniques:
- Full virtualization
Fully Virtualized (FV) drivers emulate widely supported real devices, which can be used with an existing driver in the VM Guest. The guest is also called Hardware Virtual Machine (HVM). Since the physical device on the VM Host Server may differ from the emulated one, the hypervisor needs to process all I/O operations before handing them over to the physical device. Therefore all I/O operations need to traverse two software layers, a process that not only significantly impacts I/O performance, but also consumes CPU time.
- Paravirtualization
Paravirtualization (PV) allows direct communication between the hypervisor and the VM Guest. With less overhead involved, performance is much better than with full virtualization. However, paravirtualization requires either the guest operating system to be modified to support the paravirtualization API or paravirtualized drivers. See Section 4.5.1, “Availability of paravirtualized drivers” for a list of guest operating systems supporting paravirtualization.
- PVHVM
This type of virtualization enhances HVM (see Full virtualization) with paravirtualized (PV) drivers, and PV interrupt and timer handling.
- VFIO
VFIO stands for Virtual Function I/O and is a new user-level driver framework for Linux. It replaces the traditional KVM PCI Pass-Through device assignment. The VFIO driver exposes direct device access to user space in a secure memory (IOMMU) protected environment. With VFIO, a VM Guest can directly access hardware devices on the VM Host Server (pass-through), avoiding performance issues caused by emulation in performance critical paths. This method does not allow to share devices—each device can only be assigned to a single VM Guest. VFIO needs to be supported by the VM Host Server CPU, chipset and the BIOS/EFI.
Compared to the legacy KVM PCI device assignment, VFIO has the following advantages:
Resource access is compatible with UEFI Secure Boot.
Device is isolated and its memory access protected.
Offers a user space device driver with more flexible device ownership model.
Is independent of KVM technology, and not bound to x86 architecture only.
In SUSE Linux Enterprise Server the USB and PCI pass-through methods of device assignment are considered deprecated and are superseded by the VFIO model.
- SR-IOV
The latest I/O virtualization technique, Single Root I/O Virtualization SR-IOV combines the benefits of the aforementioned techniques—performance and the ability to share a device with several VM Guests. SR-IOV requires special I/O devices, that are capable of replicating resources so they appear as multiple separate devices. Each such “pseudo” device can be directly used by a single guest. However, for network cards for example the number of concurrent queues that can be used is limited, potentially reducing performance for the VM Guest compared to paravirtualized drivers. On the VM Host Server, SR-IOV must be supported by the I/O device, the CPU and chipset, the BIOS/EFI and the hypervisor—.
To be able to use the VFIO and SR-IOV features, the VM Host Server needs to fulfill the following requirements:
IOMMU needs to be enabled in the BIOS/EFI.
For Intel CPUs, the kernel parameter
intel_iommu=onneeds to be provided on the kernel command line. For more information, see https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/kernel-parameters.txt#L1951.The VFIO infrastructure needs to be available. This can be achieved by loading the kernel module
vfio_pci.
15 For more information #
For further steps in virtualization, refer to the following sources:
16 Legal Notice #
Copyright© 2006–2026 SUSE LLC and contributors. All rights reserved.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or (at your option) version 1.3; with the Invariant Section being this copyright notice and license. A copy of the license version 1.2 is included in the section entitled “GNU Free Documentation License”.
For SUSE trademarks, see https://www.suse.com/company/legal/. All other third-party trademarks are the property of their respective owners. Trademark symbols (®, ™ etc.) denote trademarks of SUSE and its affiliates. Asterisks (*) denote third-party trademarks.
All information found in this book has been compiled with utmost attention to detail. However, this does not guarantee complete accuracy. Neither SUSE LLC, its affiliates, the authors, nor the translators shall be held liable for possible errors or the consequences thereof.






















