Guía de Virtualización OpenSuse en Color
Guía de Virtualización OpenSuse en Color
Virtualization Guide
openSUSE Leap 42.1
Describes virtualization technology in general, and introduces libvirtthe unified interface to
virtualizationand detailed information on specific hypervisors.
Cambridge MA 02141
USA
https://www.suse.com/documentation
Copyright 20062016 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 http://www.suse.com/company/legal/. All other third party trademarks are the property of
their respective owners. A trademark symbol (, etc.) denotes a SUSE or Novell trademark; an asterisk (*) denotes
a third party trademark.
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.
Contents
About This Manual xiv
I
1
1.1
Virtualization Technology 2
Overview 2
1.2
Virtualization Capabilities 3
1.3
Virtualization Benefits 3
1.4
1.5
I/O Virtualization 5
2.1
Basic Components 7
2.2
3.1
Basic Components 10
3.2
4
4.1
iii
INTRODUCTION 1
Virtualization Tools 13
5.1
5.2
Virtualization Guide
6.1
Installing KVM 17
6.2
Installing Xen 17
6.3
Installing Containers 18
6.4
Patterns 18
7
7.1
7.2
7.3
7.4
Feature Support 23
Host (Dom0) 23 Paravirtualized Guest 24 Fully Virtualized
Guest 25
II
Guest Installation 29
9.1
9.2
9.3
iv
Virtualization Guide
10
10.1
10.2
10.3
10.4
10.5
10.6
Deleting a VM Guest 49
Deleting a VM Guest with Virtual Machine Manager 50 Deleting a VM Guest
with virsh 50
10.7
Migrating VM Guests 50
Migration Requirements 51 Migrating with virt-manager 52 Migrating with virsh 53 Step-by-Step Example 54
10.8
Monitoring 58
Monitoring with Virtual Machine Manager 58 Monitoring with virttop 59 Monitoring with kvm_stat 60
11
11.1
11.2
Virtualization Guide
11.3
12
12.1
Managing Storage 84
Managing Storage with Virtual Machine Manager 86
Adding a Storage Pool 87 Managing Storage Pools 90
12.2
12.3
12.4
12.5
Sharing Directories between Host and Guests (File System PassThrough) 100
13
13.1
13.2
14
14.1
vi
14.2
Storage 121
14.3
Controllers 123
Virtualization Guide
14.4
Networking 124
14.5
14.6
14.7
14.8
14.9
14.10
14.11
III
15
15.1
15.2
15.3
15.4
15.5
16
16.1
16.2
vii
Virtualization Guide
17
17.1
libguestfs 151
VM Guest Manipulation Overview 151
VM Guest Manipulation Risk 151 libguestfs Design 152
17.2
17.3
17.4
Troubleshooting 159
Environment 160 libguestfs-test-tool 160
17.5
IV
18
18.1
18.2
18.3
18.4
18.5
19
viii
19.1
19.2
19.3
Virtualization Guide
19.4
19.5
20
20.1
20.2
20.3
20.4
20.5
20.6
21
21.1
21.2
21.3
22
22.1
22.2
22.3
ix
Virtualization Guide
22.4
22.5
22.6
23
23.1
23.2
23.3
23.4
23.5
24
24.1
Introduction 209
24.2
25
25.1
25.2
25.3
Virtualization Guide
26
27
27.1
27.2
27.3
28
28.1
28.2
29
29.1
29.2
29.3
xi
Virtualization Guide
29.4
29.5
30
30.1
30.2
30.3
30.4
30.5
30.6
30.7
30.8
30.9
30.10
30.11
VI
31
31.1
xii
31.2
31.3
Virtualization Guide
31.4
31.5
32
32.1
32.2
32.3
Glossary 303
A
Appendix 315
B.1
C
C.1
C.2
C.3
C.4
C.5
D
D.1
xiii
Virtualization Guide
introduces the different virtualization solutions by describing their requirements, their installa-
tions and SUSE's support status. The second part deals with managing VM Guests and VM Host
Servers with libvirt . The following parts describe various administration tasks and practices
and the last three parts deal with hypervisor-specific topics.
Many chapters in this manual contain links to additional documentation resources. This includes
additional documentation that is available on the system and documentation available on the
Internet.
For an overview of the documentation available for your product and the latest documentation
updates, refer to http://www.suse.com/doc.
1 Available Documentation
We provide HTML and PDF versions of our books in different languages. The following manuals
for users and administrators are available for this product:
Book Start-Up
This manual will see you through your initial contact with openSUSE Leap. Check out
the various parts of this manual to learn how to install, use and enjoy your system.
Book Reference
Covers system administration tasks like maintaining, monitoring and customizing an initially installed system.
Virtualization Guide
Describes virtualization technology in general, and introduces libvirtthe unified interface to virtualizationand detailed information on specific hypervisors.
Book AutoYaST
AutoYaST is a system for installing one or more openSUSE Leap systems automatically
and without user intervention, using an AutoYaST profile that contains installation and
configuration data. The manual guides you through the basic steps of auto-installation:
preparation, installation, and configuration.
xiv
Introduces basic concepts of system security, covering both local and network security
aspects. Shows how to use the product inherent security software like AppArmor or the
auditing system that reliably collects information about any security-relevant events.
Book System Analysis and Tuning Guide
An administrator's guide for problem detection, resolution and optimization. Find how to
inspect and optimize your system by means of monitoring tools and how to efficiently
manage resources. Also contains an overview of common problems and solutions and of
additional help and documentation resources.
Book GNOME User Guide
Introduces the GNOME desktop of openSUSE Leap. It guides you through using and con-
figuring the desktop and helps you perform key tasks. It is intended mainly for end users
who want to make efficient use of GNOME as their default desktop.
Find HTML versions of most product manuals in your installed system under /usr/share/doc/
manual or in the help centers of your desktop. Find the latest documentation updates at http://
doc.opensuse.org/ where you can download PDF or HTML versions of the manuals for your
product.
2 Feedback
Several feedback channels are available:
Bugs and Enhancement Requests
For services and support options available for your product, refer to http://www.suse.com/
support/.
We want to hear your comments about and suggestions for this manual and the other
documentation included with this product. Use the User Comments feature at the bottom
of each page in the online documentation or go to http://www.suse.com/doc/feedback.html
and enter your comments there.
xv
Feedback
For feedback on the documentation of this product, you can also send a mail to doc-
[email protected] . Make sure to include the document title, the product version and the
3 Documentation Conventions
The following typographical conventions are used in this manual:
/etc/passwd : directory names and file names
placeholder : replace placeholder with the actual value
PATH : the environment variable PATH
ls , --help : commands, options, and parameters
user : users or groups
Alt
Alt
a keyboard
xvi
Documentation Conventions
I Introduction
Virtualization Technology 2
Virtualization Tools 13
1 Virtualization Technology
Virtualization is a technology that provides a way for a machine (Host) to run another operating system (guest virtual machines) on top of the host operating system.
1.1 Overview
SUSE Linux Enterprise includes the latest open source virtualization technologies, Xen and KVM.
With these Hypervisors, SUSE Linux Enterprise can be used to provision, de-provision, install,
monitor and manage multiple virtual machines (VM Guests) on a single physical system (for
more information see Hypervisor.)
Out of the box, SUSE Linux Enterprise can create virtual machines running both modified, highly
tuned, paravirtualized operating systems and fully virtualized unmodified operating systems.
Full virtualization allows the guest OS to run unmodified and requires the presence of x86_64
processors (either Intel* Virtualization Technology (Intel VT) or AMD* Virtualization (AMD-V)).
The primary component of the operating system that enables virtualization is a Hypervisor (or
virtual machine manager), which is a layer of software that runs directly on server hardware.
It controls platform resources, sharing them among multiple VM Guests and their operating
systems by presenting virtualized hardware interfaces to each VM Guest.
SUSE Linux Enterprise is an enterprise-class Linux server operating system that offers two types
of Hypervisors: Xen and KVM. Both Hypervisors support virtualization on 64-bit x86-based
hardware architectures. Both Xen and KVM support full virtualization mode. In addition, Xen
supports paravirtualized mode. SUSE Linux Enterprise with Xen or KVM acts as a virtualization
host server (VHS) that supports VM Guests with its own guest operating systems. The SUSE VM
Guest architecture consists of a Hypervisor and management components that constitute the
VHS, which runs many application-hosting VM Guests.
In Xen, the management components run in a privileged VM Guest often called Dom0. In KVM,
where the Linux kernel acts as the hypervisor, the management components run directly on
the VHS.
Virtualization Technology
Server consolidation: Many servers can be replaced by one big physical server, so hardware
is consolidated, and Guest Operating Systems are converted to virtual machine. It provides
the ability to run legacy software on new hardware.
Isolation: guest operating system can be fully isolated from the Host running it. So if the
virtual machine is corrupted, the Host system is not harmed.
Migration: A process to move a running virtual machine to another physical machine. Live
migration is an extended feature that allows this move without disconnection of the client
or the application.
Disaster recovery: Virtualized guests are less dependent on the hardware, and the Host
server provides snapshot features to be able to restore a known running system without
any corruption.
Dynamic load balancing: A migration feature that brings a simple way to load-balance
your service across your infrastructure.
Less hardware: You can run several operating system on one host, so all hardware maintenance will be 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 will be saved because you do not need more hardware
servers (less servers than service running).
Virtualization Capabilities
snapshots. These features reduce downtime, and bring an easy way to move your service
from one place to another without any service interruption.
Full virtualization mode lets virtual machines run unmodified operating systems, such
as Windows* Server 2003, but requires the computer running as the VM Host Server to
Some guest operating systems hosted in full virtualization mode can be configured to run
the Novell* Virtual Machine Drivers instead of drivers originating from the operating system. Running virtual machine drivers improves performance dramatically on guest operating systems, such as Windows Server 2003. For more information, see AppendixA, Virtual
Machine Drivers.
Paravirtual mode does not require the host computer to support hardware-assisted virtual-
ization technology, but does require the guest operating system to be modified for the virtualization environment. Typically, operating systems running in paravirtual mode enjoy
better performance than those requiring full virtualization mode.
Operating systems currently modified to run in paravirtual mode are called paravirtualized
operating systems and include openSUSE Leap and NetWare 6.5 SP8.
system. Because software I/O virtualization techniques deliver less performance than bare metal, hardware solutions that deliver almost native performance have been developed recently.
openSUSE Leap 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. 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 virtualiza-
tion. However, paravirtualization requires either the guest operating system to be modified
to support the paravirtualization API or paravirtualized drivers. See Section7.1.1, Availabil-
ity of Paravirtualized Drivers for a list of guest operating systems supporting paravirtualiza-
tion.
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 userspace in a secure memory (IOMMU) protected environ-
ment. 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 deviceseach 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 secure boot.
Device is isolated and its memory access protected.
I/O Virtualization
Offers a userspace device driver with more flexible device ownership model.
Is independent of KVM technology, and not bound to x86 architecture only.
SR-IOV
The latest I/O virtualization technique, Single Root I/O Virtualization SR-IOV combines
the benefits of the aforementioned techniquesperformance 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
for setup instructions see Section14.10, Adding a PCI Device to a VM Guest.
KVM PCI Pass-Through (deprecated)
This method of assigning PCI devices to VM Guests is deprecated and has been replaced by
VFIO. KVM PCI Pass-Through is still supported by SUSE, but using VFIO instead is strongly
recommended. Support for KVM PCI Pass-Through will be removed from future versions
of openSUSE Leap.
the Kernel command line. Refer to Book Reference, Chapter 12 The Boot Loader
GRUB 2, Section 12.3.3.2 Kernel Parameters Tab for details.
The VFIO infrastructure needs to be available. This can be achieved by loading the
Kernel module vfio_pci . Refer to Book Reference, Chapter 10 The systemd
Daemon, Section 10.6.4 Loading Kernel Modules for details.
I/O Virtualization
Dom0, any number of other VM Guests, and the tools, commands, and configuration files that let
you manage virtualization. Collectively, the physical computer running all these components is
called a VM Host Server because together these components form a platform for hosting virtual
machines.
The Xen hypervisor, sometimes simply called a virtual machine monitor, is an open source
software program that coordinates the low-level interaction between virtual machines and
physical hardware.
The Dom0
The virtual machine host environment, also called Dom0 or controlling domain, is composed of several components, such as:
The SUSE Linux operating system, which gives the administrator a graphical and
command line environment to manage the virtual machine host components and its
virtual machines.
Note
The term Dom0 refers to a special domain that provides the management
environment. This may be run either in graphical or in command line mode.
The xl toolstack based on the xenlight library (libxl). Use it to manage Xen guest
domains.
QEMUan open source software that emulates a full computer system, including a
processor and various peripherals. It provides the ability to host operating systems
in both full virtualization or paravirtualization mode.
A Xen-based virtual machine, also called a VM Guest or DomU , consists of the following
components:
At least one virtual disk that contains a bootable operating system. The virtual disk
can be based on a file, partition, volume, or other type of block device.
A configuration file for each guest domain. It is a text file following the syntax described in the manual page man 5 xl.conf .
Several network devices, connected to the virtual network provided by the controlling domain.
There is a combination of GUI tools, commands, and configuration files to help you manage
and customize your virtualization environment.
pervisor is shown as running directly on the physical hardware platform. Note that the controlling domain is also a virtual machine, although it has several additional management tasks
compared to all the other virtual machines.
On the left, the virtual machine hosts Dom0 is shown running the SUSE Linux operating system.
The two virtual machines shown in the middle are running paravirtualized operating systems.
The virtual machine on the right shows a fully virtual machine running an unmodified operating
system, such as the latest version of Microsoft Windows/Server.
VM Guests (virtual machines), virtual storage, and virtual networks can be managed with QEMU
tools directly, or with the libvirt -based stack. The QEMU tools include qemu-system-ARCH ,
the QEMU monitor, qemu-img , and qemu-ndb . A libvirt -based stack includes libvirt itself, along with libvirt -based applications such as virsh , virt-manager , virt-install ,
and virt-viewer .
emulation for virtual devices and control mechanisms to manage VM Guests (virtual machines).
The term KVM more properly refers to the Kernel level virtualization functionality, but is in
practice more commonly used to reference the userspace component.
10
11
ers) simultaneously on a single host. This is similar to the chroot environment. Containers are
isolated with kernel Control Groups (cgroups) and kernel Namespaces.
Containers provide virtualization at the operating system level where the kernel controls the
isolated containers. This is unlike full virtualization solutions like Xen or KVM where the processor simulates a complete hardware environment and controls virtual machines.
4.1 Overview
Conceptually, containers can be seen as an improved chroot technique. The difference is that a
chroot environment separates only the file system, whereas containers go further and provide
resource management and control via cgroups.
BENEFITS OF CONTAINERS
Controlling network interfaces and applying resources inside containers through cgroups.
LIMITATIONS OF CONTAINERS
All containers run inside the host system's kernel and not with a different kernel.
Only allows Linux guest operating systems.
Security depends on the host system. Container is not secure. If you need a secure system,
you can confine it using an AppArmor or SELinux profile.
12
5 Virtualization Tools
libvirt is a library that provides a common API for managing popular virtualization solu-
tions, among them KVM, LXC, and Xen. The library provides a normalized management API
for these virtualization solutions, allowing a stable, cross-hypervisor interface for higher-lev-
el management tools. The library also provides APIs for management of virtual networks and
storage on the VM Host Server. The configuration of each VM Guest is stored in an XML file.
With libvirt you can also manage your VM Guests remotely. It supports TLS encryption,
x509 certificates and authentication with SASL. This enables managing VM Host Servers cen-
trally from a single workstation, alleviating the need to access each VM Host Server individually.
Using the libvirt -based tools is the recommended way of managing VM Guests. Interoper-
ability between libvirt and libvirt -based applications has been tested and is an essential
part of SUSE's support stance.
A command line tool to manage VM Guests with similar functionality as the Virtual Ma-
chine Manager. Allows you to change a VM Guest's status (start, stop, pause, etc.), to set
up new guests and devices, or to edit existing configurations. virsh is also useful to script
VM Guest management operations.
virsh takes the first argument as a command and further arguments as options to this
command:
Like zypper , virsh can also be called without a command. In this case it starts a shell
waiting for your commands. This mode is useful when having to run subsequent commands:
13
Virtualization Tools
Type:
virsh # hostname
mercury.example.com
virt-install
A command line tool for creating new VM Guests using the libvirt library. It supports
graphical installations via VNC or SPICE protocols. Given suitable command line arguments,
virt-install can run completely unattended. This allows for easy automation of guest
installs. virt-install is the default installation tool used by the Virtual Machine Manager.
vm-install
A tool to set up a VM Guest, configure its devices and start the operating system installation. Starts a GUI wizard when called from a graphical user interface. When invoked on
a terminal, starts the wizard in command line mode. vm-install can be selected as the
installation tool when creating a new virtual machine in the Virtual Machine Manager.
The Virtual Machine Manager is a desktop tool for managing VM Guests. It provides the
ability to control the life cycle of existing machines (start/shutdown, pause/resume, save/
restore) and create new VM Guests. It allows managing various types of storage and virtual
networks. It provides access to the graphical console of VM Guests with a built-in VNC
viewer and can be used to view performance statistics. virt-manager supports connecting
to a local libvirtd , managing a local VM Host Server, or a remote libvirtd managing
a remote VM Host Server.
14
To start the Virtual Machine Manager, enter virt-manager at the command prompt.
virt-viewer
A viewer for the graphical console of a VM Guest. It uses SPICE (configured by default on
the VM Guest) or VNC protocols and supports TLS and x509 certificates. VM Guests can be
accessed by name, ID, or UUID. If the guest is not already running, the viewer can be told
to wait until the guest starts, before attempting to connect to the console. virt-viewer
is not installed by default and is available after installing the package virt-viewer .
15
yast2 vm
A YaST module that simplifies the installation of virtualization tools and can set up a
network bridge:
16
3. To enable normal networking for the VM Guest, using a network bridge is recommended.
4. After the setup has been finished, you can start setting up VM Guests. Rebooting the VM
3. To enable normal networking for the VM Guest, using a network bridge is recommended.
4. After the setup has been finished, you need to reboot the machine with the Xen kernel.
17
6.4 Patterns
It is possible using Zypper and patterns to install virtualization packages. Run the command
zypper in -t pattern PATTERN . Available patterns are:
KVM
kvm_server : sets up the KVM VM Host Server with QEMU tools for management
kvm_tools : installs the libvirt tools for managing and monitoring VM Guests
Xen
xen_server : sets up the Xen VM Host Server with Xen tools for management
xen_tools : installs the libvirt tools for managing and monitoring VM Guests
Containers
18
Installing Containers
in the following table) and paravirtualized (PV in the following table) with two exceptions:
Windows, which is only supported fully-virtualized, and OES and NetWare operating systems,
which are only supported on Xen paravirtualized. All guest operating systems are supported
both in 32-bit and 64-bit flavors, unless stated otherwise (see NetWare).
TABLE7.1:PARAVIRTUALIZED OS SUPPORT
Operating System
FV Support (Xen/KVM)
PV Support (Xen)
SLES 12 SP1
Full
Full
SLES 12
Full
Full
SLES 11 SP4
Full
Full
SLES 11 SP3
Full
Full
SLES 10 SP4
Full
Full
SLED 12
Technology preview1
Technology preview1
SLED 12 SP1
Technology preview1
Technology preview1
OES 11 SP1
None
Full2, 3
OES 11 SP2
None
Full2, 3
None
RHEL 5.11+
Full/best effort4
Full/best effort4
19
Operating System
FV Support (Xen/KVM)
PV Support (Xen)
RHEL 6.7+
Full/best effort4
Full/best effort4
RHEL 7.2+
Full/best effort4
Full/best effort4
Full
None
Full
None
Full
None
Full
None
Full
None
Windows 7 SP1+
Best effort
None
Windows 8+
Best effort
None
Windows 8.1+
Best effort
None
Windows 10
Best effort
None
SP1+
Technology preview: The operating system has been tested to install and run successfully. Bugs
can be reported and will be tracked by SUSE Technical Services, but no support commitments or
service level agreements apply. Potential fixes and patches will be evaluated for future inclusion.
2
3
4
You need a static IP address for each virtual machine running NetWare or OES.
OES can only be installed from a network installation source.
RedHat* guest operating systems are fully supported with Expanded Support. Otherwise, they
20
Supported VM Guests
7.1.1
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:
SUSE Linux Enterprise Server 12 / 12 SP1
Included in kernel
SUSE Linux Enterprise Server 11 SP1 / SP2 / SP3
Included in kernel
SUSE Linux Enterprise Server 10 SP4
Included in kernel
RedHat
SUSE has developed virtio-based drivers for Windows, which are available in the Virtual Machine Driver Pack (VMDP). For more information, see http://www.suse.com/products/vmdriverpack/.
virtualization hosts (Hypervisor). Both 32-bit and 64-bit versions are supported for the host if
available. The support status is defined as follows:
Full support for all SUSE host systems and openSUSE Leap 42.1 VM Guests
Full support for openSUSE Leap 42.1 VM Guests on third-party host systems
The following SUSE host operating systems are supported:
SUSE Linux Enterprise Server 11 SP4 (KVM/Xen)
SUSE Linux Enterprise Server 12 SP1 (KVM/Xen)
21
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).
22
On the AMD64/Intel 64 architecture, you can test whether your CPU supports hardware virtualization with the following command:
egrep '(vmx|svm)' /proc/cpuinfo
If 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: http://ark.intel.com/Products/VirtualizationTechnology (for Intel CPUs), and http://
products.amd.com/ (for AMD CPUs).
The general minimum hardware requirements for the VM Host Server are the same as for a
physical machine. 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 to have at least one processor core or hyper-thread for each running guest.
Host (Dom0)
Features
Xen
Yes
No
Yes
23
Feature Support
Features
Xen
Yes
Yes
Yes
Intel* VT-d2 (DMA remapping with interrupt filtering and queued invalida-
Yes
AMD* IOMMU (I/O page table with guest-to-host physical address transla-
Yes
7.4.2
Paravirtualized Guest
Features
Xen
Yes
Yes
Yes
24
mode)
Paravirtualized Guest
Features
Xen
VM live migration
Yes
Yes
Memory ballooning
Yes
PCI pass-through
For live migration, both source and target system architectures need to match; that is, the processors (AMD* or Intel*) must be the same. Unless CPU ID masking is used, such as with Intel
FlexMigration, the target should feature the same processor revision or a more recent processor
revision than the source. If VMs are moved among different systems, the same rules apply for
each move. To avoid failing optimized code at runtime or application start-up, source and target
CPUs need to expose the same processor extensions. Xen exposes the physical CPU extensions to
the VMs transparently. To summarize, guests can be 32- or 64-bit, but the VHS must be identical.
7.4.3
Features
Xen
KVM
Yes
Yes
No
No
25
Features
Xen
KVM
Yes
Yes
Yes
Yes
Yes
Yes
VM Live Migration
Yes
size
VM snapshot
Yes
Yes
Yes
Yes
Yes
Yes
PCI pass-through
Yes
Yes
GDBC
restoring dynamic virtual memory are supported in Xen and KVM only if PV drivers are
being used (VMDP).
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/kvm .
26
Guest Installation 29
10
11
12
Managing Storage 84
13
14
APIs. Use the following commands to start and stop libvirtd or check its status:
root # systemctl start libvirtd
To automatically start libvirtd at boot time, either activate it using the YaST Services Manager
module or by entering the following command:
root # systemctl enable libvirtd
28
9 Guest Installation
A VM Guest is comprised 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.
Virtual machines have few if any requirements above those required to run the operating sys-
tem. If the operating system has not been optimized for the virtual machine host environment,
the unmodified OS can run only 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.
not run on other system architectures such as POWER. A 64-bit virtual machine host can,
however, run both 32-bit and 64-bit VM Guests.
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.
source. If you want to set up your VM Guest from an existing image, choose import existing
disk image.
29
Guest Installation
On a VM Host Server running the Xen hypervisor, you can choose whether to install a
paravirtualized or a fully virtualized guest. The respective option is available under Ar-
chitecture Options. Depending on this choice, not all installation options may be available.
3. Depending on your choice in the previous step, you need to provide the following data:
Local Installation Media
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 via
the Browse button (see Chapter12, Managing Storage for more information). Alterna-
tively, choose a physical CD-ROM or DVD inserted in the optical drive of the VM
Host Server.
Network Installation
Provide the URL pointing to the installation source. Valid URL prefixes are, for example, ftp:// , http:// , https:// , and nfs:// . Under URL Options you may
When booting via PXE, you only need to provide the OS Type and the Version.
Import an Existing Image
To set up the VM Guest from an existing image, you need to specify the path on
4. Choose the memory size and number of CPUs for the new virtual machine.
5. This step is omitted if having chosen Import an Existing Image 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 (see Chapter12, Managing Storage for more information). If you choose to create a disk, a qcow2 image will be created under /var/lib/
libvirt/(images .
Setting up a disk is optional. In case you are running a live system directly from CD or DVD,
for example, you can omit this step by deselecting Enable Storage for this Virtual Machine.
30
6. The last screen of the wizard lets you specify the name for the virtual machine. Options
to specify the network device and the MAC address can be found under Advanced Options.
If you need to customize the configuration in detail before the installation, activate the
relevant check box. Exit the wizard with Finish. Depending on your choice, this will either
start the installation or open the VM Guest configuration screen.
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
key sticky, then you can press the remaining keys to pass the combination to the virtual
machine.
Alt
Ctrl
Alt
Ctrl
Ctrl
three times,
F2 .
The sticky key functionality is available in the Virtual Machine Manager during and after
installing a VM Guest.
libvirt library. It is useful if you cannot use the graphical user interface, or need to automatize
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).
31
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 guests configuration file and you can access the guest
with this name from virsh . Alphanumeric and _-.:+ characters are allowed.
--memory required_memory : Specify the amount of memory to allocate for the new
--vcpus number_of_cpus : Specify the number of virtual CPUs. For best perfor-
mance, 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
--virt-type hypervisor : Specify the hypervisor. Supported values are kvm , xen ,
or lxc .
Guest Storage
Specify one of --disk , --filesystem or --nodisks the type of the storage for the new
virtual machine. For example, --disk size=10 creates 10 GB disk in the default image
location for the hypervisor and uses it for the VM Guest. --filesystem /export/path/
on/vmhost specifies the directory on the VM Host Server to be exported to the guest. And
--nodisks sets 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 .
Use the --graphics value option to specify how to access the installation. openSUSE
Leap supports the values vnc or none .
32
not be run, connect to the VM Guest manually with you preferred viewer. To explicitly prevent virt-install from launching the viewer use --noautoconsole . To de-
fine 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.
EXAMPLE9.1:EXAMPLE OF A virt-install COMMAND LINE
The following command line example creates a new SUSE Linux Enterprise Desktop 12
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 will use VNC graphics, and it will auto-launch the graphical client.
KVM
virt-install --connect qemu:///system --virt-type kvm
--name sled12 \
Xen
virt-install --connect xen:// --virt-type xen
--name sled12 \
33
9.3.1
Memory ballooning is a method to change the amount of memory used by VM Guest at runtime.
Both the KVM and Xen hypervisors provide 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) [http://www.suse.com/products/vmdriverpack/] to provide
ballooning. To set the maximum memory greater than the initial memory configured for Windows guests, follow these steps:
1. Install the Windows guest with the maximum memory equal or less than the initial value.
2. Install the Virtual Machine Driver Pack in the Windows guest to provide required drivers.
3. Shut down the Windows guest.
4. Reset the maximum memory of the Windows guest to the required value.
5. Start the Windows guest again.
9.3.2
Some operating systems such as SUSE Linux Enterprise Server offer to include add-on products in
the installation process. In case the add-on product installation source is provided via network,
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 and an image for the add-on product.
In case you are using the GUI-based installation, select Customize Configuration Before Install in
the last step of the wizard and add the add-on product ISO image via Add Hardware Storage.
Specify the path to the image and set the Device Type to CD-ROM.
If 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.
The following example will install SUSE Linux Enterprise Server 12 plus SDK:
virt-install --name sles12+sdk --memory 1024 --disk size=10 \
--disk /virt/iso/SLES12.iso,device=cdrom \
--disk /virt/iso/SLES12_SDK.iso,device=cdrom \
34
35
virt-viewer can be used to manage VM Guests on the host. However, it is also possible
To connect to such a remote host with Virtual Machine Manager, you need to set up a
connection as explained in Section11.2.2, Managing Connections with Virtual Machine Manager. If connecting to a remote host using virsh or virt-viewer , you need to spec-
ify a connection URI with the parameter -c (for example virsh -c qemu+tls://
10.1.1
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 (Running, Paused,
or Shutoff) displayed as icon and literally, and a CPU usage bar.
36
10.1.2
For more information and further options, see virsh help list or man 1 virsh .
10.2.1
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 .
Ctrl
not passed to the VM Guest. To pass such key combinations to a VM Guest, open the Send
Key menu from the VNC window and choose the desired key combination entry. The Send Key
37
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.
are using SASL authentication and/or TLS/SSL connection to access the guest, the options
become limited. Common VNC viewers such as tigervnc support neither SASL authen-
tication nor TSL/SSL. The only supported alternative to Virtual Machine Manager and
virt-viewer is vinagre .
10.2.1.1
10.2.1.2
virt-viewer is a simple VNC viewer with added functionality for displaying VM Guest con-
soles. It can, for example, 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.
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 IDyou can only connect by UUID or name.
Connect to guest with the ID 8
virt-viewer 8
Connect to the inactive guest named sles12 ; the connection window will open once the guest
starts
virt-viewer --wait sles12
38
With the --wait option, the connection will be upheld even if the VM Guest is not running
at the moment. When the guest starts, the viewer will be launched.
second time for authenticating with the VNC server. The second password needs to be
provided on the command line where virt-viewer was started.
10.2.2
As an alternative to the graphical console, which requires a graphical environment on the client
accessing the VM Guest, 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
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.
Launch the YaST Boot Loader module and switch to the Kernel Parameters tab. Add
console=ttyS0 to the field Optional Kernel Command Line Parameter.
39
SLES 11
Launch the YaST Boot Loader module and select the boot entry for which to activate
serial console access. Choose Edit and add console=ttyS0 to the field Optional
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.
Depending on the guest operating system, the avilability ACPI may not be sufficient to
perform a graceful shutdown. It is strongly recommended to test shutting down and rebooting a guest before releasing it to production. openSUSE or SUSE Linux Enterprise
Desktop, for example, may require PolKit authorization for shutdown and reboot. Make
sure this policy is turned off on all VM Guests.
40
If ACPI was enabled during a Windows XP/Server 2003 guest installation, turning it on
in the VM Guest configuration alone is not sufficient. See the following articles for more
information:
http://support.microsoft.com/kb/314088/EN-US/
http://support.microsoft.com/?kbid=309283
A graceful shutdown is of course always possible from within the guest operating system,
regardless of the VM Guest's configuration.
1. Open a VNC Window as described in Section10.2.1.1, Opening a Graphical Console with Virtual
Machine Manager.
2. Choose Run, Pause, or one of the Shut Down options either from the toolbar or from the
10.3.1.1
Autostarting a VM Guest
Automatically starting a guest when the VM Host Server boots is not enabled by default. This
feature needs to be turned on for each VM Guest individually. There is no way to activate it
globally.
1. Double-click the VM Guest entry in Virtual Machine Manager to open its console.
41
10.3.2
Pause
virsh suspend sles12
Reboot
virsh reboot sles12
Graceful shutdown
virsh shutdown sles12
Force shutdown
virsh destroy sles12
Turn on autostart
virsh autostart sles12
42
When saved, the VM Guest is paused, its current memory state is saved to disk, and then the
guest is stopped. The operation does not make a copy of any portion of the VM Guests virtual
disk. The amount of time taken to save the virtual machine depends on the amount of memory
allocated. When saved, a VM Guests memory is returned to the pool of memory available on
the VM Host Server.
The restore operation loads a VM Guests previously saved memory state file and starts it. The
guest is not booted but rather resumes at the point where it was previously saved. The operation
is slightly similar to coming out of hibernation.
The VM Guest is saved to a state file. Make sure there is enough space on the partition you are
going to save to. Issue the following command on the guest to get a rough estimation of the
file size in megabytes to be expected:
cause the machine's virtual disk and the saved memory state to get out of synchronization.
This can result in critical errors when restoring the guest.
To be able to work with a saved VM Guest again, always use the restore operation.
10.4.1
PROCEDURE10.3:SAVING A VM GUEST
1. Open a VNC connection window to a VM Guest. Make sure the guest is running.
2. Choose Virtual Machine Shutdown Save
43
PROCEDURE10.4:RESTORING A VM GUEST
Alt
3. Choose the file you want to restore and proceed with Open. Once the file has been suc-
10.4.2
Save a running VM Guest with the command virsh save and specify the file which it is saved
to.
RAM, and the content of all writable disks. To use virtual machine snapshots, you must have at
least one non-removable and writable block device using the qcow2 disk image format.
44
Note
Snapshots are supported on KVM VM Host Servers only.
Snapshots let you restore the state of the machine at a particular point in time. This is for
example useful to undo a faulty configuration or the installation of a lot of packages. It is also
helpful for testing purposes, as it allows you to go back to a defined state at any time.
Snapshots can be taken either from running guests or from a guest currently not running. Taking
a screenshot from a guest that is shut down ensures data integrity. In case you want to create
a snapshot from a running system, be aware that the snapshot only captures the state of the
disk(s), not the state of the memory. Therefore you need to ensure that:
All running programs have written their data to the disk. If you are unsure, terminate the
application and/or stop the respective service.
Buffers have been written to disk. This can be achieved by running the command sync
on the VM Guest.
Starting a snapshot reverts the machine back to the state it was in when the snapshot was taken.
Any changes written to the disk after that point in time will be lost when starting the snapshot.
Starting a snapshot will restore the machine to the state (shut off or running) it was in when
the snapshot was taken. After starting a snapshot that was created while the VM Guest was shut
off, you will need to boot it.
45
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 Description can be
changed or added directly in this view; the other snapshot data cannot be changed.
10.5.1.1
Creating a Snapshot
running.
2. Click the plus symbol in the bottom left corner of the VNC window to open the Create
Snapshot window.
3. Provide a Name 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.
46
10.5.1.2
Deleting a Snapshot
10.5.1.3
Starting a Snapshot
10.5.2
To list all existing snapshots for a domain ( admin_server in the following), run the snapshot-list command:
Creation Time
State
Beta2 prepared
Beta2 running
47
Beta3 running
Cloud2 GM running
CLOUD3 RC prepared
OS + SMT + eth[01]
The snapshot that was last started is shown with the snapshot-current command:
tux > virsh snapshot-current --name admin_server
Basic installation incl. SMT for CLOUD4
Details about a particular snapshot can be obtained by running the snapshot-info command:
tux > virsh snapshot-info sles "Basic installation incl. SMT for CLOUD4"
Name:
Domain:
admin_server
Current:
yes
State:
shutoff
Location:
internal
Parent:
Children:
Descendants:
Metadata:
yes
10.5.2.1
Creating a Snapshot
To take a new snapshot of a VM Guest currently not running, use the snapshot-create-as
command as follows:
48
Name of the snapshot. It is recommended to use a speaking name, since that makes it
easier to identify the snapshot. Mandatory.
Description for the snapshot. Optional.
To take a snapshot of a running VM Guest, you need to specify the --live parameter:
virsh snapshot-create-as --domain admin_server --name "Snapshot 2" \
--description "First live snapshot" --live
Refer to the SNAPSHOT COMMANDS section in man 1 virsh for more details.
10.5.2.2
Deleting a Snapshot
10.5.2.3
Starting a Snapshot
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:
49
Deleting a VM Guest
To delete a VM Guest, it needs to be shut down first (refer to Section10.3, Changing a VM Guest's
State: Start, Stop, Pause for instructions). It is not possible to delete a running guest.
10.6.1
You may also choose to permanently delete the guest's virtual disk by activating Delete
Associated Storage Files. The deletion is not recoverable either.
10.6.2
There is no option to automatically delete the attached storage files. If they are managed by
libvirt, delete them as described in Section12.2.4, Deleting Volumes from a Storage Pool.
50
10.7.1
Migration Requirements
It is recommended that the source and destination systems have the same architecture,
however it is possible to migrate between hosts with AMD* and Intel* architectures.
Storage devices must be accessible from both machines (for example, via NFS or iSCSI) and
must be configured as a storage pool on both machines (see Chapter12, Managing Storage
for more information). This is also true for CD-ROM or floppy images that are connected
during the move (however, you may disconnect them prior to the move as described in
Section14.8, Ejecting and Changing Floppy or CD/DVD-ROM Media with Virtual Machine Manager).
libvirtd needs to run on both VM Host Servers and you must be able to open a remote
libvirt connection between the target and the source host (or vice versa). Refer to Sec-
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, libvirt chooses 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.
Host and target machine should be in the same subnet on the network, otherwise networking will not work after the migration.
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 will be overwritten.
All CPU models except host cpu model are supported when migrating VM Guests.
SATA disk device type is not migratable.
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. In case live migration
51
Migration Requirements
Cache mode setting is an important setting for migration. See: Section15.5, Effect of Cache
Modes on Live Migration.
Live migration of VM Guests from a host running one operating system to a host running
a different operating system is fully supported for the following scenarios:
SLES 12 to SLES 12 SP1
SLES 12 SP1 to SLES 12 SP2 (when released)
SLES 11 SP3 to SLES 12 SP1
SLES 11 SP4 to SLES 12 SP1
10.7.2
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.
1. 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.
2. Right-click the VM Guest that is to be migrated and choose Migrate. Make sure the guest
is running or pausedit is not possible to migrate guests that are shut down.
3. Choose a New Host for the VM Guest. If the desired target host does not show up, make
By default, a live migration is performed. If you prefer an offline migration where the
VM Guest is paused during the migration, tick Migrate offline.
4. Click Migrate to start a migration with the default port and bandwidth. To change these
defaults, make the advanced options available by clicking the triangle at Advanced Options.
Here you can enter the target host's Address (IP address or host name), a Port and the
Bandwidth in megabits per second (Mbps). If you specify a Port, you must also specify an
Address; the Bandwidth is optional.
52
5. When the migration is complete, the Migrate window closes and the VM Guest is now
listed on the new host in the Virtual Machine Manager window. The original VM Guest
will still be available on the target host (in shut down state).
10.7.3
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:
The most important options are listed below. See virsh help migrate for a full list.
--live
Does a live migration. If not specified, an offline migrationwhere the VM Guest is paused
during the migrationwill be performed.
--suspend
Does an offline migration and does not restart the VM Guest on the target host.
--persistent
matically deleted on the target host if it is shut down. Use this switch to make the migration persistent.
--undefinesource
When specified, the VM Guest definition on the source host will be deleted after a successful migration (however, virtual disks attached to this guest will not be deleted).
The
following
examples
use
mercury.example.com
as
the
source
system
and
53
target host. A shut down version of the original guest description remains on the source
host. A transient copy will be 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 will result in the loss of both VM Guest definitions when the guest is shut down
on the target host.
10.7.4
54
Step-by-Step Example
Step-by-Step Example
10.7.4.1
First you need to export the storage, to share the Guest image between host. 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 will use 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)
10.7.4.2
10.0.1.0/24
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 will be VM. To define this pool, create a VM.xml
<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>
55
Step-by-Step Example
</target>
</pool>
Then the pool can be set to start automatically at host boot (autostart option):
virsh # pool-autostart VM
Pool VM marked as autostarted
State
Autostart
------------------------------------------default
active
yes
VM
active
yes
virsh # pool-info VM
Name:
VM
UUID:
42efe1b3-7eaa-4e24-a06a-ba7c9ee29741
State:
running
Persistent:
yes
Autostart:
yes
Capacity:
2,68 TiB
56
Step-by-Step Example
Allocation:
2,38 TiB
Available:
306,05 GiB
10.7.4.3
The pool has been definednow we need a volume which will contain the disk image:
virsh # vol-create-as VM sled12.qcow12 8G --format qcow2
Vol sled12.qcow12 created
The volume names shown will be used later to install the guest with virt-install.
10.7.4.4
Let's create a SUSE Linux Enterprise Desktop VM Guest with the virt-install command. The
VM pool will be specified with the --disk option, cache=none is recommended if you do not
want to use the --unsafe option while doing the migration.
10.7.4.5
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 destination.
57
Step-by-Step Example
10.8 Monitoring
10.8.1
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 Preferences:
1. Run virt-manager .
2. Select Edit Preferences.
3. Change the tab from General to Polling.
4. Activate the check boxes for Disk I/O and Network I/O.
5. If desired, also change the update interval or the number of samples that are kept in the
history.
Afterwards, 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
Section10.2.1, Opening a Graphical Console. Choose Details from the toolbar or the View menu.
The statistics are displayed from the Performance entry of the left-hand tree menu.
58
Monitoring
10.8.2
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
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%
TIME
NAME
7 R
123
18K
196
5.8
6.0
0:24.35 sled12_sp1
6 R
18K
0.2
6.0
0:42.51 sles12_sp1
5 R
18K
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
Shift
Shift
Shift
P : CPU usage
Shift
R .
Shift
virt-top also supports different views on the VM Guests data, which can be changed on-the-
59
: default view
virt-top supports more hot keys to change the view on the data and also many command line
switches that affect the behavior of the program. Refer to man 1 virt-top for details.
10.8.3
kvm_stat -1
# 1 second snapshot
efer_reload
11378946
218130
fpu_reload
62144
152
halt_exits
414866
100
halt_wakeup
260358
50
host_state_reload
539650
249
6227331
173067
invlpg
227281
47
io_exits
113148
18
irq_exits
168474
127
irq_injections
482804
123
exits
hypercalls
insn_emulation
insn_emulation_fail
60
irq_window
51270
18
largepages
mmio_exits
6925
mmu_cache_miss
71820
19
mmu_flooded
35420
mmu_pde_zapped
64763
20
213782
29
128690
17
46
-1
nmi_injections
nmi_window
pf_fixed
1553821
857
pf_guest
1018832
562
174007
37
request_irq
signal_exits
394182
148
mmu_pte_updated
mmu_pte_write
mmu_recycled
mmu_shadow_zapped
mmu_unsync
remote_tlb_flush
tlb_flush
61
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).
11.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 libvirtd connections only.
Access control for Unix sockets with PolKit. This method is available for local libvirtd
connections only.
User name and password authentication with SASL (Simple Authentication and Security
Layer). This method is available for both, libvirtd and 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 libvirtd connections only, is not
covered in this manual. Refer to http://libvirt.org/auth.html#ACL_server_kerberos for details.
Single password authentication. This method is available for VNC connections only.
its graphical console on the other hand, always needs to be configured separately. When
restricting access to the management tools, these restrictions do not automatically apply
to VNC connections!
62
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 Section11.3.2.5, Restricting Access (Security Considerations) for details.
11.1.1
libvirtd Authentication
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 ).
In the following instructions, you will learn 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.
Local Connections
Section11.1.1.2, Local Access Control for Unix Sockets with PolKit
Section11.1.1.1, Access Control for Unix Sockets with Permissions and Group Ownership
Remote Tunnel over SSH
Section11.1.1.1, Access Control for Unix Sockets with Permissions and Group Ownership
Remote TLS/SSL Connection
Section11.1.1.3, User name and Password Authentication with SASL
63
libvirtd Authentication
none (access controlled on the client side by restricting access to the certificates)
11.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.
1. In case it does not exist, create the group that should own the socket:
groupadd libvirt
unix_sock_rw_perms = "0770"
auth_unix_rw = "none"
4. Restart libvirtd :
systemctl start libvirtd
64
libvirtd Authentication
11.1.1.2
Access control for Unix sockets with PolKit is the default authentication method on openSUSE
Leap 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.
To grant users access to a socket without having to provide the root password, you need to
libvirt with the following content to grant access to the read-write socket to all members of
polkit.addRule(function(action, subject) {
if (action.id == "org.libvirt.unix.manage" && subject.isInGroup("libvirt")) {
return polkit.Result.YES;
}
});
11.1.1.3
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.
65
libvirtd Authentication
restricting access to the certificate's key file. However, this might prove error-prone when
dealing with a large number of clients. Using SASL with TLS adds security by additionally
controlling access on the server side.
2. Restart libvirtd :
systemctl restart libvirtd
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 the mech_list parameter. Only do this for
TSL/SASL, for TCP connections this parameter must be set to digest-md5.
#mech_list: digest-md5
66
libvirtd Authentication
4. By default, no SASL users are configured, so no logins are possible. Use the following
11.1.2
VNC Authentication
Since access to the graphical console of a VM Guest is not controlled by libvirt , but rather
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 wellit is possible to share the same database.
67
VNC Authentication
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 Section11.3.2.4.2, VNC over TLS/SSL: Client Configuration for details.
11.1.2.1
SASL provides user name and password authentication and data encryption. Since SASL main-
tains 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 Sec-
tion11.3.2.4.2, VNC over TLS/SSL: Client Configuration for details on configuring these connections.
you have already configured SASL for libvirt and are planning to use the same settings
including the same user name and password database, a simple link is suitable:
ln -s /etc/sasl2/libvirt.conf /etc/sasl2/qemu.conf
In case you 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 and edit it according
to your needs:
cp /etc/sasl2/libvirt.conf /etc/sasl2/qemu.conf
The first parameter enables VNC to listen on all public interfaces (rather than to the local
host only), and the second parameter enables SASL authentication.
68
VNC Authentication
3. By default, no SASL users are configured, so no logins are possible. Use the following
4. Restart libvirtd :
systemctl restart libvirtd
5. Restart all VM Guests that have been running prior to changing the configuration. VM
Guests that have not been restarted will not use SASL authentication for VNC connects.
11.1.2.2
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 to edit the VM Guest's configuration files.
69
VNC Authentication
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.
2. Restart libvirtd :
root # systemctl restart libvirtd
3. Restart all VM Guests that have been running prior to changing the configuration. VM
Guests that have not been restarted will not use password authentication for VNC connects.
2. 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, vi is used.
virsh edit VM NAME
70
VNC Authentication
3. Search for the element <graphics> with the attribute type='vnc' , for example:
<graphics type='vnc' port='-1' autoport='yes'/>
4. Add the passwd=PASSWORD attribute, save the file and exit the editor. The maximum
5. Restart libvirtd :
root # systemctl restart libvirtd
6. Restart all VM Guests that have been running prior to changing the configuration. VM
Guests that have not been restarted will not use password authentication for VNC connects.
encryption key. Therefore, it is recommended to use VNC with TLS/SSL or tunneled over
SSH. virt-viewer , Virtual Machine Manager and vinagre from version 2.30 onwards
supports both methods.
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 Section11.2.2, Managing Connections
with Virtual Machine Manager for details.
HYPERVISOR
1
+PROTOCOL
://USER@REMOTE
/CONNECTION_TYPE
Specify the hypervisor. openSUSE Leap currently supports the following hypervisors: test
(dummy for testing), qemu (KVM), and xen (Xen). This parameter is mandatory.
71
When connecting to a remote host, specify the protocol here. It can be one of: ssh (connection via SSH tunnel), tcp (TCP connection with SASL/Kerberos authentication), tls
(TLS/SSL encrypted connection with authentication via x509 certificates).
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 ( $USER ) is used.
See below for more information. For TLS connections, the host name has to be specified
exactly as in the x509 certificate.
4
When connecting to the QEMU/KVM hypervisor, two connection types are accepted: sys-
tem for full access rights, or session for restricted access. Since session access is not
test:///default
qemu:///system or xen:///system
Connect to the QEMU/Xen hypervisor on the local host having full access (type system).
qemu+ssh://[email protected]/system
or
xen+ssh://
[email protected]/system
Connect to the QEMU/Xen hypervisor on the remote host mercury.example.com. The connection is established via an SSH tunnel.
qemu+tls://saturn.example.com/system or xen+tls://saturn.example.com/system
Connect to the QEMU/Xen 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 http://libvirt.org/uri.html.
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
72
11.2.1
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 privi-
leges 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:
PROCEDURE11.3:GRANTING SYSTEM ACCESS TO A REGULAR USER
1. Enable access via Unix sockets as described in Section11.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 libvirt and tux is made a member of this group. This ensures
that tux can connect using virsh or Virtual Machine Manager.
This ensures that the VM Guests are started by tux and that resources bound to the guest
(for example virtual disks) can be accessed and modified by tux .
3. Make tux a member of the group kvm :
usermod -A kvm tux
This step is needed to grant access to /dev/kvm , which is required to start VM Guests.
4. Restart libvirtd :
root # systemctl restart libvirtd
73
11.2.2
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 Connect from the context menu. You can also Delete an existing
connection from this menu.
Manager was started on, or one of the remote connections (see Section11.3, Configuring
Remote Connections for more information).
USERNAME@REMOTE_HOST . User names must be specified for local connections and for SSH.
be evaluated anyway. A user name must be specified for local connections and for
SSH connectionsif not, the default user root will be used.
5. If you do not want the connection to be automatically activated when starting the Virtual
74
a central location. This section gives detailed instructions on how to configure server and client
to allow remote connections.
11.3.1
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 Section11.1.1.1, Access Control for Unix Sockets with Permissions and
Group Ownership. Connecting as user tux ( qemu+ssh://tuxsIVname;/system or xen+ssh://
tuxsIVname;/system ) works out of the box and does not require additional configuration on
SSH: Secure Network Operations, Section 14.5.2 Copying an SSH Key. Using an ssh-agent on
the machine from which you are connecting adds even more conveniencesee Book Security
Guide, Chapter 14 SSH: Secure Network Operations, Section 14.5.3 Using the ssh-agent for
instructions.
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.
75
11.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.
Restricting Access (Security Considerations) for details. libvirt also supports user authen-
tication on the server with SASL. Read more in Section11.3.2.6, Central User Authentication
with SASL for TLS Sockets.
11.3.2.2
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. Once the certificates are in place,
TLS support can be turned on for libvirt .
1. Create the server certificate and export it together with the CA certificate as described in
SectionB.1, Generating x509 Client/Server Certificates.
openSUSE
Leap 42.1
4. By default, libvirt uses the TCP port 16514 for accepting secure TLS connections. Open
11.3.2.3
The client is the machine initiating connections. Therefore the client certificates need to be
installed. The CA certificate needs to be installed, too.
1. Create the client certificate and export it together with the CA certificate as described in
SectionB.1, Generating x509 Client/Server Certificates.
openSUSE
Leap 42.1
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
#Xen
virsh -c xen+tls://mercury.example.com/system list --all
If your setup is correct, you will see a list of all VM Guests registered with libvirt on
the VM Host Server.
11.3.2.4
Currently, VNC communication over TLS is only supported by a few tools. The widespread
tightvnc or tigervnc viewer, for example, do not support TLS. Known to work are the Virtual
Machine Manager ( virt-manager ), virt-viewer and the GNOME VNC viewer vinagre .
11.3.2.4.1
To access the graphical console via VNC over TLS/SSL, you need to configure the VM Host
Server as follows:
openSUSE
Leap 42.1
2. Create a directory /etc/pki/libvirt-vnc and link the certificates into this directory
as follows:
to restart all machines that have been running prior to making the configuration
change.
11.3.2.4.2
The only action needed on the client side is to place the x509 client certificates in a location
recognized by the client of choice. Unfortunately, each supported clientVirtual Machine Manager, virt-viewer , and vinagre expects the certificates in a different location. However,
Virtual Machine Manager and vinagre can either read from a system-wide location applying
to all users, or from a per-user location.
openSUSE
Leap 42.1
To connect to the remote host, Virtual Machine Manager requires the setup explained in
Section11.3.2.3, Configuring the Client and Testing the Setup. To be able to connect via VNC
Per-user location
/etc/pki/CA/cacert.pem
~/.pki/libvirt-vnc/clientcert.pem
~/.pki/libvirt-vnc/private/clientkey.pem
virt-viewer
11.3.2.5
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 probably 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.
openSUSE
Leap 42.1
Server Certificates
Server certificates need to be readable for QEMU processes. On openSUSE Leap QEMU
processes started from libvirt tools are owned by root , so it is sufficient if the root
can read the certificates:
If 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 libvirt is created, and group ownership of the clientkey.pem file and its parent
directory is set to libvirt . Afterwards, the access permissions are restricted to owner and
group. Finally the user tux is added to the group libvirt , 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 -A 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 do 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.
openSUSE
Leap 42.1
11.3.2.5.1
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 Section11.1.1.3, User name and Password Authentication
with SASL.
It is also possible to restrict access with a whitelist of DNs (distinguished names), so only clients
with a certificate matching a DN from the list can connect.
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=*"]
11.3.2.6
A direct user authentication via TLS is not possiblethis is handled indirectly on each client via
the read permissions for the certificates as explained in Section11.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 Section11.1.1.3, User name and Password Authentication with SASL for configuration details.
11.3.2.7
Troubleshooting
openSUSE
Leap 42.1
11.3.2.7.1
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?
11.3.2.7.2
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
openSUSE
Leap 42.1
12 Managing Storage
When managing a VM Guest on the VM Host Server itself, it is possible to 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.
Storage Volume
A storage volume is a storage device that can be assigned to a guesta virtual disk or
a CD/DVD/floppy image. Physically (on the VM Host Server) it can be a block device (a
partition, a logical volume, etc.) or a file.
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:
A directory for hosting image files. The files can be either one of the supported disk
formats (raw, qcow2, or qed), or ISO images.
Physical Disk Device (disk)
Use a complete physical disk as storage. A partition is created for each volume that
is added to the pool.
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 libvirt takes care of mounting the device.
84
Managing Storage
Set up a pool on an iSCSI target. You need to have been logged into the volume once
before, to use it with libvirt (use the YaST iSCSI Initiator to detect and log in to
a volume). 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, use fdisk
to add it:
Use an LVM volume group as a pool. You may 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.
85
Managing Storage
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 libvirt takes care of mounting the directory. Supported protocols
are NFS and glusterfs.
SCSI Host Adapter (scsi)
Use an SCSI host adapter in almost the same way as an iSCSI target. It is recommended
to use a device name from /dev/disk/by-* rather than the simple /dev/sdX , since
the latter may 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.
groups, iSCSI targets, etc. that are used to build storage pools on the VM Host Server, as
well. 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 already
existing on the VM Host Server.
86
12.1.1
87
3. Specify the required details in the following window. The data that needs to be entered
Target Path: The directory that hosts the devices. The default value /dev should
usually fit.
Format: Format of the device's partition table. Using auto should usually work.
If not, get the required format by running the command parted -l on the
VM Host Server.
Source Path: 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 may 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).
Build Pool: Activating this option formats the device. Use with careall data
on the device will be lost!
Type fs:
Get the necessary data by running the following command on the VM Host Server:
iscsiadm --mode node
88
It will return a list of iSCSI volumes with the following format. The elements highlighted with a bold font are the ones needed:
IP_ADDRESS:PORT,TPGT TARGET_NAME_(IQN)
Target Path: The directory containing the device file. Use /dev/disk/by-path
(default) or /dev/disk/by-id .
Target Path: In case you use an existing volume group, specify the existing
device path. In case of building a new LVM volume group, specify a device
name in the /dev directory that does not already exist.
Source Path: Leave empty when using an existing volume group. When creating
a new one, specify its devices here.
path devices available. Therefore you may enter an arbitrary string here (required, otherwise the XML parser will fail); it will be ignored anyway.
Type netfs:
89
Type scsi:
Target Path: The directory containing the device file. Use /dev/disk/by-path
(default) or /dev/disk/by-id .
12.1.2
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.
12.1.2.1
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, you may Stop it by clicking the stop symbol in the bottom left corner of the Storage
Manager. Stopped pools are marked with State: Inactive and are grayed out in the list pane. By
default, a newly created pool will be automatically started On Boot of the VM Host Server.
To Start an inactive pool and make it available from remote again click the play symbol in the
bottom left corner of the Storage Manager.
90
To permanently make a pool inaccessible, you can Delete it by clicking the shredder symbol in the
bottom left corner of the Storage Manager. You may only delete inactive pools. Deleting a pool
does not physically erase its contents on VM Host Serverit only deletes the pool configuration.
However, you need to be extra careful when deleting pools, especially when deleting LVM
volume group-based tools:
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
will become inaccessible from the VM Guest if the pool is deleted. Although the volumes
themselves will not be deleted, the VM Host Server will no longer have access to the
resources.
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 will be erased
and the LVM group will no longer exist on the host system. The configuration is not
recoverable and all volumes from this pool are lost.
12.1.2.2
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 .
1. A new volume can either be created using the Storage Manager or while adding a new
storage device to a VM Guest. In both cases, select a Storage Pool and then click New
Volume.
2. Specify a Name for the image and choose an image format (note that SUSE currently only
supports raw , qcow2 , or qed images). The latter option is not available on LVM groupbased pools.
Specify a Max Capacity and the amount of space that should initially be allocated. If both
values differ, a sparse image file, growing on demand, will be created.
91
12.1.2.3
Deleting a volume can only be done from the Storage Manager, by selecting a volume and
clicking Delete Volume. Confirm with Yes. Use this function with extreme care!
Whether a volume is used by a VM Guest is indicated in the Used By column in the Storage
Manager.
storage pools is currently not supported by SUSE. Therefore this section is restricted to document
functions like 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.
12.2.1
List all pools currently active by executing the following command. To also list inactive pools,
add the option --all :
Details about a specific pool can be obtained with the pool-info subcommand:
virsh pool-info POOL
Volumes can only be listed per pool by default. To list all volumes from a pool, enter the following command.
92
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.
1. Create an XSLT style sheet by saving the following content to a file, for example, ~/
libvirt/guest_storage_list.xsl:
</xsl:text>
<xsl:value-of select="(source/@file|source/@dev|source/@dir)[1]"/>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
2. Run the following commands in a shell. It is assumed that the guest's XML definitions are
SSHEET="$HOME/libvirt/guest_storage_list.xsl"
cd /etc/libvirt/qemu
for FILE in *.xml; do
basename $FILE .xml
xsltproc $SSHEET $FILE
done
93
12.2.2
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 POOL
Only pools that are marked to autostart will automatically be started if the VM Host Server
reboots.
94
12.2.3
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 .
NAME
12G --format
raw|qcow2|qed
--allocation 4G
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 raw , qcow2 , and qed .
Optional parameter. By default virsh creates a sparse image file that grows on demand.
Specify the amount of space that should be allocated with this parameter (4 gigabytes in
this example). Use the suffixes k, M, G, T for kilobyte, megabyte, gigabyte, and terabyte,
respectively.
When not specifying this parameter, a sparse image file with no allocation will be gener-
ated. If you want to create a non-sparse volume, specify the whole image size with this
parameter (would be 12G in this example).
12.2.3.1
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.
NAME_NEW_VOLUME
--pool POOL
Optional parameter. libvirt tries to locate the existing volume automatically. If that
fails, specify this parameter.
95
12.2.4
--pool is optional. libvirt tries to locate the volume automatically. If that fails, specify this
parameter.
Whether a volume is used by a VM Guest can only be detected by using by the method
described in Procedure12.1, Listing all Storage Volumes Currently Used on a VM Host Server.
disk to two different virtual machines. This will reduce 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 will endure a crash or a restart of libvirtd . Locks will even
persist in the case of 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.
96
12.3.1
Enable Locking
Locking virtual disks is not enabled by default on openSUSE Leap. To enable and automatically
start it upon rebooting, perform the following steps:
1. Edit /etc/libvirt/qemu.conf and set
lock_manager = "lockd"
12.3.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) will
97
Enable Locking
mu-lockd.conf . It also contains detailed comments with further information. Make sure to ac-
12.3.2.1
virtlockd 's default configuration uses a direct lockspace, where the locks are acquired
against the actual file paths associated with the <disk> devices. If the disk file paths are not
accessible to all hosts, virtlockd can be configured to allow an indirect lockspace, where a
hash of the disk file path is used to create a file in the indirect lockspace directory. The locks
are then held on these hash files instead of the actual disk file paths. Indirect lockspace is also
useful if the file system containing the disk files does not support fcntl() locks. An indirect
lockspace is specified with the file_lockspace_dir setting:
file_lockspace_dir = "/MY_LOCKSPACE_DIRECTORY"
12.3.2.2
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"
98
Configure Locking
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 (see the virt-
resize command from the Section17.3, Guestfs Tools package) as the service provided by the
guest is not interrupted by the resizing process. To resize a VM Guest disk, follow these steps:
PROCEDURE12.2:ONLINE RESIZING OF GUEST DISK
1. Inside the guest system, check the current size of the disk (for example /dev/vda ).
root # 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 bytes
2. On the host, resize the logical volume holding the /dev/vda disk of the guest to the
3. On the host, resize the block device related to the disk /dev/mapper/vg00-home of the
guest. Note that you can find the domain_id with virsh list .
root # virsh blockresize
99
the menu, or click the bulb icon in the toolbar. Choose Add Hardware Filesystem to open
the Filesystem Passthrough dialog.
2. Driver allows you to choose between a Handle or Path base driver. The default setting is
Path. Mode lets you choose the security model, which influences the way file permissions
are set on the host. Three options are available:
Passthrough (Default)
Files on the file system are directly created with the client-user's credentials. This is
very similar to what NFSv3 is using.
Squash
Same as Passthrough, but failure of privileged operations like chown are ignored.
This is required when KVM is not run with root privileges.
Mapped
Files are created with the file server's credentials ( qemu.qemu ). The user credentials
and the client-user's credentials are saved in extended attributes. This model is recommended when host and guest domains should be kept completely isolated.
openSUSE
Leap 42.1
3. Specify the path to the directory on the VM Host Server with Source Path. Enter a string at
Target Path that will be used as a tag to mount the shared directory. Note that the string
of this field is a tag only, not a path on the VM Guest.
4. Apply the setting. If the VM Guest is currently running, you need to shut it down to apply
5. Boot the VM Guest. To mount the shared directory, enter the following command:
sudo mount -t 9p -o trans=virtio,version=9p2000.L,rw TAG /MOUNT_POINT
To make the shared directory permanently available, add the following line to the /etc/
fstab file:
TAG
/MOUNT_POINT
9p
trans=virtio,version=9p2000.L,rw
openSUSE
Leap 42.1
13 Managing Networks
This chapter introduces common networking configurations supported by libvirt . It does
not depend on the hypervisor used, which means that it is valid for all hypervisors supported
by libvirt , such as KVM or Xen. These setups can be achieved using both the graphical interface of Virtual Machine Manager and the command line tool virsh .
There are two common network setups to provide a VM Guest with a network connection
either create a virtual network for the guest, or create a network bridge over a host's physical
network interface and have the guest use it.
Virtual networks are based on virtual devices that connects virtual machines inside a hypervisor.
They allow outgoing traffic translated to the LAN and are provided with DHCP and DNS services.
Virtual networks can be either isolated, or forwarded to a physical network.
Guests inside an isolated virtual network can communicate with each other, but cannot commu-
nicate with guests outside the virtual network. Also, guests not belonging to the isolated virtual
network cannot communicated with guests inside.
On the other hand, guests inside a forwarded (NAT, network address translation) virtual network
can make any outgoing network connection they request. Incoming connections are allowed
from VM Host Server, and from other guests connected to the same virtual network. All other
incoming connections are blocked by iptables rules.
A standard libvirt installation on openSUSE Leap already comes with a predefined virtual network providing DHCP server and network address translation (NAT) named "default".
13.1.1
ager
You can define, configure, and operate both isolated and forwarded virtual networks with Virtual Machine Manager.
102
Managing Networks
13.1.1.1
1. Start Virtual Machine Manager. In the list of available connections, left-click the name
of the connection for which you need to configure the virtual network, and then select
Details.
2. In the Connection Details window, click the Virtual Networks tab. You can see the list of
all virtual networks available for the current connection. On the right, there are details
of the highlighted virtual network.
FIGURE13.1:CONNECTION DETAILS
3. Click
4. Type a name for the new virtual network and click Forward.
5. If you want to specify an IPv4 network address space definition, activate the relevant
103
6. libvirt can provide your virtual network with a DHCP server. If you need it, activate
Enable DHCPv4, then type the start and end IP address range of assignable addresses.
7. To enable static routing for the new virtual network, activate the relevant option and type
activatei Enable IPv6 network address space definition and activate/fill the relevant options.
104
For forwarded networks, specify the network interface to which the requests will be
forwarded, and one of the forwarding modes: while NAT (network address translation)
remaps the virtual network address space and allows sharing a single IP address, Routed
connects the virtual switch to the physical host LAN with no network translation.
12. If you did not specify IPv6 network address space definition earlier, you can enable IPv6
bridge virbrX is available, which corresponds to the newly create virtual network. You
can check with brctl show . libvirt automatically adds iptables rules to allow traffic
to/from guests attached to the new virbrX device.
13.1.1.2
of the connection for which you need to configure the virtual network, and then select
Details.
105
2. In the Connection Details window, click the Virtual Networks tab. You can see the list of all
3. Click
13.1.1.3
of the connection for which you need to configure the virtual network, and then select
Details.
2. In the Connection Details window, click the Virtual Networks tab. You can see the list of all
3. Click
13.1.1.4
of the connection for which you need to configure the virtual network, and then select
Details.
2. In the Connection Details window, click the Virtual Networks tab. You can see the list of all
3. Click
13.1.2
You can manage libvirt -provided virtual networks with the virsh command line tool. To
view all network related virsh commands, run
# virsh help network
Networking (help keyword 'network'):
106
net-autostart
autostart a network
net-create
net-define
net-destroy
net-dumpxml
net-edit
net-event
Network Events
net-info
network information
net-list
list networks
net-name
net-start
net-undefine
net-update
net-uuid
To view a brief help information for a specific virsh command, run virsh
virsh_command :
help
SYNOPSIS
net-create <file>
DESCRIPTION
Create a network.
OPTIONS
[--file] <string>
13.1.2.1
Creating a Network
107
The vnet_definition.xml XML file includes the definition of the virtual network that libvirt accepts.
<dhcp>
<range start="192.168.122.2" end="192.168.122.254" />
</dhcp>
</ip>
</network>
The name of the bridge device used to construct the virtual network. When defining
a new network with a <forward> mode of "nat" or "route" (or an isolated network
with no <forward> element), libvirt will automatically generate a unique name
for the bridge device if none is given.
Inclusion of the <forward> element indicates that the virtual network will be connected to the physical LAN. The mode attribute specifies the forwarding method. The
most common modes are "nat" (default, network address translation), "route" (direct
forwarding to the physical network, no address translation), and "bridge" (network
bridge configured outside of libvirt ). If the <forward> element is not specified,
the virtual network will be isolated from other networks. For a complete list of forwarding modes, see http://libvirt.org/formatnetwork.html#elementsConnect.
108
Enable DHCP server for the virtual network, offering IP addresses ranging from the
specified start and end attribute.
EXAMPLE13.2:ROUTED NETWORK
The following configuration routes traffic from the virtual network to the LAN without
applying any NAT. The IP address range must be pre-configured in the routing tables of
the router on VM Host Server network.
<network>
<name>vnet_routed</name>
<bridge name="virbr1" />
<forward mode="route" dev="eth1"/>
The guest traffic may only go out via the eth1 network device on the VM Host Server.
EXAMPLE13.3:ISOLATED NETWORK
This configuration provides a completely 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>
109
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 will all be
on the subnet of the physical network, and there will be no restrictions on incoming or
outgoing connections.
<network>
<name>host-bridge</name>
<forward mode="bridge"/>
<bridge name="br0"/>
</network>
13.1.2.2
Listing Networks
Name
State
Autostart
Persistent
---------------------------------------------------------crowbar
active
yes
yes
vnet_nated
active
yes
yes
vnet_routed
active
yes
yes
vnet_isolated
inactive
yes
yes
13.1.2.3
vnet_routed
UUID:
756b48ff-d0c6-4c0a-804c-86c4c832a498
Active:
yes
Persistent:
yes
Autostart:
yes
Bridge:
virbr5
110
13.1.2.4
Starting a Network
To start an inactive network that was already defined, find its name (or unique identifier, UUID)
with
State
Autostart
Persistent
---------------------------------------------------------vnet_isolated
inactive
yes
yes
13.1.2.5
Stopping a Network
To stop an active network, find its name (or unique identifier, UUID) with
root # virsh net-list --inactive
Name
State
Autostart
Persistent
---------------------------------------------------------vnet_isolated
active
yes
yes
13.1.2.6
Removing a Network
To remove the definition of an inactive network from VM Host Server permanently, run
root # virsh net-undefine vnet_isolated
Network vnet_isolated has been undefined
111
network switch, and guest machines treat it transparently as a physical network interface. Any
physical or virtual device can be connected to the bridge.
If there is a network bridge present on VM Host Server, you can connect VM Guest directly to
it. This provides the VM Guest with full incoming and outgoing network access.
13.2.1
This section includes procedures to add or remove network bridges with YaST.
13.2.1.1
4. In the Address tab, specify networking details such as DHCP/static IP address, subnet mask
or host name.
5. Activate the Bridged Devices tab and activate the network devices you want to include in
6. Click Next to return to the Overview tab and confirm with OK. The new network bridge
13.2.1.2
112
Bridged Networking
2. Select the bridge device you want to delete from the list in the Overview tab.
3. Delete the bridge with Delete and confirm with OK.
13.2.2
This section includes procedures to add or remove network bridges with the brctl command
line tool.
13.2.2.1
To add a new network bridge device on VM Host Server with brctl , follow these steps:
1. Login as root on the VM Host Server where you want to create a new network bridge.
2. Choose a name for the new bridge virbr_test in our example and run
root # brctl addbr virbr_test
bridge id
STP enabled
interfaces
br0
8000.e06995ec09e8
no
eth0
virbr0
8000.525400b37ec9
yes
virbr0-nic
virbr_test
8000.000000000000
no
virbr_test is present, but is not associated with any physical network interface.
Important
You can only enslave a network interface that is not yet used by other network
bridge.
113
ki/Spanning_Tree_Protocol]:
13.2.2.2
To delete an existing network bridge device on VM Host Server with brctl , follow these steps:
1. Login as root on the VM Host Server where you want to delete an existing network bridge.
2. List existing network bridges to identify the name of the bridge to remove:
root # brctl show
bridge name
bridge id
STP enabled
interfaces
br0
8000.e06995ec09e8
no
eth0
virbr0
8000.525400b37ec9
yes
virbr0-nic
virbr_test
8000.000000000000
yes
eth1
114
sole in Virtual Machine Manager and either choose View Details from the menu, or click the
bulb icon in the toolbar.
The left panel of the window lists VM Guest overview and already installed hardware. After
clicking an item in the list, you can access its detailed settings in the details view. You can
change the hardware parameters to match your needs, then click Apply to confirm them. Some
changes take effect immediately, while other need reboot of the machineand virt-manager
warns you about that fact.
To remove installed hardware form VM Guest, click it in the left panel and then click Remove
in the bottom right of the window.
To add new hardware, click Add Hardware below the left panel, then select the type of the
hardware you want to add in the Add New Virtual Hardware window. Modify its parameters and
confirm with Finish.
115
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.
14.1.1
Overview
FIGURE14.2:OVERVIEW DETAILS
Name, Title, and Description are editable and help you identify VM Guest in the Virtual Machine
Manager list of machines.
116
Machine Setup
UUID shows the universally unique identifier of the virtual machine, while Status shows its
current statusRunning, Paused, or Shutoff.
The Hypervisor Details section shows the hypervisor type, CPU architecture, used emulator, and
chipset type. None of the hypervisor parameters can be changed.
14.1.2
Performance
Performance shows regularly updated charts of CPU and memory usage, and disk and network
I/O.
FIGURE14.4:PERFORMANCE
selected charts, go to File View Manager Polling, and check the charts that you want to
see regularly updated. You can also specify the time interval (in seconds) of the update.
117
Performance
FIGURE14.5:STATISTICS CHARTS
14.1.3
Processor
FIGURE14.6:PROCESSOR VIEW
118
Processor
In the CPUs section, you can configure several parameters related to the number of allocated
CPUs.
The number of currently allocated CPUs. You can hotplug more CPUs by increasing this
value up to the Maximum allocation value.
Maximum allocation
Maximum number of allocable CPUs for the current session. Any change to this value will
take effect after next VM Guest reboot.
The Configuration section lets you configure the CPU model, topology, and pinning.
When activated, the Copy host CPU configuration option uses the host CPU model for VM Guest.
Otherwise you need to specify the CPU model from the drop-down list.
After you activate Manually set CPU topology, you can specify a custom number of sockets, cores
and threads for the CPU.
You can also specify Default pinning (see CPU pinning) for the CPU, or get the relevant pinning
information from the host by clicking Generate from host NUMA configuration.
14.1.4
Memory
119
Memory
FIGURE14.7:MEMORY VIEW
The amount of memory currently available to VM Guest. You can hotplug more memory
by increasing this value up to the value of Maximum allocation.
Maximum allocation
The maximum value to which you can hotplug the currently available memory. Any change
to this value will take effect after next VM Guest reboot.
14.1.5
Boot Options
120
Boot Options
FIGURE14.8:BOOT OPTIONS
In the Autostart section, you can specify whether the virtual machine should automatically start
during VM Host Server boot phase.
In the Boot device order, activate the devices that will be used for booting VM Guest. You can
change their order with the up an down arrows on the right side of the list. If you want to choose
from a list of bootable devices on VM Guest startup, activate Enable boot menu.
To boot a different kernel than the one on the boot device, activate Enable direct kernel boot and
specify paths to alternative kernel and initrd placed on the VM Host Server file system. You can
also specify kernel arguments that will be passed to the loaded kernel.
14.2 Storage
This section gives you detailed description of configuration options for storage devices. It includes both hard disks and removable media, such as USB or CDROM drives.
PROCEDURE14.1:ADDING A NEW STORAGE DEVICE
121
Storage
1. Click Add Hardware below the left panel, then select Storage from the Add New Virtual
Hardware window.
2. If you prefer that Virtual Machine Manager creates a disk image for you, activate Create a
disk image on the computer's hard drive and specify its size in Gigabytes. If you want Virtual
Machine Manager to allocate the entire disk space no, activate the relevant option. Note
that qcow2 and qed formats do not support full allocation.
If you want to have more control over the disk image creation, activate Select managed or
other existing storage and click Browse to manage storage pools and images. Choose Storage
window opens, which has almost identical functionality as the Storage card described in
Section12.1, Managing Storage with Virtual Machine Manager.
3. After you manage to create and specify the disk image file, specify the Device type. It can be
either Disk device, CDROM device, Floppy device, or LUN Passthrough. The latter is required
if you want to use an existing SCSI storage directly without adding it into a storage pool.
122
Storage
4. Select the Bus type for your device. The list of available options depends on the device
type you selected in the previous step. Note that the Virtio- based types use paravirtualized
drivers.
5. In the Advanced options section, select the preferred Cache mode and Storage format. For
14.3 Controllers
This section focuses on adding and configuring new controllers.
PROCEDURE14.2:ADDING A NEW CONTROLLER
1. Click Add Hardware below the left panel, then select Controller from the Add New Virtual
Hardware window.
123
Controllers
2. Select the type of the controller. You can choose from IDE, Floppy, SCSI, SATA, VirtIO
3. Optionally, select the model for the controller. It is available for USB and SCSI types.
4. Confirm your settings with Finish. A new controller appears in the left panel.
14.4 Networking
This section describes how to add and configure new network devices.
PROCEDURE14.3:ADDING A NEW NETWORK DEVICE
1. Click Add Hardware below the left panel, then select Network from the Add New Virtual
Hardware window.
124
Networking
2. From the Network source list, select the source for the network connection. The list in-
cludes VM Host Server's available physical network interfaces, network bridges, or net-
work bonds. You can also assign the VM Guest to an already defined virtual network. See
Chapter13, Managing Networks for more information on setting up virtual networks with
3. Specify a MAC address 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.
4. Select a device model from the list. You can either leave the Hypervisor default, or specify
one of e1000, eepro100, rtl8139, or virtio models. Note that virtio uses paravirtualized
drivers.
5. Confirm your settings with Finish. A new network device appears in the left panel.
Alt
Ctrl ). To prevent the console from grabbing the key and to enable seamless cursor
movement between host and guest instead, add a tablet to the VM Guest.
Adding a tablet has the additional advantage of synchronizing the cursor movement between
VM Host Server and VM Guest when using a graphical environment on the guest. With no tablet
configured on the guest, you will often see two cursor symbols with one dragging behind the
other.
1. Double-click a VM Guest entry in the Virtual Machine Manager to open its console and
2. Click Add Hardware and choose Input and then EvTouch USB Graphics Tablet in the pop-
3. If you try to add the tablet while the guest is still running, you will be asked whether to
enable the tablet after the next reboot. Confirm with Yes.
125
4. When you (re)start the VM Guest, the tablet is available in the VM Guest.
2. Click Add Hardware and choose Storage in the pop-up window. Proceed with Forward.
3. Change the Device Type to IDE CDROM.
4. Select Select Managed or Other Existing Storage.
a. 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 the Browse button. Alternatively you may use the Browse button to open a file browser and then click Browse
Local 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.
b. To assign the device to an existing image, click Browse to choose an image from a
storage pool. If the Virtual Machine Manager was started on the VM Host Server,
you may alternatively choose an image from another location on the file system by
clicking Browse Local. Select an image and close the file browser with Choose Volume.
5. Proceed with Forward to review the settings. Apply them with Finish, Yes, and Apply.
6. Reboot the VM Guest to make the new device available. For further information also see
Section14.8, Ejecting and Changing Floppy or CD/DVD-ROM Media with Virtual Machine Manager.
126
To create an empty floppy disk image use one of the following commands:
Raw Image
dd if=/dev/zero of=/var/lib/libvirt/images/floppy.img bs=512 count=2880
2. Click Add Hardware and choose Storage in the pop-up window. Proceed with Forward.
3. Change the Device Type to Floppy Disk.
4. Choose Select Managed or Other Existing Storage and click Browse to choose an existing
image from a storage pool. If Virtual Machine Manager was started on the VM Host Server,
you may alternatively choose an image from another location on the file system by clicking
Browse Local. Select an image and close the file browser with Choose Volume.
5. Proceed with Forward to review the settings. Apply them with Finish, Yes, and Apply.
6. Reboot the VM Guest to make the new device available. For further information also see
Section14.8, Ejecting and Changing Floppy or CD/DVD-ROM Media with Virtual Machine Manager.
127
14.8 Ejecting and Changing Floppy or CD/DVDROM Media with Virtual Machine Manager
Regardless of 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.
1. Double-click a VM Guest entry in the Virtual Machine Manager to open its console and
2. Choose the Floppy or CD/DVD-ROM device and eject the media by clicking Disconnect.
3. To insert a new media, click Connect.
a. 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 CD-ROM or DVD and select the device from the drop-down
box.
b. If using an ISO image, choose ISO image Location and select an image by clicking
Browse. When connecting from a remote host, you may only choose images from
existing storage pools.
4. Click OK to finish. The new media can now be accessed in the VM Guest.
VM Guest is pc-i440fx. The machine type is stored in the VM Guest's xml configuration file in
/etc/libvirt/qemu/ in the tag type :
Let's change this value to the new supported q35 machine type. q35 is an Intel* chipset. It
includes PCIe. q35 supports up to 12 USB ports, and has SATA and IOMMU support. IRQ routing
has also been improved.
Ejecting and Changing Floppy or CD/DVD-ROM Media with Virtual Machine Manag128
er
Name
State
----------------------------------------------------
sles11
shut off
5. Now check that the machine type has changed. Log in to the VM Guest as root and run
machine type of the VM Guests to the latest available version (check with 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 , an update to pc-i440fx-2.x
is strongly recommended. This allows to take advantage of the most recent updates and
corrections in the machine definitions, with an eye towards better future-looking compatibility.
129
via VFIO or via the legacy KVM PCI Pass-Through. Using VFIO is strongly recommended,
since it is more stable and secure. Support for the legacy KVM PCI Pass-Through will be
removed from future openSUSE Leap releases. See Section1.5, I/O Virtualization for more
details.
VFIO support is built into libvirt and will automatically be used if the vfio_pci driver
is loaded (see Important: Requirements for VFIO and SR-IOV for setup instructions). In case
vfio_pci is not loaded, libvirt will automatically fall back to KVM PCI Pass-Through.
14.10.1
The following procedure describes how to add a PCI device to a VM Guest using Virtual Machine
Manager:
1. Double-click a VM Guest entry in the Virtual Machine Manager to open its console and
2. Click Add Hardware and choose the PCI Host Device category in the left pane. A list of
130
3. From the list of available PCI devices, choose the one you want to pass to the guest.
14.10.2
131
[...]
03:07.0 Ethernet controller [0200]: Digital Equipment Corporation DECchip \
21140 [FasterNet] [1011:0009] (rev 22)
[...]
the ID , you need to replace colon and period in the device ID ( 03:07.0 ) with underscore
and prefix the result with pci_0000_ ( pci_0000_03_07_0 ).
tux > virsh 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>
132
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. libvirt
will refuse to assign the device if one of its functions is still in use by the VM Host
Server or another VM Guest.
4. Convert the domain, bus, slot, and function value from decimal to hexadecimal, and
prepend 0x to tell the system that the value is hexadecimal. In our example, domain =
0, bus = 3, slot = 7, and function = 0. Their hexadecimal values are:
tux > printf %x 0
0
tux > printf %x 3
3
tux > printf %x 7
7
This results in domain = 0x0000, bus = 0x03, slot = 0x07 and function = 0x00.
5. Run virsh edit on your domain, and add the following device entry in the <devices>
aged or unmanaged . In the managed case, libvirt will handle all the details of
unbinding the device from the existing driver if needed, resetting the device, binding it to vfio-pci before starting the domain, etc. When the domain is terminated
or the device is removed from the domain, libvirt will unbind from vfio-pci
133
and rebind to the original driver in the case of a managed device. If the device
is unmanaged, the user must take care to ensure all of 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, set managed='no' in the listing
above. If you do so, you need to take care of the related driver with the virsh nod-
to detach the device from the host. In case the VM Guest is not running, you
can make the device available for the host by running virsh nodedev-reattach
pci_0000_03_07_0 .
6. Shut down the VM Guest and restart it to make the assigned PCI device available.
Tip: SELinux
If you are running SELinux on your VM Host Server, you need to disable it prior
to starting the VM Guest with
setsebool -P virt_use_sysfs 1
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 partthey only can move data
and a reduced set of configuration functions. Since VFs do not have all PCIe functions, the host
operating system or the Hypervisor must support SR-IOV to be able to access and initialize VFs.
134
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.
14.11.1
Requirements
A host configuration that meets the requirements listed at Important: Requirements for VFIO
and SR-IOV
A list of the PCI addresses of the VF(s) that will be assigned to VM Guests
135
Requirements
14.11.2
To be able to access and initialize VFs, an SR-IOV-capable driver needs to be loaded on the
host system.
1. Before loading the driver, make sure the card is properly detected by running lspci . The
following example shows the lspci output for the dual-port Intel 82576NS network card:
tux > sudo /sbin/lspci | grep 82576
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)
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, it is likely that the hardware virtualization support in the
BIOS/EFI has not been enabled.
2. 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.
185649 0
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 rmmod to unload a driver. The following example unloads
the non-SR-IOV driver for the Intel 82576NS network card:
sudo /sbin/rmmod igbvf
136
4. Configure the driver by adding the number of VFs you want to make available and, if
Make sure to replace the example values igb , igbvf and 50-igb by values appropriate
for your driver.
5. Now make sure the driver is loaded on boot by creating the file /etc/modules-load.d/
igb.conf with the following content:
# Load the igb driver at boot
igb
Make sure to replace the example value igb by a string appropriate for your driver.
6. Reboot the machine and check if the SR-IOV driver is loaded by re-running the lspci
command from the first step of this procedure. If the SR-IOV driver was loaded successfully
you should see additional lines for the VFs:
137
04:10.1 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
04:10.2 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
[...]
14.11.3
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 some data first.
Note: The following procedure is using example data. Make sure to replace it by appropriate data from your setup.
1. Use the virsh nodedev-list command to get the PCI address of the VF you want
to assign and its corresponding PF. Numerical values from the lspci output shown
in Section14.11.2, Loading and Configuring the SR-IOV Host Drivers (for example 01:00.0
or 04:00.1 ) are transformed by adding the prefix "pci_0000_" and by replacing colons
and dots with underscores. So a PCI ID listed as "04:00.0" by lspci is listed as
"pci_0000_04_00_0" by virsh. The following example lists the PCI IDs for the second port
of the Intel 82576NS network card:
138
pci_0000_04_11_5
The first two entries represent the PFs, whereas the other entries represent the VFs.
2. Get more data that will be needed by running the command virsh nodedev-dumpxml
<source>
139
</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, libvirt introduced the
interface type='hostdev' directive, which sets up network-specific data before assigning the device.
2
4. In case a device is already attached to the host, it cannot be attached to a guest. To make
GUEST needs to be replaced by the domain name, id or uuid of the VM Guest and -- OPTION
This option will always add the device to the domain's persistent XML. In addition,
if the domain is running, it will be hotplugged.
--config
This option will only affect the persistent XML, even if the domain is running. The
device will only show up in the guest on next boot.
--live
This option will only affect a running domain. If the domain is inactive, the operation
will fail. The device is not persisted in the XML and will not be available in the guest
on next boot.
140
--current
This option affects the current state of the domain. If the domain is inactive, the
device is added to the persistent XML and will be 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-device command, which also takes the
options listed above.
14.11.4
If you define the PCI address of a VF into a guest's configuration statically as described in
Section14.11.3, Adding a VF Network Device to an Existing 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 guest configuration must be modified prior to 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 guest then references this network, and each time it is started, a single
VF is dynamically allocated to it. When the guest is stopped, the VF is returned to the pool,
available for another guest.
14.11.4.1
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
141
14.11.4.2
The following example of guest device interface definition uses a VF of the SR-IOV device from
the pool created in Section14.11.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>
To verify the list of associated VFs, run virsh net-dumpxml passthrough on the host after
the first guest that uses the network with the pool of VFs starts.
<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>
142
15
16
17
libguestfs 151
default cache mode is used. These cache modes influence how host-based storage is accessed,
as follows:
Synchronous write mode may be used, in which write requests are reported complete only
when committed to the storage device.
Flush commands (generated by the guest storage controller) may be ignored for performance reasons.
If a disorderly disconnection between the guest and its storage occurs, the cache mode in use will
affect whether data loss occurs. The cache mode can also affect disk performance significantly.
Additionally, some cache modes are incompatible with live migration, depending on several
factors. There are no simple rules about what combination of cache mode, disk image format,
image placement, or storage sub-system is best. The user should plan each guest's configuration
carefully and experiment with various configurations to determine the optimal performance.
In QEMU versions older than v1.2 (for example SLES11 SP2), not specifying a cache mode
meant that writethrough would be used as the default. Since that version, the various guest
storage interfaces have been fixed to handle writeback or writethrough semantics more cor-
144
rectly, allowing for the default caching mode to be switched to writeback. The guest driver
for each of ide , scsi , and virtio have within their power to disable the write back
cache, causing the caching mode used to revert to writethrough. The typical guest's storage
drivers will maintain the default caching mode as writeback, however.
writethrough
This mode causes the hypervisor to interact with the disk image file or block device with
O_DSYNC semantics, where writes are reported as completed only when the data has been
committed to the storage device. The host page cache is used in what can be termed a
writethrough caching mode. The guest's virtual storage adapter is informed that there is
no writeback cache, so the guest would not need to send down flush commands to manage
data integrity. The storage behaves as if there is a writethrough cache.
writeback
This mode causes the hypervisor to interact with the disk image file or block device with
neither O_DSYNC nor O_DIRECT semantics, so the host page cache is used and writes are
reported to the guest as completed when placed in the host page cache, and the normal
page cache management will handle commitment to the storage device. Additionally, the
guest's virtual storage adapter is informed of the writeback cache, so the guest would be
expected to send down flush commands as needed to manage data integrity. Analogous
to a raid controller with RAM cache.
none
This mode causes the hypervisor to interact with the disk image file or block device with
O_DIRECT semantics, so the host page cache is bypassed and I/O happens directly between
the hypervisor userspace buffers and the storage device. Because the actual storage device
may report a write as completed when placed in its write queue only, the guest's virtual
storage adapter is informed that there is a writeback cache, so the guest would be expected
to send down flush commands as needed to manage data integrity. Performance-wise, it
is equivalent to direct access to your host's disk.
unsafe
This mode is similar to the writeback mode discussed above. The key aspect of this
unsafe mode, is that all flush commands from the guests are ignored. Using this mode
implies that the user has accepted the trade-off of performance over risk of data loss in
case of a host failure. Useful, for example, during guest installation, but not for production
workloads.
145
directsync
This mode causes the hypervisor to interact with the disk image file or block device with
both O_DSYNC and O_DIRECT semantics, where writes are reported as completed only
when the data has been committed to the storage device, and when it is also desirable to
bypass the host page cache. Like writethrough, it is helpful to guests that do not send flushes
when needed. It was the last cache mode added, completing the possible combinations of
caching and direct access semantics.
These are the safest modes, and considered equally safe, given that the guest operating
system is modern and well behaved, which means that it uses flushes as needed. If you
have a suspect guest, use writethough, or directsync. Note that some file systems are not
compatible with none or directsync , as they do not support O_DIRECT, which these
cache modes rely on.
writeback
This mode informs the guest of the presence of a write cache, and relies on the guest to
send flush commands as needed to maintain data integrity within its disk image. This is
a common storage design which is completely accounted for within modern file systems.
But it should be noted that because there is a window of time between the time a write is
reported as completed, and that write being committed to the storage device, this mode
exposes the guest to data loss in the unlikely case of a host failure.
unsafe
This mode is similar to writeback caching except the guest flush commands are ignored,
nullifying the data integrity control of these flush commands, and resulting in a higher
risk of data loss because of host failure. The name unsafe should serve as a warning that
there is a much higher potential for data loss because of a host failure than with the other
modes. Note that as the guest terminates, the cached data is flushed at that time.
146
of the page cache and the IO scheduler used. Additionally, not flushing the write cache increases
performance, but with risk, as noted above. As a general rule, high-end systems typically perform
best with the cache mode none , because of the reduced data copying that occurs. The potential
benefit of having multiple guests share the common host page cache, the ratio of reads to writes,
and the use of AIO mode native (see below) should also be considered.
clustered file system is used, all cache modes support live migration. Otherwise the only cache
mode that supports live migration on read/write shared storage is none .
The libvirt management layer includes checks for migration compatibility based on sever-
al factors. If the guest storage is hosted on a clustered file system, is read-only or is marked
sharable, then the cache mode is ignored when determining if migration can be allowed. Otherwise libvirt will not allow migration unless the cache mode is set to none . However, this
restriction can be overridden with the unsafe option to the migration APIs, which is also supported by virsh , as for example in
virsh migrate --live --unsafe
Tip
The cache mode none is required for the AIO mode setting native . If another cache
mode is used, then the AIO mode will silently be switched back to the default threads .
The guest flush within the host is implemented using fdatasync() .
147
Keeping the correct time is especially important for network applications and is also a prerequisite to do a live migration of a VM Guest.
Use the following command inside a VM Guest running Linux to check whether the driver
kvm_clock has been loaded:
To check which clock source is currently used, run the following command in the VM Guest.
It should output kvm-clock :
cat /sys/devices/system/clocksource/clocksource0/current_clocksource
148
16.1.1
The paravirtualized kvm-clock is currently not for Windows* operating systems. For Windows*, use the Windows
Time
Service
avirtual machines manage clock time according to their independent wallclock setting. If the
independent wallclock is enabled, the virtual machine manages its time independently and does
not synchronize with the host. If the independent wallclock is disabled, the virtual machine
periodically synchronizes its time with the host clock.
Note
OES 2 NetWare virtual machines manage clock time independently after booting. They
do not synchronize with the host clock time.
If a guest operating system is configured for NTP and the virtual machine's independent wallclock setting is disabled, it will still periodically synchronize its time with the host time. This
dual type of configuration can result in time drift between virtual machines that need to be
synchronized. To effectively use an external time source, such as NTP, for time synchronization
on a virtual machine, the virtual machine's independent wallclock setting must be enabled (set
to 1 ). Otherwise, it will continue to synchronize its time with its host.
PROCEDURE16.1:VIEWING THE INDEPENDENT WALLCLOCK SETTING
149
0 means that the virtual machine is getting its time from the host and is not using
independent wallclock.
1 means that the virtual machine is using independent wallclock and managing its
While booting, a virtual machine gets its initial clock time from the host. Then, if the
wallclock setting is set to 1 in the sysctl.conf file, it manages its clock time independently and does not synchronize with the host clock time.
Although the current status of the independent wallclock changes immediately, its clock
time might not be immediately synchronized. The setting persists until the virtual machine
reboots. Then, it gets its initial clock time from the host and uses the independent wallclock
according to the setting specified in the sysctl.conf file.
150
17 libguestfs
Virtual Machines consist of disk images and definition files. Manually accessing and manipulat-
ing these guest components (outside of normal hypervisor processes) is possible, but inherently dangerous and risks compromising data integrity. libguestfs is a C library and corresponding set of tools designed for safely accessing and modifying Virtual Machine disk images - outside of normal hypervisor processes, but without the risk normally associated with manual
editing.
As disk images and definition files are simply another type of file in a Linux environment, it is
possible to use many different tools to access, edit and write to these files. When used correctly,
such tools can be an important part of guest adminitration. However, even correct usage of
these tools is not without risk. Risks that should be considered when manually manipulating
guest disk images include:
Data Corruption: Concurrently accessing images, by the host machine or another node in a
cluster, can cause changes to be lost or data corruption to occur if virtualization protection
layers are bypassed.
Security: Mounting disk images as loop devices requires root access. While an image is loop
mounted, other users and processes can potentially access the disk contents.
standing of virtual components and tools. Failing to isolate the images or failing to clean
up properly after changes have been made can lead to further problems once back in virtualization control.
151
libguestfs
17.1.2
libguestfs Design
libguestfs C library has been designed to safely and securely create, access and modify virtual
machine (VM Guest) disk images. It also provides additional language bindings: for Perl [http://
libguestfs.org/guestfs-perl.3.html], Python [http://libguestfs.org/guestfs-python.3.html], PHP
access VM Guest disk images without needing root and with multiple layers of defense against
rogue disk images.
libguestfs provides many different tools designed for accessing and modifying VM Guest disk
images and contents. These tools provide such capabilities as: viewing and editing files inside
guests, scripting changes to VM Guests, monitoring disk used/free statistics, creating guests,
doing V2V migrations, performing backups, cloning VM Guests, formatting disks, and resizing
disks.
However most command have the --ro (read-only) option. With this option, you can
attach a command to a live virtual machine. The results might be strange or inconsistent
at times but you will not risk disk corruption.
guestfs-tools: the core guestfs tools, man pages, and the /etc/libguestfs-tools.conf
configuration file.
152
libguestfs Design
The set of tools found within the guestfs-tools package is used for accessing and modifying
virtual machine disk images. This functionality is provided through a familiar shell interface
with built-in safeguards which ensure image integrity. Guestfs tools shells expose all capabilities
of the guestfs API, and use the kernel and initrd found in /usr/lib4/guestfs .
17.3.2
systems, and other disk image formats (VMDK, VHDX...). However, these file systems and
disk image formats are unsupported on SUSE Linux Enterprise.
153
Guestfs Tools
17.3.3
virt-rescue
virt-rescue is similar to a rescue CD, but for virtual machines, and without the need for a
CD. virt-rescue presents users with a rescue shell and some simple recovery tools which can be
used to examine and correct problems within a virtual machine or disk image.
tux >
virt-rescue -a sles.qcow2
><rescue>
[
(none):~ #
/dev/pts
devpts
mode=0620,gid=5 0 0
proc
/proc
proc
defaults
0 0
sysfs
/sys
sysfs
noauto
0 0
0 0
usbfs
/proc/bus/usb
usbfs
noauto
0 0
tmpfs
/run
tmpfs
noauto
0 0
154
virt-rescue
17.3.4
virt-resize
virt-resize is used to resize a virtual machine disk, making it larger or smaller overall, and
Name
Type
MBR
Size
Parent
/dev/sda1
partition
83
16G
/dev/sda
/dev/sda
device
16G
store the resized output disk. Use the truncate command to create a file of suitable size:
tux >
3. Use virt-resize to resize the disk image. virt-resize requires two mandatory para-
The
**********
Setting up initial partition table on outdisk.img ...
155
virt-resize
00:03
Expanding /dev/sda1 using the 'resize2fs' method ...
disk, carefully check that the resized disk boots and works correctly.
Name
Type
MBR
Size
Parent
/dev/sda1
partition
83
32G
/dev/sda
/dev/sda
device
32G
5. Bring up the VM Guest using the new disk image and confirm correct operation before
17.3.5
Various other guestfs tools exist to simplify administrative taskssuch as viewing and editing
files, or obtaining information on the virtual machine.
17.3.5.1
virt-filesystems
This tool is used to report information regarding file systems, partitions, and logical volumes
in a disk image or virtual machine.
tux >
virt-filesystems -l -a sles.qcow2
Name
Type
VFS
Label
Size
Parent
/dev/sda1
filesystem
ext3
17178820608
156
17.3.5.2
virt-ls
virt-ls lists file names, file sizes, checksums, extended attributes and more from a virtual
machine or disk image. Multiple directory names can be given, in which case the output from
each is concatenated. To list directories from a libvirt guest, use the -d option to specify the
name of the guest. For a disk image, use the -a option.
tux >
d 0755
4,0K /var/log/
d 0700
4,0K /var/log//YaST2
- 0644
1,9K /var/log//YaST2/mkinitrd.log
- 0644
496 /var/log//YaST2/perl-BL-standalone-log
- 0600
3,2K /var/log//faillog
d 0700
4,0K /var/log//krb5
- 0644
29K /var/log//lastlog
- 0644
496 /var/log//pbl.log
- 0664
0 /var/log//wtmp
d 0755
4,0K /var/log//zypp
17.3.5.3
virt-cat
virt-cat is a command line tool to display the contents of a file that exists in the named virtual
machine (or disk image). Multiple file names can be given, in which case they are concatenated
together. Each file name must be a full path, starting at the root directory (starting with '/').
tux >
/proc
17.3.5.4
proc
defaults
0 0
virt-df
virt-df is a command line tool to display free space on virtual machine file systems. Unlike
other tools, it does not just display the size of disk allocated to a virtual machine, but can look
inside disk images to show how much space is actually being used.
tux >
157
virt-df -a sles.qcow2
Filesystem
sles.qcow2:/dev/sda1
17.3.5.5
1K-blocks
Used
Available
16381864
520564
15022492
Use%
4%
virt-edit
virt-edit is a command line tool capable of editing files that reside in the named virtual
17.3.5.6
virt-tar-in/out
virt-tar-in unpacks an uncompressed TAR archive into a virtual machine disk image or
named libvirt domain. virt-tar-out packs a virtual machine disk image directory into a TAR
archive.
tux >
17.3.5.7
virt-copy-in/out
virt-copy-in copies files and directories from the local disk into a virtual machine disk image
or named libvirt domain. virt-copy-out copies files and directories out of a virtual machine
disk image or named libvirt domain.
tux >
17.3.6
guestfish
guestfish is a shell and command line tool for examining and modifying virtual machine file
systems. It uses libguestfs and exposes all of the functionality of the guestfs API.
Examples of usage:
tux >
158
guestfish
run
list-filesystems
EOF
guestfish
/dev/pts
devpts
mode=0620,gid=5 0 0
proc
/proc
proc
defaults
0 0
sysfs
/sys
sysfs
noauto
0 0
0 0
usbfs
/proc/bus/usb
usbfs
noauto
0 0
tmpfs
/run
tmpfs
noauto
0 0
17.4 Troubleshooting
159
Troubleshooting
17.4.1
Environment
call in a format that is similar to guestfish commands, use the environment variable
LIBGUESTFS_TRACE=1.
17.4.2
libguestfs-test-tool
ing. It will print a large amount of diagnostic messages and details of the guestfs environment,
then create a test image and try to start it. If it runs to completion successfully, the following
message should be seen near the end:
===== TEST FINISHED OK =====
160
Environment
18
19
20
21
22
23
24
25
operating system, but additional CPU, disk, memory, and network resources should be added
to accommodate the resource demands of all planned VM Guest systems.
Tip: Resources
Remember that VM Guest systems, like physical machines, perform better when they run
on faster processors and have access to more system memory.
Xen virtualization technology is available in openSUSE Leap products based on code path 10
and later. Code path 10 products include Open Enterprise Server 2 Linux, openSUSE Leap 10,
SUSE Linux Enterprise Desktop 10, and openSUSE 10.x.
The virtual machine host requires several software packages and their dependencies to be installed. To install all necessary packages, run YaST Software Management, select View Patterns
and choose Xen Virtual Machine Host Server for installation. The installation can also be performed with YaST using the module Virtualization Install Hypervisor and Tools.
After the Xen software is installed, restart the computer and, on the boot screen, choose the
newly added option with the Xen kernel.
Updates are available through your update channel. To be sure to have the latest updates installed, run YaST Online Update after the installation has finished.
If the host should always run as Xen host, run YaST System Boot Loader and activate the
Xen boot entry as default boot section.
162
When using both iSCSI and OCFS2 to host Xen images, the latency required for OCFS2
default timeouts in SUSE Linux Enterprise Server 12 may not be met. To reconfigure this
timeout, run systemctl configure o2cb
system configuration.
If you intend to use a watchdog device attached to the Xen host, use only one at a time. It
is recommended to use a driver with actual hardware integration over a generic software
one.
A better solution is to set a default amount of memory for Dom0, so the memory can be allocated
appropriately to the hypervisor. An adequate amount would be 20 percent of the total system
memory up to 4 GiB. A recommended minimum amount would be 512 MiB
should handle. So be sure you have enough memory to support all your VM Guests. If
the value is too low, the host system may hang when multiple VM Guests use most of
the memory.
163
18.2.1
The memory that is currently allocated by Dom0 can be determined with the command
xl list .
erwise launching VMs will fail with errors about not being able to balloon
down Dom0. So add autoballoon=0 to xl.conf if you have the dom0_mem=
option specified for Xen. Also see Xen dom0 memory [http://wiki.xen.org/wi-
ki/Xen_Best_Practices#Xen_dom0_dedicated_memory_and_preventing_dom0_memory_ballooning]
164
When using SUSE Linux Enterprise, only the paravirtualized network cards are available for the
VM Guest by default. The following network options are available:
emulated
To use an emulated network interface like an emulated Realtek card, specify type=ioemu
in the vif device section of the domain xl configuration. An example configuration would
look like:
vif = [ 'type=ioemu,mac=00:16:3e:5f:48:e4,bridge=br0' ]
Find more details about the xl configuration in the xl.conf manual page man 5 xl.conf .
paravirtualized
When you specify type=vif and do not specify a model or type, the paravirtualized network interface is used:
vif = [ 'type=vif,mac=00:16:3e:5f:48:e4,bridge=br0,backen=0' ]
If the administrator should be offered both options, simply specify both type and model.
The xl configuration would look like:
vif = [ 'type=ioemu,mac=00:16:3e:5f:48:e4,model=rtl8139,bridge=br0' ]
In this case, one of the network interfaces should be disabled on the VM Guest.
memory for a recovery kernel in Dom0, this memory need to be reserved by the hypervisor. Thus, it is necessary to add the parameter crashkernel=size to the kernel line
instead of using the line with the other boot options.
165
For more information on the crashkernel parameter, see Book System Analysis and Tuning Guide, Chapter 17 Kexec and Kdump, Section 17.4 Calculating crashkernel Allocation Size.
If the Xen option is not on the GRUB 2 menu, review the steps for installation and verify that
the GRUB 2 boot loader has been updated. If the installation has been done without selecting
the Xen pattern, run the YaST Software Management, select the filter Patterns and choose Xen
Virtual Machine Host Server for installation.
After booting the hypervisor, the Dom0 virtual machine starts and displays its graphical desktop
environment. If you did not install a graphical desktop, the command line environment appears.
Before starting to install virtual guests, make sure that the system time is correct. To do this,
configure NTP (Network Time Protocol) on the controlling domain:
1. In YaST select Network Services NTP Configuration.
2. Select the option to automatically start the NTP daemon during boot. Provide the IP ad-
correct the system time compared to the hardware time by means of an additional time
source. To get the correct time on all VM Guest systems, also activate the network time
services on each respective guest or make sure that the guest uses the system time of the
host. For more about Independent Wallclocks in openSUSE Leap see Section16.2, Xen
Virtual Machine Clock Settings.
166
For more information about managing virtual machines, see Chapter20, Managing a Virtualization
Environment.
This feature is available from both AMD* and Intel*. For AMD machines, the feature is called
IOMMU; in Intel speak, this is VT-d. Note that Intel-VT technology is not sufficient to use this
feature for fully virtualized guests. To make sure that your computer supports this feature, ask
your supplier specifically to deliver a system that supports PCI Pass-Through.
LIMITATIONS
Some graphics drivers use highly optimized ways to access DMA. This is not supported,
and thus using graphics cards may be difficult.
When accessing PCI devices behind a PCIe bridge, all of the PCI devices must be assigned
to a single guest. This limitation does not apply to PCIe devices.
Guests with dedicated PCI devices cannot be migrated live to a different host.
The configuration of PCI Pass-Through is twofold. First, the hypervisor must be informed at
boot time that a PCI device should be available for reassigning. Second, the PCI device must
be assigned to the VM Guest.
18.5.1
1. Select a device to reassign to a VM Guest. To do this, run lspci and read the device
167
PCI Pass-Through
18.5.1.1
If you want to avoid restarting the host system, you can use dynamic assignment with xl to use
PCI Pass-Through.
Begin by making sure that dom0 has the pciback module loaded:
modprobe pciback
Then make a device assignable by using xl pci-assignable-add . For example, if you wanted
to make the device 06:01.0 available for guests, you should type the following:
xl pci-assignable-add 06:01.0
18.5.2
168
The command xl can be used to add or remove PCI devices on the fly. To add the device
with number 06:01.0 to a guest with name sles12 use:
xl pci-attach sles12 06:01.0
To add the device to the guest permanently, add the following snippet to the guest configuration file:
pci = [ '06:01.0,power_mgmt=1,permissive=1' ]
After assigning the PCI device to the VM Guest, the guest system must care for the configuration
and device drivers for this device.
18.5.3
VGA Pass-Through
Xen 4.0 and newer supports VGA graphics adapter pass-through on fully virtualized VM Guests.
The guest can take full control of the graphics adapter with high-performance full 3D and video
acceleration.
LIMITATIONS
VGA Pass-Through functionality is similar to PCI Pass-Through and as such also requires
IOMMU (or Intel VT-d) support from the mainboard chipset and BIOS.
Only the primary graphics adapter (the one that is used when you power on the computer)
can be used with VGA Pass-Through.
VGA Pass-Through is supported only for fully virtualized guests. Paravirtual guests (PV)
are not supported.
The graphics card cannot be shared between multiple VM Guests using VGA Pass-Through
you can dedicate it to one guest only.
To enable VGA Pass-Through, add the following settings to your fully virtualized guest configuration file:
gfx_passthru=1
pci=['yy:zz.n']
169
VGA Pass-Through
where yy:zz.n is the PCI controller ID of the VGA graphics adapter as found with lspci v on Dom0.
18.5.4
Troubleshooting
In some circumstances, problems may occur during the installation of the VM Guest. This section
describes some known problems and their solutions.
During boot, the system hangs
The software I/O translation buffer allocates a large chunk of low memory early in the
bootstrap process. If the requests for memory exceed the size of the buffer it usually results
in a hung boot process. To check if this is the case, switch to console 10 and check the
output there for a message similar to
kernel: PCI-DMA: Out of SW-IOMMU space for 32768 bytes at device 000:01:02.0
In this case you need to increase the size of the swiotlb . Add swiotlb=128 on the
cmdline of Dom0. Note that the number can be adjusted up or down to find the optimal
size for the machine.
18.5.5
There are several resources on the Internet that provide interesting information about PCI PassThrough:
http://wiki.xensource.com/xenwiki/VTdHowTo
http://software.intel.com/en-us/articles/intel-virtualization-technology-for-directed-io-vt-denhancing-intel-platforms-for-efficient-virtualization-of-io-devices/
http://support.amd.com/TechDocs/48882_IOMMU.pdf
170
Troubleshooting
19 Virtual Networking
A VM Guest system needs some means to communicate either with other VM Guest systems or
with a local network. The network interface to the VM Guest system is made of a split device
driver, which means that any virtual Ethernet device has a corresponding network interface in
Dom0. This interface is set up to access a virtual network that is run in Dom0. The bridged
virtual network is fully integrated into the system configuration of openSUSE Leap and can be
configured with YaST.
When installing a Xen VM Host Server, a bridged network configuration will be proposed during
normal network configuration. The user can choose to change the configuration during the
installation and customize it to the local needs.
If desired, Xen VM Host Server can be installed after performing a default Physical Server installation using the Install Hypervisor and Tools module in YaST. This module will prepare
the system for hosting virtual machines, including invocation of the default bridge networking
proposal.
In case the necessary packages for a Xen VM Host Server are installed manually with rpm or
zypper , the remaining system configuration has to be done by the administrator manually or
The network scripts that are provided by Xen are not used by default in openSUSE Leap. They are
only delivered for reference but disabled. The network configuration that is used in openSUSE
Leap is done by means of the YaST system configuration similar to the configuration of network
interfaces in openSUSE Leap.
by default. For each virtual bridge, a physical Ethernet device is enslaved, and the IP address
assigned to the bridge.
To add a new bridge, for example after installing an additional Ethernet device, or to create a
bridge that is not connected to a real network, proceed as follows:
1. Start yast2 System Network Settings.
2. Click the tab Overview and press Add.
171
Virtual Networking
3. Select Device Type Bridge. The parameter Configuration Name will be set to the next free
4. Either use Dynamic Address (DHCP) as selected by default, or assign a static IP address
to the bridge. Using Dynamic Address is only useful when also assigning a device to the
bridge that is connected to some DHCP server.
If you intend to create a virtual bridge that has no connection to a real Ethernet device,
use Statically assigned IP Address. In this case, it is a good idea to use addresses from the
private IP address ranges, for example, 192.168.x.x or 10.x.x.x .
To create a bridge that should only serve as a connection between the different guests
without connection to the host system, set the IP address to 0.0.0.0 and the netmask to
255.255.255.255 . The network scripts handle this special address as an unset IP address.
After the bridge is created, it may be used by any of the Xen VM Guest systems. A purely virtual
bridge without connection to a real network device is good to provide fast network connections
between different VM Guest systems. If you provide a DHCP server on Dom0 that also defines
routing information to the respective guest for the bridge, the network setup of the respective
VM Guest is simplified.
highest transfer rates with the lowest system requirements. Up to eight network interfaces may
be provided for each VM Guest.
Systems that are not aware of paravirtualized hardware may not have this option. To connect
systems to a network that can only run fully virtualized, several emulated network interfaces
are available. The following emulations are at your disposal:
172
All these network interfaces are software interfaces. Because every network interface must have
a unique MAC address, an address range has been assigned to Xensource that can be used by
these interfaces.
addresses should be big enough to get only unique addresses. However, if you have a
very big installation, or if you want to make sure that no problems arise from random
MAC address assignment, you can also manually assign these addresses.
For debugging or system management purposes, it may be useful to know which virtual in-
terface in Dom0 is connected to which Ethernet device in a running guest. This information
may be read from the device naming in Dom0. All virtual devices follow the rule vif<domain
number>.<interface_number> .
For example, if you want to know the device name for the third interface (eth2) of the VM Guest
with id 5, the device in Dom0 would be vif5.2 . To obtain a list of all available interfaces,
run the command ip a .
The device naming does not contain any information about which bridge this interface is connected to. However, this information is available in Dom0. To get an overview about which
interface is connected to which bridge, run the command brctl show . The output may look
like the following:
# brctl show
bridge name
bridge id
STP enabled
interfaces
br0
8000.001cc0309083
no
eth0
vif2.1
br1
8000.000476f060cc
no
eth1
vif2.0
br2
8000.000000000000
no
In this example, there are three configured bridges: br0, br1 and br2. Currently, br0 and br1
each have a real Ethernet device added: eth0 and eth1, respectively. There is one VM Guest
running with the id 2 that has two Ethernet devices available. eth0 on the VM Guest is bridged
173
with eth1 on the VM Host Server and eth1 on the VM Guest is connected to eth0 on the VM
Host Server. The third bridge with the name br2 is not connected to any VM Guest nor any
real Ethernet device.
yet well supported from YaST and requires quite an amount of manual editing of configuration
files. Thus, this is a task that requires an advanced administrator.
The following configuration will only work when using fixed IP addresses. Using DHCP is not
practicable with this procedure, because the IP address must be known to both, the VM Guest
and the VM Host Server system.
The easiest way to create a routed guest is to change the networking from a bridged to a routed
network. As a requirement to the following procedures, a VM Guest with a bridged network setup must be installed. For example, the VM Host Server is named earth with the IP 192.168.1.20,
and the VM Guest has the name alice with the IP 192.168.1.21.
PROCEDURE19.1:CONFIGURING A ROUTED IPV4 VM GUEST
1. Make sure that alice is shut down. Use xl commands to shut down and check.
2. Prepare the network configuration on the VM Host Server earth:
a. Create a hotplug interface that will be used to route the traffic. To accomplish this,
174
tions:
c. Add a static route to the interface of alice. To accomplish this, add the following line
alice.0
d. To make sure that the switches and routers that the VM Host Server is connected to
know about the routed interface, activate proxy_arp on earth. Add the following
lines to /etc/sysctl.conf :
net.ipv4.conf.default.proxy_arp = 1
net.ipv4.conf.all.proxy_arp = 1
175
3. Proceed with configuring the Xen configuration of the VM Guest by changing the vif
or
vifname=vifalice.0=emu
5. Finally, test the network connection from the VM Guest to the world outside and from
176
br0 , proceed as follows. For easier configuration, only the already installed guest is modified
tions:
177
c. Add a static route to the interface of dolly. To accomplish this, add the following
d. Change the script that is used to set up the interface to the following:
script=/etc/xen/scripts/vif-route-ifup
178
4. The remaining configuration tasks need to be accomplished from inside the VM Guest.
a. Open a console to the VM Guest with xl console domain and log in.
b. Check whether the guest IP is set to 192.168.100.1.
c. Provide VM Guest with a host route and a default gateway to the VM Host Server.
5. Finally, test the network connection from the VM Guest to the outside world.
19.5.1
With Xen, you may limit the network transfer rate a virtual guest may use to access a bridge.
To configure this, you need to modify the VM Guest configuration as described in Section20.1,
XLXen Management Tool.
In the configuration file, first search for the device that is connected to the virtual bridge. The
configuration looks like the following:
vif = [ 'mac=00:16:3e:4f:94:a9,bridge=br0' ]
To add a maximum transfer rate, add a parameter rate to this configuration as in:
vif = [ 'mac=00:16:3e:4f:94:a9,bridge=br0,rate=100Mb/s' ]
Note that the rate is either Mb/s (megabits per second) or MB/s (megabytes per second). In the
above example, the maximum transfer rate of the virtual interface is 100 megabits. By default,
there is no limitation to the bandwidth of a guest to the virtual bridge.
179
Special Configurations
It is even possible to fine-tune the behavior by specifying the time window that is used to define
the granularity of the credit replenishment:
vif = [ 'mac=00:16:3e:4f:94:a9,bridge=br0,rate=100Mb/s@20ms' ]
19.5.2
To monitor the traffic on a specific interface, the little application iftop is a nice program that
displays the current network traffic in a terminal.
When running a Xen VM Host Server, you need to define the interface that is monitored. The
interface that Dom0 uses to get access to the physical network is the bridge device, for example
br0 . This, however, may vary on your system. To monitor all traffic to the physical interface,
To monitor the network traffic of a special network interface of a specific VM Guest, supply
the correct virtual interface. For example, to monitor the first Ethernet device of the domain
with id 5, use the command:
ftop -i vif5.0
19.5.3
Sometimes, it is necessary to create a private connection either between two Xen hosts or be-
tween VM Guest systems. For example, if you want to migrate VM Guest to hosts in a different
network segment, or if you want 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.
180
VLAN interfaces are commonly set up on the VM Host Server and either interconnect the dif-
ferent 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 Dom0 over this network.
Run the YaST module System Network Settings. Follow this procedure to actually set up the
VLAN device:
4. Press Next.
5. Select the interface that the VLAN device should connect to below Real Interface for VLAN.
If the desired interface does not appear in the list, first set up this interface without an
IP Address.
6. Select the desired method for assigning an IP address to the VLAN device.
7. Press Next to finish the configuration.
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 to live-migrate VM Guest
systems that are connected to such a network.
YaST does not always allow to set no IP address. However, this may be a desired feature especially if VM Host Server-only networks should be connected. In this case, use the special address 0.0.0.0 with netmask 255.255.255.255 . The system scripts handle this address as no
IP address set.
181
and can be used for general domain management, such as domain creation, listing, pausing, or
shutting down. Usually you need to be root to execute xl commands.
Note
xl can only manage running guest domains specified by their configuration file. If a
Tip
To allow users to continue to have managed guest domains in the way the obsolete xm
command allowed, we now recommend using libvirt 's virsh and virt-manager
tools. For more information, see PartII, Managing Virtual Machines with libvirt.
xl operations rely upon xenstored and xenconsoled services. Make sure you start
systemctl start xencommons
182
For a complete list of the available xl subcommands, run xl help . For each command, there
is a more detailed help available that is obtained with the extra parameter --help . More information about the respective subcommands is available in the manual page of xl .
For example, the xl list --help displays all options that are available to the list command.
As an example, the xl list command displays the status of all virtual machines.
# xl list
Name
ID
Mem VCPUs
State
Time(s)
Domain-0
457
r-----
2712.9
sles12
512
-b----
16.3
512
opensuse
12.9
The State information indicates if a machine is running, and in which state it is. The most
common flags are r (running) and b (blocked) where blocked means it is either waiting for IO,
or sleeping because there is nothing to do. For more details about the state flags, see man 1 xl .
Other useful xl commands include:
xl create creates a virtual machine from a given configuration file.
xl reboot reboots a virtual machine.
xl destroy immediately terminates a virtual machine.
xl block-list displays all virtual block devices attached to a virtual machine.
20.1.1
When operating domains, xl requires a domain configuration file for each domain. The typical
directory to store such configuration files is /etc/xen/ .
A domain configuration file is a plain text file. It consists of several key=value pairs. Some
keys are mandatory, some are general and apply to any guest, and some apply only to a specific
guest type (para or fully virtualized). A value can either be a "string" surrounded by single
or double quotes, a number, a boolean value, or a list of several values enclosed in brackets
[ value1, value2, ... ] .
183
2. Make a symbolic link of the guest domain configuration file in the auto/ subdirectory.
ln -s /etc/xen/domain_name.cfg /etc/xen/auto/domain_name.cfg
3. On the next system boot, the guest domain defined in domain_name.cfg will be started.
set of events. For example, to tell the domain to restart itself after it is powered off, include the
following line in its configuration file:
on_poweroff="restart"
184
on_poweroff
Specifies what should be done with the domain if it shuts itself down.
on_reboot
Action to take if the domain shuts down with a reason code requesting a reboot.
on_watchdog
Action to take if the domain shuts down because of a Xen watchdog timeout.
on_crash
destroy
Destroy the domain and immediately create a new domain with the same configuration.
rename-restart
Rename the domain that terminated, and then immediately create a new domain with the
same configuration as the original.
preserve
Keep the domain. It can be examined, and later destroyed with xl destroy .
coredump-destroy
Write a core dump of the domain to /var/xen/dump/NAME and then destroy the domain.
coredump-restart
Write a core dump of the domain to /var/xen/dump/NAME and then restart the domain.
185
where ID is the virtual machine ID you want to save, and state-file is the name you
specify for the memory state file. By default, the domain will no longer be running after
you create its snapshot. Use -c to keep it running even after you create the snapshot.
1. Make sure the virtual machine to be restored has not been started since you ran the save
operation.
where state-file is the previously saved memory state file. By default, the domain will
be running after it is restored. To pause it after the restore, use -p .
r - running - The virtual machine is currently running and consuming allocated resources.
b - blocked - The virtual machines processor is not running and not able to run. It is either
p - paused - The virtual machine is paused. It does not interact with the hypervisor but
s - shutdown - The guest operating system is in the process of being shut down, rebooted,
186
187
disk = [ 'format=raw,vdev=hdc,access=ro,devtype=cdrom,target=/root/image.iso' ]
It defines a disk block device based on the /root/image.iso disk image file. The disk will be
seen as hdc by the guest, with read-only ( ro ) access. The type of the device is cdrom with
raw format.
The following example defines an identical device, but using simplified positional syntax:
disk = [ '/root/image.iso,raw,hdc,ro,cdrom' ]
You can include more disk definitions in the same line, each one separated by a comma. If a
parameter is not specified, then its default value is taken:
disk = [ '/root/image.iso,raw,hdc,ro,cdrom','/dev/vg/guest-volume,,hda','...' ]
LIST OF PARAMETERS
target
Virtual device as seen by the guest. Supported values are hd[x], xvd[x], sd[x] etc. See /
parameter is mandatory.
access
Whether the block device is provided to the guest in read-only or read-write mode. Supported values are ro or r for read-only, and rw or w for read/write access. Default is
ro for devtype=cdrom , and rw for other device types.
188
devtype
The back-end implementation to use. Supported values are phy , tap , and qdisk . Nor-
mally this option should not be specified as the back-end type is automatically determined.
script
Specifies that target is not a normal host path, but rather information to be interpreted by the executable program. The specified script file is looked for in /etc/xen/
scripts if it does not point to an absolute path. These scripts are normally called block<script_name> .
To simultaneously run more file-backed virtual disks on a host, you can increase the number of available loopback devices by adding the following option to the hosts /etc/
modprobe.conf.local file.
options loop max_loop=x
Tip
Enter rmmod loop and modprobe loop to unload and reload the module. In case rmmod
does not work, unmount all existing loop devices or reboot the computer.
189
already planned during deployment of the VM Guest, some basic considerations should be done:
Use a block device that may be increased in size. LVM devices and file system images are
commonly used.
Do not partition the device inside the VM Guest, but use the main device directly to apply
the file system. For example, use /dev/xvdb directly instead of adding partitions to /
dev/xvdb .
Make sure that the file system to be used can be resized. Sometimes, for example with
ext3, some features must be switched off to be able to resize the file system. A file system
that can be resized online and mounted is XFS . Use the command xfs_growfs to resize
that file system after the underlying block device has been increased in size. For more
information about XFS , see man 8 xfs_growfs .
When resizing an LVM device that is assigned to a VM Guest, the new size is automatically
known to the VM Guest. No further action is needed to inform the VM Guest about the new
size of the block device.
When using file system images, a loop device is used to attach the image file to the guest. For
more information about resizing that image and refreshing the size information for the VM
Guest, see Section23.2, Sparse Image Files and Disk Space.
190
options that might help technology innovators implement leading-edge virtualization solutions.
It is provided as a courtesy and does not imply that all documented options and tasks are supported by Novell, Inc.
Virtual CD readers work differently depending on whether they are paravirtual or fully virtual.
22.1.1
A paravirtual machine can have up to 100 block devices composed of virtual CD readers and
virtual disks. On paravirtual machines, virtual CD readers present the CD as a virtual disk with
read-only access. Virtual CD readers cannot be used to write data to a CD.
After you have finished accessing a CD on a paravirtual machine, it is recommended that you
remove the virtual CD reader from the virtual machine.
Paravirtualized guests can use the device type devtype=cdrom . This partly emulates the be-
havior of a real CD reader, and allows CDs to be changed. It is even possible to use the eject
command to open the tray of the CD reader.
22.1.2
A fully virtual machine can have up to four block devices composed of virtual CD readers and
virtual disks. A virtual CD reader on a fully virtual machine interacts with an inserted CD in
the way you would expect a physical CD reader to interact. For example, in a Windows* XP*
virtual machine, the inserted CD appears in the Devices with Removable Storage section
of My Computer .
191
When a CD is inserted in the physical CD reader on the host computer, all virtual machines with
virtual CD readers based on the physical CD reader, such as /dev/cdrom/ , can read the inserted
CD. Assuming the operating system has automount functionality, the CD should automatically
appear in the file system. Virtual CD readers cannot be used to write data to a CD. They are
configured as read-only devices.
22.1.3
Virtual CD readers can be based on a CD inserted into the CD reader or on an ISO image file.
1. Make sure that the virtual machine is running and the operating system has finished boot-
ing.
2. Insert the desired CD into the physical CD reader or copy the desired ISO image to a
was properly added. You can also enter ls /sys/block to see all disks available
to the virtual machine.
The CD is recognized by the virtual machine as a virtual disk with a drive designation, for example:
/dev/xvdb
192
b. Enter the command to mount the CD or ISO image using its drive designation. For
example,
The CD or ISO image file should be available to the virtual machine at the specified
mount point.
22.1.4
1. Make sure that the virtual machine is running and the operating system has finished boot-
ing.
2. If the virtual CD reader is mounted, unmount it from within the virtual machine.
3. Enter xl block-list alice on the host view of the guest block devices.
4. Enter xl block-detach alice block_dev_id to remove the virtual device from the
If a graphical desktop, such as GNOME, is installed on the virtual machine host, you can
use a remote viewer, such as a VNC viewer. On a remote computer, log in and manage the
remote guest environment by using graphical tools, such as tigervnc or virt-viewer .
193
Text Only
You can use the ssh command from a remote computer to log in to a virtual machine
host and access its text-based console. You can then use the xl command to manage
virtual machines and the virt-install or vm-install commands to create new virtual
machines.
You can use it from Dom0 (known as local access or on-box access), or from a remote computer.
You can use the IP address of a VM Host Server and a VNC viewer to view the display of this
VM Guest. When a virtual machine is running, the VNC server on the host assigns the virtual
machine a port number to be used for VNC viewer connections. The assigned port number is the
lowest port number available when the virtual machine starts. The number is only available for
the virtual machine while it is running. After shutting down, the port number might be assigned
to other virtual machines.
For example, if ports 1 and 2 and 4 and 5 are assigned to the running virtual machines, the VNC
viewer assigns the lowest available port number, 3. If port number 3 is still in use the next time
the virtual machine starts, the VNC server assigns a different port number to the virtual machine.
To use the VNC viewer from a remote computer, the firewall must permit access to as many
ports as VM Guest systems run from. This means from port 5900 and up. For example, if you
want to run 10 VM Guest systems, you need to open the TCP ports 5900:5910.
To access the virtual machine from the local console running a VNC viewer client, enter one
of the following commands:
vncviewer ::590#
vncviewer :#
# is the VNC viewer port number assigned to the virtual machine.
When accessing the VM Guest from a machine other than Dom0, use the following syntax:
vncviewer 192.168.1.20::590#
194
VNC Viewer
To assign a specific port number on a VM Guest, edit the xl setting of the virtual machine
and change the vnclisten to the desired value. Note that for example for port number 5902,
specify 2 only, as 5900 is added automatically:
vfb = [ 'vnc=1,vnclisten="localhost:2"' ]
For more information regarding editing the xl settings of a guest domain, see Section20.1, XL
Xen Management Tool.
Tip
Assign higher port numbers to avoid conflict with port numbers assigned by the VNC
viewer, which uses the lowest available port number.
22.3.2
If you access a virtual machine's display from the virtual machine host console (known as local
or on-box access), you might want to use SDL instead of VNC viewer. VNC viewer is faster for
viewing desktops over a network, but SDL is faster for viewing desktops from the same computer.
To set the default to use SDL instead of VNC, change the virtual machine's configuration information to the following. For instructions, see Section20.1, XLXen Management Tool.
vfb = [ 'sdl=1' ]
Remember that, unlike a VNC viewer window, closing an SDL window terminates the virtual
machine.
195
entry according to the virtual machine's settings. If there is no keymap entry specified, the
virtual machine's keyboard defaults to English (US).
To view a virtual machine's current keymap entry, enter the following command on the Dom0:
xl list -l vm_name | grep keymap
For a complete list of supported keyboard layouts, see the Keymaps section of the xl.cfg
manual page man 5 xl.cfg .
use to retain its performance. The performance of Dom0 is important for the overall system,
as the disk and network drivers are running on it. Also I/O intensive guests' workloads may
consume lots of Dom0s' CPU cycles. On the other hand, the performance of VM Guests is also
important, to be able to accomplish the task they were set up for.
22.5.1
Dom0
Dedicating CPU resources to Dom0 results in a better overall performance of the virtualized
environment because Dom0 has free CPU time to process I/O requests from VM Guests. Failing
to dedicate exclusive CPU resources to Dom0 usually results in a poor performance and can
cause the VM Guests to function incorrectly.
Dedicating CPU resources involves three basic steps: modifying Xen boot line, binding Dom0's
VCPUs to a physical processor, and configuring CPU-related options on VM Guests:
196
Virtual Keyboards
1. First you need to append the dom0_max_vcpus=X to the Xen boot line. Do so by adding
The first line binds Dom0's VCPU number 0 to the physical processor number 0, while the
second line binds Dom0's VCPU number 1 to the physical processor number 1.
5. Lastly, you need to make sure no VM Guest uses the physical processors dedicated to
VCPUs of Dom0. Assuming you are running an 8-CPU system, you need to add
cpus="2-8"
22.5.2
VM Guests
It is often necessary to dedicate specific CPU resources to a virtual machine. By default, a virtual
machine uses any available CPU core. Its performance can be improved by assigning a reason-
able number of physical processors to it as other VM Guests are not allowed to use them after
that. Assuming a machine with 8 CPU cores while a virtual machine needs to use 2 of them,
change its configuration file as follows:
vcpus=2
197
VM Guests
cpus="2,3"
The above example dedicates 2 processors to the VM Guest, and these being the 3rd and 4th
one, ( 2 and 3 counted from zero). If you need to assign more physical processors, use the
cpus="2-8" syntax.
If you need to change the CPU assignment for a guest named alice in a hotplug manner, do
the following on the related Dom0:
xl vcpu-set alice 2
xl vcpu-pin alice 0 2
xl vcpu-pin alice 1 3
The example will dedicate 2 physical processors to the guest, and bind its VCPU 0 to physical
processor 2 and VCPU 1 to physical processor 3. Now check the assignment:
xl vcpu-list alice
Name
ID VCPUs
CPU State
alice
-b-
1.9 2-3
alice
-b-
2.8 2-3
22.6.1
Just as with physical hardware, it is sometimes desirable to boot a VM Guest from a different
device than its own boot device. For fully virtual machines, it is possible to select a boot device
with the boot parameter in a domain xl configuration file:
boot = boot_device
boot_device can be one of c for hard disk, d for CD-ROM, or n for Network/PXE. You can
specify multiple options, and they will be attempted in the given order. For example,
198
HVM Features
boot = dc
boots from CD-ROM, and falls back to the hard disk if CD-ROM is not bootable.
22.6.2
To be able to migrate a VM Guest from one VM Host Server to a different VM Host Server,
it is mandatory, that the VM Guest system only uses CPU features that are available on both
VM Host Server systems. If the actual CPUs are different on both hosts, it may be necessary to
hide some features before the VM Guest is started to maintain the possibility to migrate the VM
Guest between both hosts. For fully virtualized guests, this can be achieved by configuring the
cpuid that is available to the guest.
To gain an overview of the current CPU, have a look at /proc/cpuinfo . This contains all the
important information that defines the current CPU.
To redefine a CPU, first have a look at the respective cpuid definitions of the CPU vendor. These
are available from:
Intel
http://www.intel.com/Assets/PDF/appnote/241618.pdf
cpuid = "host,tm=0,sse3=0"
The syntax is a comma-separated list of key=value pairs, preceded by the word "host". A few
keys take a numerical value, while all others take a single character which describes what to do
with the feature bit. See man 5 xl.cfg for a complete list of cpuid keys. The respective bits
may be changed by using the following values:
1
199
22.6.3
In case you need to increase the default number of PCI-IRQs available to Dom0 and/or
VM Guest, you can do so by modifying the Xen kernel command line. Use the command
extra_guest_irqs= domu_irgs,dom0_irgs . The optional first number domu_irgs is com-
mon for all VM Guests, while the optional second number dom0_irgs (preceded by a comma)
is for Dom0. Changing the setting for VM Guest has no impact on Dom0 and vice versa. For
example to change Dom0 without changing VM Guest, use
extra_guest_irqs=,512
200
23 Administrative Tasks
The YaST boot loader program is located at YaST System Boot Loader. Click the Bootloader
Options tab and select the line containing the Xen kernel as the Default Boot Section.
Confirm with OK. Next time you boot the host, it will be ready to provide the Xen virtualization
environment.
You can use the Boot Loader program to specify functionality, such as:
Pass kernel command line parameters.
Specify the kernel image and initial RAM disk.
Select a specific hypervisor.
Pass additional parameters to the hypervisor. See http://xenbits.xen.org/docs/unstable/misc/xen-command-line.html for their complete list.
201
Administrative Tasks
You can customize your virtualization environment by editing the /etc/default/grub file.
using a virtual disk based on a sparse image file cannot write to its disk. Consequently, it reports
I/O errors.
If this situation occurs, you should free up available space on the physical disk, remount the
virtual machines file system, and set the file system back to read-write.
To check the actual disk requirements of a sparse image file, use the command du -h <image
file> .
To increase the available space of a sparse image file, first increase the file size and then the
file system.
The resizing of the image file can be done online, while the VM Guest is running. Increase the
size of a sparse image file with:
202
Be sure to use the right seek, else data loss may happen.
If the VM Guest is running during the resize operation, also resize the loop device that provides
the image file to the VM Guest. First detect the correct loop device with the command:
losetup -j /var/lib/xen/images/sles/disk0
Then resize the loop device, for example /dev/loop0 , with the following command:
losetup -c /dev/loop0
Finally check the size of the block device inside the guest system with the command fdisk l /dev/xvdb . The device name depends on the actually increased device.
The resizing of the file system inside the sparse file involves tools that are depending on the
actual file system.
VM Host Server that has stronger hardware or is not yet loaded. Or, if a service of a VM Host
Server is required, all VM Guest systems running on this machine can be migrated to other
machines to avoid interruption of service. These are only two examplesmany more reasons
may apply to your personal situation.
203
Before starting, some preliminary considerations regarding the VM Host Server should be taken
into account:
All VM Host Server systems should use a similar CPU. The frequency is not so important,
but they should be using the same CPU family. To get more information about the used
CPU, see cat /proc/cpuinfo .
All resources that are used by a specific guest system must be available on all involved
VM Host Server systemsfor example all used block devices must exist on both VM Host
Server systems.
If the hosts included in the migration process run in different subnets, make sure that either
DHCP relay is available to the guests, or for guests with static network configuration, set
up the network manually.
Using special features like PCI Pass-Through may be problematic. Do not implement
these when deploying for an environment that should migrate VM Guest systems between
different VM Host Server systems.
For fast migrations, a fast network is mandatory. If possible, use GB Ethernet and fast
switches. Deploying VLAN might also help avoid collisions.
23.3.1
The block devices needed by the VM Guest system must be available on all involved VM Host
Server systems. This is done by implementing some kind of shared storage that serves as container for the root file system of the migrated VM Guest system. Common possibilities include:
iSCSI can be set up to give access to the same block devices from different systems at
NFS is a widely used root file system that can easily be accessed from different locations.
For more information, see Book Reference, Chapter 22 Sharing File Systems with NFS.
DRBD can be used if only two VM Host Server systems are involved. This gives some ex-
tra data security, because the used data is mirrored over the network. For more information, see the SUSE Linux Enterprise High Availability Extension 42.1 documentation at http://
www.suse.com/doc/.
204
SCSI can also be used if the available hardware permits shared access to the same disks.
NPIV is a special mode to use Fibre channel disks. However, in this case all migration hosts
must be attached to the same Fibre channel switch. For more information about NPIV,
see Section21.1, Mapping Physical Storage to Virtual Disks. Commonly, this works if the Fibre
channel environment supports 4 Gbit or faster connections.
23.3.2
The actual migration of the VM Guest system is done with the command:
xl migrate <domain_name> <host>
The speed of the migration depends on how fast the memory print can be saved to disk, sent
to the new VM Host Server and loaded there. This means that small VM Guest systems can be
migrated faster than big systems with a lot of memory.
23.4.1
The preferred terminal application to gather information about Xen virtual environment is xen-
top . Unfortunately, this tool needs a rather broad terminal, else it inserts line breaks into the
display.
205
xentop has several command keys that can give you more information about the system that
Also display network statistics. Note, that only standard configurations will be displayed.
If you use a special configuration like a routed network, no network will be displayed.
B
Display the respective block devices and their cumulated usage count.
For more information about xentop see the manual page man 1 xentop .
Tip: virt-top
libvirt offers the hypervisor-agnostic tool virt-top , which is recommended for monitoring VM Guests. See Section10.8.2, Monitoring with virt-top for details.
23.4.2
There are many different system tools that also help monitoring or debugging a running SUSE
Linux Enterprise system. Many of these are covered in the official SUSE Linux Enterprise documentation. Especially useful for monitoring a virtualization environment are the following tools:
ip
The command line utility ip may be used to monitor arbitrary network interfaces. This
is especially useful if you have set up a network that is routed or applied a masqueraded network. To monitor a network interface with the name alice.0 , run the following
command:
206
brctl
In a standard setup, all the Xen VM Guest systems are attached to a virtual network bridge.
brctl allows you to determine the connection between the bridge and the virtual network
adapter in the VM Guest system. For example, the output of brctl show may look like
the following:
bridge name
bridge id
STP enabled
interfaces
br0
8000.000476f060cc
no
eth0
vif1.0
br1
8000.00001cb5a9e7
no
vlan22
This shows that there are two virtual bridges defined on the system. One is connected to the
physical Ethernet device eth0 , the other one is connected to a VLAN interface vlan22 .
There is only one guest interface active in this setup, vif1.0 . This means that the guest
with ID 1 has an Ethernet interface eth0 assigned, that is connected to br0 in the VM
Host Server.
iptables-save
Especially when using masquerade networks, or if several Ethernet interfaces are set up
together with a firewall setup, it may be helpful to check the current firewall rules.
The command iptables may be used to check all the different firewall settings. To list
all the rules of a chain, or even of the complete setup, you may use the commands iptables-save or iptables -S .
207
3. Check the validity of the vhostmd.conf configuration file with the command:
cd /etc/vhostmd
xmllint --postvalid --noout vhostmd.conf
4. Start the vhostmd daemon with the command sudo systemctl start vhostmd .
If vhostmd should be started automatically during start-up of the system, run the command:
5. Attach the image file /dev/shm/vhostmd0 to the VM Guest system named alice with the
command:
option -d <filename> .
The result of the vm-dump-metrics is an XML output. The respective metric entries follow the
DTD /etc/vhostmd/metric.dtd .
For more information, see the manual pages man 8 vhostmd and /usr/share/doc/vhost-
md/README on the VM Host Server system. On the guest, see the manual page man 1 vm-dumpmetrics .
208
24.1 Introduction
XenStore is a database of configuration and status information shared between VM Guests and
the management tools running in Dom0. VM Guests and the management tools read and write to
XenStore to convey configuration information, status updates, and state changes. The XenStore
database is managed by Dom0 and supports simple operations such as reading and writing a
key. VM Guests and management tools can be notified of any changes in XenStore by watching
entries of interest. Note that the xenstored daemon is managed by the xencommons service.
XenStore is located on Dom0 in a single database file /var/lib/xenstored/tdb ( tdb represents tree database).
information on /proc , see Book System Analysis and Tuning Guide, Chapter 2 System Monitoring Utilities, Section 2.6 The /proc File System). The tree has three main paths: /vm , /
local/domain , and /tool .
209
Tip
Each VM Guest has two different ID numbers. The universal unique identifier (UUID) re-
mains the same even if the VM Guest is migrated to another machine. The domain iden-
24.2.1
XenStore Commands
The file system structure of the XenStore database can be operated with the following commands:
xenstore-ls
xenstore-read path_to_xenstore_entry
xenstore-exists xenstore_path
xenstore-list xenstore_path
xenstore-write path_to_xenstore_entry
xenstore-rm xenstore_path
xenstore-control
210
XenStore Commands
24.2.2
/vm
The /vm path is indexed by the UUID of each VM Guest, and stores configuration information
such as the number of virtual CPUs and the amount of allocated memory. There is a /vm/
<uuid> directory for each VM Guest. To list the directory content, use xenstore-list .
# xenstore-list /vm
00000000-0000-0000-0000-000000000000
9b30841b-43bc-2af9-2ed3-5a649f466d79-1
The first line of the output belongs to Dom0, and the second one to a running VM Guest. The
following command lists all the entries related to the VM Guest:
# xenstore-list /vm/9b30841b-43bc-2af9-2ed3-5a649f466d79-1
image
rtc
device
pool_name
shadow_memory
uuid
on_reboot
start_time
on_poweroff
bootloader_args
on_crash
vcpus
vcpu_avail
bootloader
name
To read a value of an entry, for example the number of virtual CPUs dedicated to the VM Guest,
use xenstore-read :
# xenstore-read /vm/9b30841b-43bc-2af9-2ed3-5a649f466d79-1/vcpus
1
211
/vm
UUID of the VM Guest. It does not change during the migration process.
on_reboot
on_poweroff
on_crash
vcpus
vcpu_avail
Bitmask of active virtual CPUs for the VM Guest. The bitmask has several bits equal to the
value of vcpus , with a bit set for each online virtual CPU.
name
kernel
212
/vm
cmdline
The kernel command line for the VM Guest used when booting.
ramdisk
dmargs
Shows arguments passed to the QEMU process. If you look at the QEMU process with ps ,
you should see the same arguments as in /vm/<uuid>/image/dmargs .
24.2.3
/local/domain/<domid>
This path is indexed by the running domain (VM Guest) ID, and contains information about
the running VM Guest. Remember that the domain ID changes during VM Guest migration. The
following entries are available:
vm
domid
cpu
cpu_weight
The weight assigned to the VM Guest for scheduling purposes. Higher weights use the
physical CPUs more often.
Apart from the individual entries described above, there are also several subdirectories under /
local/domain/<domid> , containing specific entries. To see all entries available, refer to XenS-
Contains memory information. /local/domain/<domid>/memory/target contains target memory size for the VM Guest (in kilobytes).
213
/local/domain/<domid>
/local/domain/<domid>/console
/local/domain/<domid>/backend
Contains information about all back-end devices used by the VM Guest. The path has
subdirectories of its own.
/local/domain/<domid>/device
/local/domain/<domid>/device-misc
/local/domain/<domid>/store
214
/local/domain/<domid>
Failure of a single server does not cause major interruption of the service.
A single big machine is normally way cheaper than multiple smaller machines.
Adding new servers as needed is a trivial task.
The utilization of the server is improved, which has positive effects on the power consumption of the system.
The setup of migration for Xen hosts is described in Section23.3, Migrating Xen VM Guest Systems.
In the following, several typical scenarios are described.
system is already in place, first try to use the same device type you already used in the network.
If the storage system cannot be used directly but provides a possibility to offer the needed space
over NFS, it is also possible to create image files on NFS. If the NFS file system is available on
all Xen host systems, this method also allows live migrations of Xen guests.
When setting up a new system, one of the main considerations is whether a dedicated storage
area network should be implemented. The following possibilities are available:
TABLE25.1:XEN REMOTE STORAGE
Method
Complexity
Comments
Ethernet
low
215
Method
Complexity
Comments
medium
age.
over a dedicated Ethernet interface may eliminate a bottleneck on the server side.
high
Typically, a 1 Gbit/s Ethernet device can fully use a typical hard disk or storage system. When
using very fast storage systems, such an Ethernet device will probably limit the speed of the
system.
host systems. To still maintain the possibility of live migrations, it is necessary to build block
devices that are mirrored to both Xen hosts. The software that allows this is called Distributed
Replicated Block Device (DRBD).
If a system that uses DRBD to mirror the block devices or files between two Xen hosts should be
set up, both hosts should use the identical hardware. If one of the hosts has slower hard disks,
both hosts will suffer from this limitation.
216
During the setup, each of the required block devices should use its own DRBD device. The setup
of such a system is quite a complex task.
to do this over the regular interface. However, for security reasons it may be advisable to create
a bridge that is only connected to guest systems.
In an HA environment that also should support live migrations, such a private bridge must be
connected to the other Xen hosts. This is possible by using dedicated physical Ethernet devices
and a dedicated network.
A different implementation method is using VLAN interfaces. In that case, all the traffic goes
over the regular Ethernet interface. However, the VLAN interface does not get the regular traffic,
because only the VLAN packets that are tagged for the correct VLAN are forwarded.
For more information about the setup of a VLAN interface see Section19.5.3, Using VLAN Interfaces.
217
26
27
28
29
30
26 QEMU Overview
QEMU is a fast, cross-platform open source machine emulator which can emulate a huge number
of hardware architectures for you. QEMU lets you run a complete unmodified operating system
(VM Guest) on top of your existing system (VM Host Server).
You can also use QEMU for debugging purposesyou can easily stop your running virtual machine, inspect its state and save and restore it later.
QEMU consists of the following parts:
processor emulator (x86, s390x, PowerPC, Sparc)
emulated devices (graphic card, network card, hard disks, mice)
generic devices used to connect the emulated devices to the related host devices
descriptions of the emulated machines (PC, Power Mac)
debugger
user interface used to interact with the emulator
QEMU is central to KVM and Xen Virtualization, where it provides the general machine emulation. Xen's usage of QEMU is somewhat hidden from the user, while KVM's usage exposes most
QEMU features transparently. If the VM Guest hardware architecture is the same as the VM Host
Server's architecture, QEMU can take advantage of the KVM acceleration (SUSE only supports
QEMU with the KVM acceleration loaded).
Apart from providing a core virtualization infrastructure and processor-specific drivers, QEMU
also provides an architecture-specific userspace program for managing VM Guests. Depending
on the architecture this program is one of:
qemu-system-i386
qemu-system-s390x
qemu-system-x86_64
In the following this command is called qemu-system-ARCH ; in examples the qemu-system-x86_64 command is used.
219
QEMU Overview
Tip: Resources
In general, the virtual guest system needs the same hardware resources as SUSE Linux
Enterprise Server installed on a physical machine. The more guests you plan to run on
the host system, the more hardware resourcesCPU, disk, memory, and networkyou
need to add.
To find out whether your system supports virtualization, see Section7.3, KVM Hardware Requirements.
1. Run YaST
220
2. Select KVM server and preferably also KVM tools, and confirm with Accept.
3. During the installation process, you can optionally let YaST create a Network Bridge for
you automatically. If you do not plan to dedicate an additional physical network card to
your virtual guests, network bridge is a standard way to connect the guest machines to
the network.
FIGURE27.2:NETWORK BRIDGE
221
Required Software
4. After all the required packages are installed (and new network setup activated), try to
load the KVM kernel module relevant for your CPU type kvm-intel or kvm-amd :
root # modprobe kvm-intel
64835
411041
6
1 kvm_intel
Now the KVM host is ready for serving KVM VM Guests. For more information, see Chapter29, Running Virtual Machines with qemu-system-ARCH.
niques to make the guests access the physical host's hardware directlywithout the emulation
layerto make the most use of it.
Tip
Examples included in this section assume basic knowledge of the qemu-system-ARCH
command line options. For more information, see Chapter29, Running Virtual Machines with
qemu-system-ARCH.
222
27.3.1
virtio-scsi is an advanced storage stack for KVM. It replaces the former virtio-blk stack
KVM guests have a limited number of PCI controllers which results in a limited number
of possibly attached devices. virtio-scsi solves this limitation by grouping multiple
storage devices on a single controller. Each device on a virtio-scsi controller is represented as a logical unit, or LUN.
Standard command set
While virtio-blk uses a small set of commands which has to be known to both the
virtio-blk driver and the virtual machine monitor. To introduce a new command means
However, virtio-scsi does not define commands, but a transport protocol for these
virtio-scsi keeps the device names identical to those on physical systems, making the
For virtual disks backed by a whole LUN on the host, it is preferable for the guest to send
SCSI commands directly to the LUN (pass-through). This is limited in virtio-blk , as
guests need to use the virtio-blk protocol instead of SCSI command pass-through, and,
moreover, it is not available for Windows guests. virtio-scsi natively removes these
limitations.
27.3.1.1
virtio-scsi Usage
223
27.3.2
The vhost-net module is used to accelerate KVM's paravirtualized network drivers. It provides
better latency and greater throughput for network. Use the vhost-net driver by starting the
guest with the following example command line:
qemu-system-x86_64 [...] \
-netdev tap,id=guest0,vhost=on,script=no \
-net nic,model=virtio,netdev=guest0,macaddr=00:16:35:AF:94:4B
allowing VM Guest virtual CPUs to transfer packets in parallel. Multiqueue support is required
on both VM Host Server and VM Guest side.
systems, or between the guest and the host, or between the guest and an external
system.
The number of active queues is equal to the number of virtual CPUs in the VM Guest.
Note
While multiqueue virtio-net increases the total network throughput, it increases CPU
consumption as it uses of the virtual CPU's power.
224
The following procedure lists important steps to enable the multiqueue feature with qe-
mu-system-ARCH . It assumes that a tap network device with multiqueue capability (sup-
-device virtio-net-pci,mq=on,vectors=2*N+2
where the formula for the number of MSI-X vectors results from: N vectors for TX (transmit) queues, N for RX (receive) queues, one for configuration purposes, and one for possible VQ (vector quantization) control.
3. In VM Guest, enable multiqueue on the relevant network interface ( eth0 in this example):
ethtool -L eth0 combined 2*N
The resulting qemu-system-ARCH command line will look similar to the following example:
qemu-system-x86_64 [...] -netdev tap,id=guest0,queues=4,vhost=on \
-device virtio-net-pci,netdev=guest0,mq=on,vectors=10
Note that the id of the network device ( guest0 ) needs to be identical for both options.
Inside the running VM Guest, specify the following command as root :
ethtool -L eth0 combined 8
Now the guest system networking uses the multiqueue support from the qemu-system-ARCH
hypervisor.
225
27.3.4
Directly assigning a PCI device to a VM Guest (PCI pass-through) avoids performance issues
caused by avoiding any emulation in performance critical paths. VFIO replaces the traditional
KVM PCI Pass-Through device assignment. Prerequisite for this feature is a VM Host Server
configuration described in Important: Requirements for VFIO and SR-IOV.
To be able to assign a PCI device via VFIO to a VM Guest, you need to find out which IOMMU
Group it belongs to. The IOMMU (input/output memory management unit that connects a direct
memory access-capable I/O bus to the main memory) API supports the notion of groups. A
group is a set of devices that can be isolated from all other devices in the system. Groups are
therefore the unit of ownership used by VFIO.
Note down the device ID ( 00:10.0 in this case) and the vendor ID ( 8086:10ca ).
2. Find the IOMMU group of this device:
tux > sudo readlink /sys/bus/pci/devices/0000\:00\:10.0/iommu_group
../../../kernel/iommu_groups/20
The IOMMU group for this device is 20 .Now you can check the devices belonging to the
same IOMMU group:
ls -l /sys/bus/pci/devices/0000:01:10.0/iommu_group/devices/0000:01:10.0
[...] 0000:00:1e.0 -> ../../../../devices/pci0000:00/0000:00:1e.0
[...] 0000:01:10.0 -> ../../../../devices/pci0000:00/0000:00:1e.0/0000:01:10.0
[...] 0000:01:10.1 -> ../../../../devices/pci0000:00/0000:00:1e.0/0000:01:10.1
226
4. Bind the device to the vfio-pci driver using the vendor ID from step 1:
sudo echo "8086 153a" > /sys/bus/pci/drivers/vfio-pci/new_id
Important: No Hot-plugging
As of openSUSE Leap 42.1 hot-plugging of PCI devices passed to a VM Guest via VFIO
is not supported.
You can find more detailed information on the VFIO driver in the /usr/src/linux/Documentation/vfio.txt file (package kernel-source has to be installed).
27.3.5
USB Pass-Through
To assign an existing host USB device to a VM Guest, you need to find out its host bus and
device ID.
tux@vmhost:~> lsusb
[...]
Bus 002 Device 005: ID 12d1:1406 Huawei Technologies Co., Ltd. E1750
[...]
227
USB Pass-Through
In the above example, we want to assign a USB stick connected to the host's USB bus number 2
with device number 5. Now run the VM Guest with the following additional options:
qemu-system-x86_64 [...] -usb -device usb-host,hostbus=2,hostaddr=5
After the guest is booted, check that the assigned USB device is present on it.
tux@vmguest:~> lsusb
[...]
Bus 001 Device 002: ID 12d1:1406 Huawei Technologies Co., Ltd. E1750
[...]
Note
The guest operating system must take care of mounting the assigned USB device so that
it is accessible for the user.
27.3.6
PCI Pass-Through is a technique to give your VM Guest exclusive access to a VM Host Server PCI
device. Prerequisite for this feature is a VM Host Server configuration described in Important:
Requirements for VFIO and SR-IOV. Assigning graphics cards is not supported by SUSE.
though it is still supported by SUSE, it is recommended to use VFIO for assigning PCI
devices as described in Section27.3.4, VFIO: Secure Direct Access to Devices. vt.io.vfio
PROCEDURE27.3:CONFIGURING PCI PASS-THROUGH (DEPRECATED)
228
hot-remove:
device_del new_pci_device
27.3.7
VM Guests usually run in a separate computing spacethey are provided their own memory
range, dedicated CPUs, and file system space. The ability to share parts of the VM Host Server's
file system makes the virtualization environment more flexible by simplifying mutual data ex-
change. Network file systems, such as CIFS and NFS, have been the traditional way of sharing
directories. But as they are not specifically designed for virtualization purposes, they suffer from
major performance and feature issues.
229
KVM introduces a new optimized method called VirtFS (sometimes called file system pass-
through). VirtFS uses a paravirtual file system driver, which avoids converting the guest appli-
cation file system operations into block device operations, and then again into host file system
operations.
To replace the virtual disk as the root file system to which the guest's RAM disk connects
during the guest boot process.
To provide storage services to different customers from a single host file system in a cloud
environment.
27.3.7.1
Implementation
fsdev device which defines the export file system properties, such as file system type
,path=/tmp/
-device virtio-9p-pci,fsdev=exp1
,security_model=mapped
,mount_tag=v_tmp
Security model to be used mapped keeps the guest file system modes and permissions isolated from the host, while none invokes a pass-through security model in
which permission changes on the guest's files are reflected on the host as well.
230
Mount tag used later on the guest to mount the exported file system.
Such an exported file system can be mounted on the guest like this
sudo mount -t 9p -o trans=virtio v_tmp /mnt
where v_tmp is the mount tag defined earlier with -device mount_tag= and /mnt is
the mount point where you want to mount the exported file system.
27.3.8
Kernel SamePage Merging (KSM) is a Linux Kernel feature that merges identical memory pages
from multiple running processes into one memory region. Because KVM guests run as processes
under Linux, KSM provides the memory overcommit feature to hypervisors for more efficient
use of memory. Therefore, if you need to run multiple virtual machines on a host with limited
memory, KSM may be helpful to you.
KSM stores its status information in the files under the /sys/kernel/mm/ksm directory:
tux > ls -1 /sys/kernel/mm/ksm
full_scans
merge_across_nodes
pages_shared
pages_sharing
pages_to_scan
pages_unshared
pages_volatile
run
sleep_millisecs
For more information on the meaning of the /sys/kernel/mm/ksm/* files, see /usr/src/
linux/Documentation/vm/ksm.txt (package kernel-source ).
231
2. Now run several VM Guests under KVM and inspect the content of files pages_sharing
232
28 Guest Installation
The libvirt -based tools such as virt-manager , virt-install , or vm-install offer con-
venient interfaces to set up and manage virtual machines. They act as a kind of wrapper for the
qemu-system-ARCH command. However, it is also possible to use qemu-system-ARCH directly
tools.
If you do not already have an image of a system that you want to run in a virtualized environ-
ment, you need to create one from the installation media. In such case, you need to prepare a
hard disk image, and obtain an image of the installation media or the media itself.
Create a hard disk with qemu-img .
qemu-img create
-f raw
/images/sles/hda
8G
The size of the image8 GB in this case. The image is created as a Sparse image file file
that grows when the disk is filled with data. The specified size defines the maximum size
to which the image file can grow.
After at least one hard disk image is created, you can set up a virtual machine with qemu-system-ARCH that will boot into the installation system:
qemu-system-x86_64 -name "sles"
-smp 2
233
-boot d
-machine accel=kvm -M pc
-m 768
Guest Installation
-drive file=/images/sles/hda,if=virtio,index=0,media=disk,format=raw
-drive file=/isos/SLES-11-SP3-DVD-x86_64-GM-DVD1.iso,index=1,media=cdrom
-net nic,model=virtio,macaddr=52:54:00:05:11:11
-vga cirrus
-balloon virtio
-net user\
10
Name of the virtual machine that will be displayed in the window caption and be used for
the VNC server. This name must be unique.
Specifies the machine type. Use qemu-system-ARCH -M ? to display a list of valid parameters. pc is the default Standard PC.
Specifies the boot order. Valid values are a , b (floppy 1 and 2), c (first hard disk), d
(first CD-ROM), or n to p (Ether-boot from network adapter 1-3). Defaults to c .
Defines the first ( index=0 ) hard disk. It will be accessed as a paravirtualized ( if=virtio )
drive in raw format.
Specifies the graphic card. If you specify none , the graphic card will be disabled.
10
Defines the paravirtualized balloon device that allows to dynamically change the amount
of memory (up to the maximum value specified with the parameter -m ).
After the installation of the guest operating system finishes, you can easily start the related
virtual machine without the need to specify the CD-ROM device:
234
general disk image manipulation. This section introduces useful qemu-img subcommands to
help manage the disk images flexibly.
28.2.1
qemu-img uses subcommands (like zypper does) to do specific tasks. Each subcommand un-
derstands a different set of options. Some options are general and used by more of these subcommands, while some are unique to the related subcommand. See the qemu-img manual page ( man
1 qemu-img ) for a list of all supported options. qemu-img uses the following general syntax:
qemu-img subcommand [options]
check
compare
map
Dumps the metadata of the image file name and its backing file chain.
amend
Amends the image format specific options for the image file name.
convert
info
snapshot
235
commit
rebase
resize
28.2.2
This section describes how to create disk images, check their condition, convert a disk image
from one format to another, and get detailed information about a particular disk image.
28.2.2.1
qemu-img create
Use qemu-img create to create a new disk image for your VM Guest operating system. The
command uses the following syntax:
qemu-img create -f fmt
-o options
fname
size
The format of the target image. Supported formats are qed , qcow2 , and raw .
Some image formats support additional options to be passed on the command line. You
can specify them here with the -o option. The raw image format supports only the size
option, so it is possible to insert -o size=8G instead of adding the size option at the end
of the command.
3
Size of the target disk image (if not already specified with the -o size=<image_size>
option. Optional suffixes for the image size are K (kilobyte), M (megabyte), G (gigabyte),
or T (terabyte).
To create a new disk image sles.raw in the directory /images growing up to a maximum
size of 4 GB, run the following command:
236
As you can see, the virtual size of the newly created image is 4 GB, but the actual reported disk
size is 0 as no data has been written to the image yet.
If you, however, want to use copy-on-write (for example for creating snapshots or sharing
them across virtual machines), then leave the command line without the nocow option.
28.2.2.2
qemu-img convert
Use qemu-img convert to convert disk images to another format. To get a complete list of
image formats supported by QEMU, run qemu-img -h and look at the last line of the output.
The command uses the following syntax:
qemu-img convert -c
-f fmt
-O out_fmt
-o options
fname
out_fname
Applies compression on the target disk image. Only qcow and qcow2 formats support
compression.
The format of the source disk image. It is usually autodetected and can therefore be omitted.
Specify additional options relevant for the target image format. Use -o ? to view the list
of options supported by the target image format.
237
To see a list of options relevant for the selected target image format, run the following command
(replace vmdk with your image format):
backing_file
compat6
subformat
28.2.2.3
SCSI image
qemu-img check
Use qemu-img check to check the existing disk image for errors. Not all disk image formats
support this feature. The command uses the following syntax:
qemu-img check -f fmt
fname
The format of the source disk image. It is usually autodetected and can therefore be omitted.
If no error is found, the command returns no output. Otherwise, the type and number of errors
found is shown.
238
28.2.2.4
When creating a new image, you must specify its maximum size before the image is created
(see Section28.2.2.1, qemu-img create). After you have installed the VM Guest and have been
using it for some time, the initial size of the image may no longer be sufficient and you may
need to add more space to it.
Note
You can resize the disk image using the formats raw , qcow2 and qed . To resize an image
in another format, convert it to a supported format with qemu-img convert first.
The image now contains an empty space of 2 GB after the final partition. You can resize the
existing partitions or add new ones.
239
running. The snapshot includes the state of the processor (CPU), memory (RAM), devices, and
all writable disks.
Snapshots are helpful when you need to save your virtual machine in a particular state. For
example, after you configured network services on a virtualized server and want to quickly
start the virtual machine in the same state you last saved it. Or you can create a snapshot after
the virtual machine has been powered off to create a backup state before you try something
experimental and possibly make VM Guest unstable. This section introduces the latter case,
while the former is described in Chapter30, Virtual Machine Administration Using QEMU Monitor.
To use snapshots, your VM Guest must contain at least one writable hard disk image in qcow2
format. This device is usually the first virtual hard disk.
Virtual Machine snapshots are created with the savevm command in the interactive QEMU mon-
itor. To make identifying a particular snapshot easier, you can assign it a tag. For more information on QEMU monitor, see Chapter30, Virtual Machine Administration Using QEMU Monitor.
240
Once your qcow2 disk image contains saved snapshots, you can inspect them with the qemu-img
snapshot command.
mand while the virtual machine is running. Otherwise, you may damage the disk image
with the state of the virtual machine saved.
28.2.3.1
Use qemu-img snapshot -l disk_image to view a list of all existing snapshots saved in the
disk_image image. You can get the list even while the VM Guest is running.
tux > qemu-img snapshot -l /images/sles.qcow2
Snapshot list:
ID
TAG
VM SIZE
DATE
VM CLOCK
booting
00:00:20.476
booted
00:02:05.394
logged_in
00:04:34.843
ff_and_term_running
00:08:44.965
Unique description string of the snapshot. It is meant as a human-readable version of the ID.
The disk space occupied by the snapshot. Note that the more memory is consumed by
running applications, the bigger the snapshot is.
28.2.3.2
241
TAG
VM SIZE
DATE
VM CLOCK
booting
00:00:20.476
booted
00:02:05.394
logged_in
00:04:34.843
ff_and_term_running
00:08:44.965
backup_snapshot
0 2013-11-22 14:14:00
00:00:00.000
If something breaks in your VM Guest and you need to restore the state of the saved snapshot
(ID 5 in our example), power off your VM Guest and execute the following command:
tux > qemu-img snapshot -a 5 /images/sles.qcow2
The next time you run the virtual machine with qemu-system-ARCH , it will be in the state of
snapshot number 5.
Note
The qemu-img snapshot -c command is not related to the savevm command of QEMU
monitor (see Chapter30, Virtual Machine Administration Using QEMU Monitor). For example,
you cannot apply a snapshot with qemu-img snapshot -a on a snapshot created with
savevm in QEMU's monitor.
28.2.3.3
Deleting Snapshots
242
28.2.4
Imagine the following real-life situation: you are a server administrator who runs and manages
several virtualized operating systems. One group of these systems is based on one specific dis-
tribution, while another group (or groups) is based on different versions of the distribution or
even on a different (and maybe non-Unix) platform. And to make the case even more complex,
individual virtual guest systems based on the same distribution usually differ according to the
department and deployment: a file server typically uses a different setup and services than a
Web server does, while both may still be based on SUSE Linux Enterprise Server.
With QEMU it is possible to create base disk images. You can use them as template virtual
machines. These base images will save you plenty of time because you will never need to install
the same operating system more than once.
28.2.4.1
First, build a disk image as usual and install the target system on it. For more information, see
Section28.1, Basic Installation with qemu-system-ARCH and Section28.2.2, Creating, Converting and
Checking Disk Images. Then build a new image while using the first one as a base image. The base
image is also called a backing file. After your new derived image is built, never boot the base
image again, but boot the derived image instead. Several derived images may depend on one
base image at the same time. Therefore, changing the base image can damage the dependencies.
While using your derived image, QEMU writes changes to it and uses the base image only for
reading.
It is a good practice to create a base image from a freshly installed (and, if needed, registered)
operating system with no patches applied and no additional applications installed or removed.
Later on, you can create another base image with the latest patches applied and based on the
original base image.
28.2.4.2
Note
While you can use the raw format for base images, you cannot use it for derived images
because the raw format does not support the backing_file option. Use for example
the qcow2 format for the derived images.
243
For example, /images/sles_base.raw is the base image holding a freshly installed system.
tux > qemu-img info /images/sles_base.raw
image: /images/sles_base.raw
file format: raw
virtual size: 4.0G (4294967296 bytes)
disk size: 2.4G
The image's reserved size is 4 GB, the actual size is 2.4 GB, and its format is raw . Create an
image derived from the /images/sles_base.raw base image with:
tux > qemu-img create -f qcow2 /images/sles_derived.qcow2 \
-o backing_file=/images/sles_base.raw
Formatting '/images/sles_derived.qcow2', fmt=qcow2 size=4294967296 \
backing_file='/images/sles_base.raw' encryption=off cluster_size=0
Although the reserved size of the derived image is the same as the size of the base image (4
GB), the actual size is 140 KB only. The reason is that only changes made to the system inside
the derived image are saved. Run the derived virtual machine, register it, if needed, and apply
the latest patches. Do any other changes in the system such as removing unneeded or installing
new software packages. Then shut the VM Guest down and examine its details once more:
tux > qemu-img info /images/sles_derived.qcow2
image: /images/sles_derived.qcow2
file format: qcow2
virtual size: 4.0G (4294967296 bytes)
244
The disk size value has grown to 1.1 GB, which is the disk space occupied by the changes
on the file system compared to the base image.
28.2.4.3
After you have modified the derived image (applied patches, installed specific applications,
changed environment settings, etc.), it reaches the desired state. At that point, you may want
to merge the original base image and the derived image to create a new base image.
Your original base image ( /images/sles_base.raw ) holds a freshly installed system and can
be a template for new modified base images, while the new one can contain the same system as
the first one plus all security and update patches applied, for example. After you have created
this new base image, you can use it as a template for more specialized derived images as well.
The new base image becomes independent of the original one. The process of creating base
images from derived ones is called rebasing:
This command created the new base image /images/sles_base2.raw using the raw format.
tux > qemu-img info /images/sles_base2.raw
image: /images/sles11_base2.raw
file format: raw
virtual size: 4.0G (4294967296 bytes)
disk size: 2.8G
The new image is 0.4 gigabytes bigger than the original base image. It uses no backing file, and
you can easily create new derived images based upon it. This lets you create a sophisticated
hierarchy of virtual disk images for your organization, saving a lot of time and work.
245
28.2.4.4
Sometimes it is useful to mount a virtual disk image under the host system. It is strongly recommended to read Chapter17, libguestfs and use dedicated tools to access a virtual machine image.
But if for some reason you need to do it manually, just follow this guide.
Linux systems can mount an internal partition of a raw disk image using a loopback device.
The first example procedure is more complex but more illustrative, while the second one is
straightforward:
1. Set a loop device on the disk image whose partition you want to mount.
tux > losetup /dev/loop0 /images/sles_base.raw
2. Find the sector size and the starting sector number of the partition you want to mount.
tux > fdisk -lu /dev/loop0
bytes
Device Boot
Start
/dev/loop0p1
/dev/loop0p2
63
*
1542240
End
1542239
8385929
Blocks
771088+
3421845
Id
82
System
Linux swap
83
Linux
4. Delete the loop and mount the partition inside the disk image with the calculated offset
on a prepared directory.
246
/images/sles_base.raw /mnt/sles/
tux > ls -l /mnt/sles/
total 112
drwxr-xr-x
2 root root
drwxr-xr-x
3 root root
drwxr-xr-x
5 root root
drwxrwxrwt
14 root root
drwxr-xr-x
12 root root
drwxr-xr-x
15 root root
[...]
5. Copy one or more files onto the mounted partition and unmount it when finished.
tux > cp /etc/X11/xorg.conf /mnt/sles/root/tmp
tux > ls -l /mnt/sles/root/tmp
tux > umount /mnt/sles/
247
Managing Disk Images with qemu-img), it is time to start the related virtual machine. Section28.1,
Basic Installation with qemu-system-ARCH introduced simple commands to install and run a VM
Guest. This chapter focuses on a more detailed explanation of qemu-system-ARCH usage, and
shows solutions for more specific tasks. For a complete list of qemu-system-ARCH 's options, see
its manual page ( man 1 qemu ).
disk_img
emulated hardware, while others affect more general emulator behavior. If you do not
supply any options, default values are used, and you need to supply the path to a disk
image to be run.
2
Path to the disk image holding the guest system you want to virtualize. qemu-system-ARCH
supports many image formats. Use qemu-img --help to list them. If you do not supply the
path to a disk image as a separate argument, you need to use the -drive file= option.
emulated hardware, such as the virtual machine's processor, memory, model type, or time processing methods.
-name name_of_guest
Specifies the name of the running guest system. The name is displayed in the window
caption and used for the VNC server.
248
-boot options
Specifies the order in which the defined drives will be booted. Drives are represented by
letters, where a and b stand for the floppy drives 1 and 2, c stands for the first hard disk,
d stands for the first CD-ROM drive, and n to p stand for Ether-boot network adapters.
For example, qemu-system-ARCH [...] -boot order=ndc first tries to boot from network, then from the first CD-ROM drive, and finally from the first hard disk.
-pidfile fname
Stores the QEMU's process identification number (PID) in a file. This is useful if you run
QEMU from a script.
-nodefaults
By default QEMU creates basic virtual devices even if you do not specify them on the
command line. This option turns this feature off, and you must specify every single device
manually, including graphical and network cards, parallel or serial ports, or virtual consoles. Even QEMU monitor is not attached by default.
-daemonize
Daemonizes the QEMU process after it is started. QEMU will detach from the standard
input and standard output after it is ready to receive connections on any of its devices.
29.2.1
29.2.1.1
Machine Type
You can specifies the type of the emulated machine. Run qemu-system-ARCH -M help to view
a list of supported machine types.
249
pc-i440fx-2.3
pc-i440fx-2.2
pc-i440fx-2.1
pc-i440fx-2.0
pc-i440fx-1.7
pc-i440fx-1.6
pc-i440fx-1.5
pc-i440fx-1.4
pc-1.3
pc-1.2
pc-1.1
pc-1.0
pc-0.15
pc-0.14
pc-0.13
pc-0.12
pc-0.11
pc-0.10
q35
pc-q35-2.3
pc-q35-2.2
pc-q35-2.1
pc-q35-2.0
pc-q35-1.7
pc-q35-1.6
pc-q35-1.5
pc-q35-1.4
isapc
ISA-only PC
none
empty machine
xenfv
Xen Fully-virtualized PC
xenpv
Xen Para-virtualized PC
250
Note: ISA-PC
The machine type isapc: ISA-only-PC is unsupported.
29.2.1.2
CPU Model
To specify the type of the processor (CPU) model, run qemu-system-ARCH -cpu MODEL . Use
qemu-system-ARCH -cpu help to view a list of supported CPU models.
x86
qemu64
x86
phenom
x86
core2duo
x86
kvm64
x86
qemu32
x86
kvm32
x86
coreduo
x86
486
x86
pentium
x86
pentium2
x86
pentium3
x86
athlon
x86
n270
x86
Conroe
x86
Penryn
x86
Nehalem
x86
Westmere
x86
SandyBridge
x86
IvyBridge
x86
Haswell-noTSX
x86
Haswell
x86
Broadwell-noTSX
x86
Broadwell
x86
Opteron_G1
x86
Opteron_G2
x86
Opteron_G3
x86
Opteron_G4
251
T7700
@ 2.40GHz
T2600
@ 2.16GHz
@ 1.60GHz
x86
Opteron_G5
x86
host
in KVM mode)
29.2.1.3
The following is a list of most commonly used options while launching qemu from command
line. To see all options available refer to qemu-doc man page.
-m megabytes
Specifies how many megabytes are used for the virtual RAM size.
-balloon virtio
Specifies a paravirtualized device to dynamically change the amount of virtual RAM memory assigned to VM Guest. The top limit is the amount of memory specified with -m .
252
-smp number_of_cpus
Specifies how many CPUs will be emulated. QEMU supports up to 255 CPUs on the PC
platform (up to 64 with KVM acceleration used). This option also takes other CPU-related
parameters, such as number of sockets, number of cores per socket, or number of threads
per core.
-no-acpi
-S
QEMU starts with CPU stopped. To start CPU, enter c in QEMU monitor. For more information, see Chapter30, Virtual Machine Administration Using QEMU Monitor.
253
29.2.2
-readconfig cfg_file
Instead of entering the devices configuration options on the command line each time you
want to run VM Guest, qemu-system-ARCH can read it from a file that was either previously saved with -writeconfig or edited manually.
-writeconfig cfg_file
Dumps the current virtual machine's devices configuration to a text file. It can be consequently re-used with the -readconfig option.
tux > qemu-system-x86_64 -name "SLES 11 SP3" -machine accel=kvm -M pci440fx-2.3 -m 512 -cpu kvm64 \
-smp 2 /images/sles.raw -writeconfig /images/sles.cfg
(exited)
tux > more /images/sles.cfg
# qemu config file
[drive]
index = "0"
media = "disk"
file = "/images/sles_base.raw"
This way you can effectively manage the configuration of your virtual machines' devices
in a well-arranged way.
29.2.3
-rtc options
Specifies the way the RTC is handled inside a VM Guest. By default, the clock of the guest
is derived from that of the host system. Therefore, it is recommended that the host system
clock is synchronized with an accurate external clock (for example, via NTP service).
If you need to isolate the VM Guest clock from the host one, specify clock=vm instead
of the default clock=host .
You can also specify the initial time of the VM Guest's clock with the base option:
qemu-system-x86_64 [...] -rtc clock=vm,base=2010-12-03T01:02:00
254
Instead of a time stamp, you can specify utc or localtime . The former instructs
VM Guest to start at the current UTC value (Coordinated Universal Time, see http://
en.wikipedia.org/wiki/UTC), while the latter applies the local time setting.
Tip
If your device, such as -drive , needs a special driver and driver properties to be set,
specify them with the -device option, and identify with drive= suboption. For example:
To get help on available drivers and their properties, use -device ? and -device driver,? .
29.3.1
Block Devices
Block devices are vital for virtual machines. In general, these are fixed or removable storage
media usually called drives. One of the connected hard disks typically holds the guest operating
system to be virtualized.
Virtual Machine drives are defined with -drive . This option uses many sub-options, some are
described in this section. For their complete list, see the manual page ( man 1 qemu ).
SUB-OPTIONS FOR THE -drive OPTION
file=image_fname
Specifies the path to the disk image that will be used with this drive. If not specified, an
empty (removable) drive is assumed.
255
if=drive_interface
Specifies the type of interface to which the drive is connected. Currently only floppy ,
scsi , ide , or virtio are supported by SUSE. virtio defines a paravirtualized disk
index=index_of_connector
Specifies the index number of a connector on the disk interface (see the if option) where
the drive is connected. If not specified, the index is automatically incremented.
media=type
Specifies the type of media. Can be disk for hard disks, or cdrom for removable CDROM drives.
format=img_fmt
Specifies the format of the connected disk image. If not specified, the format is autodetected. Currently, SUSE supports qcow2 , qed and raw formats.
cache=method
Specifies the caching method for the drive. Possible values are unsafe , writethrough ,
writeback , directsync , or none . For the qcow2 image format, choose writeback if
you care about performance. none disables the host page cache and, therefore, is the
safest option. Default for image files is writeback . For more information, see Chapter15,
Disk Cache Modes.
Tip
To simplify defining block devices, QEMU understands several shortcuts which you may
find handy when entering the qemu-system-ARCH command line.
You can use
qemu-system-x86_64 -cdrom /images/cdrom.iso
instead of
qemu-system-x86_64 -drive file=/images/cdrom.iso,index=2,media=cdrom
and
qemu-system-x86_64 -hda /images/imagei1.raw -hdb /images/image2.raw -hdc \
256
Block Devices
instead of
qemu-system-x86_64 -drive file=/images/image1.raw,index=0,media=disk \
-drive file=/images/image2.raw,index=1,media=disk \
-drive file=/images/image3.raw,index=2,media=disk \
-drive file=/images/image4.raw,index=3,media=disk
mu-img) you can also use existing VM Host Server disks, connect them as drives, and
access them from VM Guest. Use the host disk device directly instead of disk image file
names.
A host drive used by a VM Guest must not be accessed concurrently by the VM Host
Server or another VM Guest.
29.3.1.1
A Sparse image file is a type of disk image file that grows in size as the user adds data to it, taking
up only as much disk space as is stored in it. For example, if you copy 1 GB of data inside the
sparse disk image, its size grows by 1 GB. If you then delete for example 500 MB of the data,
the image size does not by default decrease as expected.
257
Block Devices
That is why the discard=on option is introduced on the KVM command line. It tells the hy-
pervisor to automatically free the holes after deleting data from the sparse guest image. Note
that this option is valid only for the if=scsi drive interface:
29.3.1.2
virtio-blk-data-plane
The virtio-blk-data-plane is a new feature for KVM. It enables a high-performance code path for I/
O requests coming from VM Guests. More specifically, this feature introduces dedicated threads
(one per virtual block device) to process I/O requests going through the virtio-blk driver. It uses
the Linux AIO (asynchronous I/O) interface of the VM Host Server kernel directlywithout
the need to go through the QEMU block layer. Therefore, it can sustain very high I/O rates on
storage setups.
258
Block Devices
29.3.1.3
For better performance of I/O-intensive applications, a new I/O path was introduced for the
virtio-blk interface in kernel version 3.7. This bio-based block device driver skips the I/O scheduler, and thus shortens the I/O path in guest and has lower latency. It is especially useful for
high-speed storage devices, such as SSD disks.
You can do it also by editing /etc/default/grub , searching for the line that contains
reason is that the benefit of scheduling is larger than what the shortened bio path offers.
Do not use the bio-based driver on slow devices.
29.3.2
This section describes QEMU options affecting the type of the emulated video card and the way
VM Guest graphical output is displayed.
259
29.3.2.1
QEMU uses -vga to define a video card used to display VM Guest graphical output. The -vga
option understands the following values:
none
Disables video cards on VM Guest (no video card is emulated). You can still access the
running VM Guest via the serial console.
std
Emulates a standard VESA 2.0 VBE video card. Use it if you intend to use high display
resolution on VM Guest.
cirrus
Emulates Cirrus Logic GD5446 video card. Good choice if you insist on high compatibility
of the emulated video hardware. Most operating systems (even Windows 95) recognize
this type of card.
Tip
For best video performance with the cirrus type, use 16-bit color depth both on
VM Guest and VM Host Server.
29.3.2.2
Display Options
The following options affect the way VM Guest graphical output is displayed.
-display gtk
Display video output in a GTK window. This interface provides drop-down menus and
other UI elements to configure and control the VM during runtime.
-display sdl
Display video output via SDL (usually in a separate graphics window; see the SDL documentation for other possibilities).
-spice option[,option[,...]]
-display vnc
260
-nographic
Disables QEMU's graphical output. The emulated serial port is redirected to the console.
After starting the virtual machine with -nographic , press
Ctrl
in the virtual
console to view the list of other useful shortcuts, for example, to toggle between the console
and the QEMU monitor.
C-a h
C-a x
exit emulator
C-a s
C-a t
C-a b
C-a c
C-a C-a
sends C-a
(pressed C-a c)
-no-frame
Disables decorations for the QEMU window. Convenient for dedicated desktop work space.
-full-screen
-no-quit
Disables the close button of the QEMU window and prevents it from being closed by force.
-alt-grab, -ctrl-grab
261
Ctrl
Ctrl
Right Ctrl
29.3.3
USB Devices
There are two ways to create USB devices usable by the VM Guest in KVM: you can either
emulate new USB devices inside a VM Guest, or assign an existing host USB device to a VM
Guest. To use USB devices in QEMU you first need to enable the generic USB driver with the usb option. Then you can specify individual devices with the -usbdevice option.
29.3.3.1
SUSE currently supports the following types of USB devices: disk , host , serial , braille ,
net , mouse , and tablet .
disk
Emulates a mass storage device based on file. The optional format option is used rather
than detecting the format.
host
serial
braille
net
Emulates a network adapter that supports CDC Ethernet and RNDIS protocols.
mouse
Emulates a virtual USB mouse. This option overrides the default PS/2 mouse emulation.
The following example shows the hardware status of a mouse on VM Guest started with
qemu-system-ARCH [...] -usbdevice mouse :
tux > sudo hwinfo --mouse
20: USB 00.0: 10503 USB Mouse
262
USB Devices
[Created at usb.122]
UDI: /org/freedesktop/Hal/devices/usb_device_627_1_1_if0
[...]
Hardware Class: mouse
Model: "Adomax QEMU USB Mouse"
Hotplug: USB
Vendor: usb 0x0627 "Adomax Technology Co., Ltd"
Device: usb 0x0001 "QEMU USB Mouse"
[...]
tablet
Emulates a pointer device that uses absolute coordinates (such as touchscreen). This option
overrides the default PS/2 mouse emulation. The tablet device is useful if you are viewing
VM Guest via the VNC protocol. See Section29.5, Viewing a VM Guest withVNC for more
information.
29.3.4
Character Devices
Use -chardev to create a new character device. The option uses the following general syntax:
qemu-system-x86_64 [...] -chardev backend_type,id=id_string
where backend_type can be one of null , socket , udp , msmouse , vc , file , pipe , con-
sole , serial , pty , stdio , braille , tty , or parport . All character devices must have a
unique identification string up to 127 characters long. It is used to identify the device in other
related directives. For the complete description of all back-end's sub-options, see the manual
page ( man 1 qemu ). A brief description of the available back-ends follows:
null
Creates an empty device that outputs no data and drops any data it receives.
stdio
socket
263
Character Devices
socket,id=unix_socket1,path=/tmp/unix_socket1,server
The command creates a local listening ( server ) TCP socket on port 7777. QEMU will not
block waiting for a client to connect to the listening port ( nowait ).
udp
Sends all network traffic from VM Guest to a remote host over the UDP protocol.
qemu-system-x86_64 [...] -chardev
udp,id=udp_fwd,host=mercury.example.com,port=7777
The command binds port 7777 on the remote host mercury.example.com and sends VM
Guest network traffic there.
vc
Creates a new QEMU text console. You can optionally specify the dimensions of the virtual
console:
The command creates a new virtual console called vc1 of the specified size, and connects
the QEMU monitor to it.
file
Logs all traffic from VM Guest to a file on VM Host Server. The path is required and will
be created if it does not exist.
264
Character Devices
By default QEMU creates a set of character devices for serial and parallel ports, and a special
console for QEMU monitor. You can, however, create your own character devices and use them
for the just mentioned purposes. The following options will help you:
-serial char_dev
Redirects the VM Guest's virtual serial port to a character device char_dev on VM Host
Server. By default, it is a virtual console ( vc ) in graphical mode, and stdio in nongraphical mode. The -serial understands many sub-options. See the manual page man
1 qemu for a complete list of them.
You can emulate up to 4 serial ports. Use -serial none to disable all serial ports.
-parallel device
Redirects the VM Guest's parallel port to a device . This option supports the same devices
as -serial .
Tip
With SUSE Linux Enterprise Server as a VM Host Server, you can directly use the
hardware parallel port devices /dev/parportN where N is the number of the port.
You can emulate up to 3 parallel ports. Use -parallel none to disable all parallel ports.
-monitor char_dev
Redirects the QEMU monitor to a character device char_dev on VM Host Server. This
option supports the same devices as -serial . By default, it is a virtual console ( vc ) in
a graphical mode, and stdio in non-graphical mode.
For a complete list of available character devices back-ends, see the man page ( man 1 qemu ).
Currently, SUSE supports the following network types: user , bridge , and tap . For a complete
list of -netdev sub-options, see the manual page ( man 1 qemu ).
265
Networking in QEMU
bridge
Uses a specified network helper to configure the TAP interface and attach it to a specified
bridge. For more information, see Section29.4.3, Bridged Networking.
user
Specifies user-mode networking. For more information, see Section29.4.2, User-Mode Networking.
tap
Specifies bridged or routed networking. For more information, see Section29.4.3, Bridged
Networking.
29.4.1
Use -netdev together with the related -device option to add a new emulated network card:
qemu-system-x86_64 [...] \
-netdev tap
,id=hostnet0 \
-device virtio-netpci
,netdev=hostnet0,vlan=1
Specifies the model of the network card. Use -device help and search for the Network
,macaddr=00:16:35:AF:94:4B
,name=ncard1
devices: section to get the list of all network card models supported by QEMU on your
platform:
266
Currently, SUSE supports the models rtl8139 , e1000 and its variants e1000-82540em ,
Connects the network interface to VLAN number 1. You can specify your own number
it is mainly useful for identification purpose. If you omit this suboption, QEMU uses the
default 0.
Specifies the Media Access Control (MAC) address for the network card. It is a unique
identifier and you are advised to always specify it. If not, QEMU supplies its own default
MAC address and creates a possible MAC address conflict within the related VLAN.
29.4.2
User-Mode Networking
The -netdev user option instructs QEMU to use user-mode networking. This is the default if
no networking mode is selected. Therefore, these command lines are equivalent:
qemu-system-x86_64 -hda /images/sles_base.raw
267
User-Mode Networking
This mode is useful if you want to allow the VM Guest to access the external network resources,
such as the Internet. By default, no incoming traffic is permitted and therefore, the VM Guest is
not visible to other machines on the network. No administrator privileges are required in this
networking mode. The user-mode is also useful for doing a network boot on your VM Guest
from a local directory on VM Host Server.
The VM Guest allocates an IP address from a virtual DHCP server. VM Host Server (the DHCP
server) is reachable at 10.0.2.2, while the IP address range for allocation starts from 10.0.2.15.
You can use ssh to connect to VM Host Server at 10.0.2.2, and scp to copy files back and forth.
29.4.2.1
This section shows several examples on how to set up user-mode networking with QEMU.
EXAMPLE29.1:RESTRICTED USER-MODE NETWORKING
qemu-system-x86_64 [...] \
-netdev user
,id=hostnet0 \
-device virtio-net-pci,netdev=hostnet0,vlan=1
,name=user_net1
,restrict=yes
Specifies a human-readable name of the network stack. Useful when identifying it in the
QEMU monitor.
Isolates VM Guest. It will not be able to communicate with VM Host Server and no network
packets will be routed to the external network.
,host=10.2.0.6
,dhcpstart=10.2.0.20
,hostname=tux_kvm_guest
Specifies the IP address of the network that VM Guest sees and optionally the netmask.
Default is 10.0.2.0/8.
268
Specifies the VM Host Server IP address that VM Guest sees. Default is 10.0.2.2.
User-Mode Networking
Specifies the first of the 16 IP addresses that the built-in DHCP server can assign to VM
Guest. Default is 10.0.2.15.
Specifies the host name that the built-in DHCP server will assign to VM Guest.
,bootfile=/images/
Activates a built-in TFTP (a file transfer protocol with the functionality of a very basic
FTP) server. The files in the specified directory will be visible to a VM Guest as the root
of a TFTP server.
Broadcasts the specified file as a BOOTP (a network protocol that offers an IP address and
a network location of a boot image, often used in diskless workstations) file. When used
together with tftp , the VM Guest can boot from network from the local directory on the
host.
Forwards incoming TCP connections to the port 2222 on the host to the port 22 ( SSH ) on
VM Guest. If sshd is running on VM Guest, enter
ssh qemu_host -p 2222
where qemu_host is the host name or IP address of the host system, to get a SSH prompt
from VM Guest.
29.4.3
Bridged Networking
With the -netdev tap option, QEMU creates a network bridge by connecting the host TAP
network device to a specified VLAN of VM Guest. Its network interface is then visible to the rest
of the network. This method does not work by default and has to be explicitly specified.
269
Bridged Networking
First, create a network bridge and add a VM Host Server physical network interface (usually
eth0 ) to it:
3. Choose whether you need a dynamically or statically assigned IP address, and fill the
4. In the Bridged Devices pane, select the Ethernet device to add to the bridge.
Click Next. When asked about adapting an already configured device, click Continue.
5. Click OK to apply the changes. Check if the bridge is created:
tux > brctl show
270
STP enabled
interfaces
br0
no
eth0
8000.001676d670e4
Bridged Networking
29.4.3.1
Use the following example script to connect VM Guest to the newly created bridge interface
br0 . Several commands in the script are run via the sudo mechanism because they require
root privileges.
#!/bin/bash
bridge=br0
,script=no
,downscript=no
10
Prepare a new TAP device and assign it to the user who runs the script. TAP devices are
virtual network devices often used for virtualization and emulation setups.
Make a 1-second pause to make sure the new TAP network interface is really up.
The ifname= suboption specifies the name of the TAP network interface used for bridging.
Before qemu-system-ARCH connects to a network bridge, it checks the script and down-
script values. If it finds the specified scripts on the VM Host Server file system, it runs
the script before it connects to the network bridge and downscript after it exits the
271
Bridged Networking
network environment. You can use these scripts to first set up and bring up the bridged
network devices, and then to deconfigure them. By default, /etc/qemu-ifup and /etc/
qemu-ifdown are examined. If script=no and downscript=no are specified, the script
10
29.4.3.2
Another way to connect VM Guest to a network through a network bridge is by means of the
qemu-bridge-helper helper program. It configures the TAP interface for you, and attaches it
helper executable is setuid root, which is only executable by the members of the virtualization
group ( kvm ). Therefore the qemu-system-ARCH command itself does not need to be run under
root privileges.
You can specify your own custom helper script that will take care of the TAP device
(de)configuration, with the helper=/path/to/your/helper option:
Tip
To define access privileges to
qemu-bridge-helper ,
inspect the
/etc/qe-
allow br0
272
Bridged Networking
allows the qemu-system-ARCH command to connect its VM Guest to the network bridge
br0 .
Tip
When working with QEMU's virtual machine via VNC session, it is useful to work with
the -usbdevice tablet option.
Moreover, if you need to use another keyboard layout than the default en-us , specify
it with the -k option.
The first suboption of -vnc must be a display value. The -vnc option understands the following
display specifications:
host:display
Only connections from host on the display number display will be accepted. The TCP
port on which the VNC session is then running is normally a 5900 + display number.
If you do not specify host , connections will be accepted from any host.
unix:path
The VNC server listens for connections on Unix domain sockets. The path option specifies
the location of the related Unix socket.
none
The VNC server functionality is initialized, but the server itself is not started. You can start
the VNC server later with the QEMU monitor. For more information, see Chapter30, Virtual
Machine Administration Using QEMU Monitor.
273
Following the display value there may be one or more option flags separated by commas. Valid
options are:
reverse
websocket
Opens an additional TCP listening port dedicated to VNC Websocket connections. By definition the Websocket port is 5700+display.
password
tls
Require that clients use TLS when communicating with the VNC server.
x509=/path/to/certificate/dir
Valid if TLS is specified. Require that x509 credentials are used for negotiating the TLS
session.
x509verify=/path/to/certificate/dir
Valid if TLS is specified. Require that x509 credentials are used for negotiating the TLS
session.
sasl
acl
Require that the client uses SASL to authenticate with the VNC server.
Turn on access control lists for checking of the x509 client certificate and SASL party.
lossy
non-adaptive
share=[allow-exclusive|force-shared|ignore]
Note
For more details about the display options, see the qemu-doc man page.
274
29.5.1
The default VNC server setup does not use any form of authentication. In the previous example,
any user can connect and view the QEMU VNC session from any host on the network.
There are several levels of security that you can apply to your VNC client/server connection.
You can either protect your connection with a password, use x509 certificates, use SASL authentication, or even combine some authentication methods in one QEMU command.
See Section B.1, Generating x509 Client/Server Certificates for more information about the x509
certificates generation. For more information about configuring x509 certificates on a VM Host
Server and the client, see Section11.3.2, Remote TLS/SSL Connection with x509 Certificate (qemu+tls
or xen+tls) and Section11.3.2.3, Configuring the Client and Testing the Setup.
275
The Vinagre VNC viewer supports advanced authentication mechanisms. Therefore, it will be
used to view the graphical output of VM Guest in the following examples. For this example,
let us assume that the server x509 certificates ca-cert.pem , server-cert.pem , and serv-
er-key.pem are located in the /etc/pki/qemu directory on the host, while the client's certifi-
Starts the VM Guest graphical output on VNC display number 5 (usually port 5905). The
password suboption initializes a simple password-based authentication method. There
is no password set by default and you need to set one with the change vnc password
command in QEMU monitor:
You need the -monitor stdio option here, because you would not be able to manage
the QEMU monitor without redirecting its input/output.
276
The QEMU VNC server can use TLS encryption for the session and x509 certificates for
authentication. The server asks the client for a certificate and validates it against the CA
certificate. Use this authentication type if your company provides an internal certificate
authority.
You can combine the password authentication with TLS encryption and x509 certificate
277
EXAMPLE29.8:SASL AUTHENTICATION
Simple Authentication and Security Layer (SASL) is a framework for authentication and
PAM, Kerberos, LDAP and more. SASL keeps its own user database, so the connecting user
accounts do not need to exist on VM Host Server.
For security reasons, you are advised to combine SASL authentication with TLS encryption
and x509 certificates:
278
user. Using the commands available in the monitor console, it is possible to inspect the running
operating system, change removable media, take screenshots or audio grabs and control several
other aspects of the virtual machine.
Note
The following sections list selected useful QEMU monitor commands and their purpose.
To get the full list, enter help in the QEMU monitor command line.
Ctrl
the QEMU GUI window, then compatmonitor0. The most convenient way is to show the QEMU
window tabs with View Show Tabs. Then you can easily switch between the guest screen, monitor screen, and the output of the serial and parallel console.
To get help while using the console, use help or ? . To get help for a specific command, use
help command .
info commands
279
info network
info chardev
info block
Information about block devices, such as hard disks, floppy drives, or CD-ROMs.
info blockstats
info registers
info cpus
info history
info irq
info pic
info pci
info tlb
info mem
info jit
info kvm
info numa
280
info usb
info usbhost
info profile
info capture
info snapshots
info status
info pcmcia
info mice
info vnc
info name
info uuid
info usernet
info migrate
info balloon
info qtree
281
info qdm
info roms
info migrate_cache_size
Shows the current migration xbzrle (=Xor Based Zero Run Length Encoding) cache size.
info migrate_capabilities
Shows the status of the various migration capabilities, such as xbzrle compression.
info mtree
info trace-events
282
You can confirm your new device by querying the block subsystem:
(qemu) info block
[...]
disk1: removable=1 locked=0 tray-open=0 file=/tmp/test.img ro=0 drv=raw \
encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0
After the new drive is defined, it needs to be connected to a device so that the guest can see it.
The typical device would be a virtio-blk-pci or scsi-disk . To get the full list of available
driver values, run:
(qemu) device_add ?
name "VGA", bus PCI
name "usb-storage", bus usb-bus
[...]
name "virtio-blk-pci", bus virtio-bus
0, device
4, function 0:
Tip
Devices added with the device_add command can be removed from the guest with
device_del . Enter help device_del on the QEMU monitor command line for more
information.
283
Managing Devices
To release the device or file connected to the removable media device, use the eject device
command. Use the optional -f to force ejection.
To change removable media (like CD-ROMs), use the change device command. The name of
the removable media can be determined using the info block command:
(qemu) info block
ide1-cd0: type=cdrom removable=1 locked=0 file=/dev/sr0 ro=1 drv=host_device
(qemu) change ide1-cd0 /path/to/image
Ctrl
Alt F1 in X Window), you can still enter them using the sendkey keys :
sendkey ctrl-alt-f1
To list the key names used in the keys option, enter sendkey and press
Move the active mouse pointer to the specified coordinates dx, dy with the optional scroll
axis dz.
mouse_button val
mouse_set index
Set which mouse device receives events. Device index numbers can be obtained with the
info mice command.
284
balloon device that allows to dynamically change the amount of memory available is therefore
enabled, it is possible to change the available memory dynamically. For more information about
enabling the balloon device, see Section28.1, Basic Installation with qemu-system-ARCH.
To get information about the balloon device in the monitor console and to determine whether
the device is enabled, use the info balloon command:
(qemu) info balloon
If the balloon device is enabled, use the balloon memory_in_MB command to set the requested
amount of memory:
Saves virtual memory dump starting at addr of size size to file filename
Saves physical memory dump starting at addr of size size to file filename -
x / fmt addr
Makes a virtual memory dump starting at address addr and formatted according to the
fmt string. The fmt string consists of three parameters countformatsize :
The size parameter can be b (8 bits), h (16 bits), w (32 bits) or g (64 bits). On x86, h
or w can be specified with the i format to respectively select 16 or 32-bit code instruction
size.
285
xp / fmt addr
Makes a physical memory dump starting at address addr and formatted according to the
fmt string. The fmt string consists of three parameters countformatsize :
The size parameter can be b (8 bits), h (16 bits), w (32 bits) or g (64 bits). On x86, h
or w can be specified with the i format to respectively select 16 or 32-bit code instruction
size.
Virtual Machine snapshots are snapshots of the complete virtual machine including the state of
CPU, RAM, and the content of all writable disks. To use virtual machine snapshots, you must
have at least one non-removable and writable block device using the qcow2 disk image format.
Snapshots are helpful when you need to save your virtual machine in a particular state. For
example, after you have configured network services on a virtualized server and want to quickly
start the virtual machine in the same state that was saved last. You can also create a snapshot
after the virtual machine has been powered off to create a backup state before you try some-
thing experimental and possibly make VM Guest unstable. This section introduces the former
case, while the latter is described in Section28.2.3, Managing Snapshots of Virtual Machines with
qemu-img.
The following commands are available for managing snapshots in QEMU monitor:
savevm name
Creates a new virtual machine snapshot under the tag name or replaces an existing snapshot.
loadvm name
delvm
286
info snapshots
TAG
VM SIZE
DATE
VM CLOCK
booting
00:00:20.476
booted
00:02:05.394
logged_in
00:04:34.843
ff_and_term_running
00:08:44.965
The disk space occupied by the snapshot. Note that the more memory is consumed
by running applications, the bigger the snapshot is.
cont
system_reset
Resets the virtual machine. The effect is similar to the reset button on a physical machine.
This may leave the file system in an unclean state.
system_powerdown
Sends an ACPI shutdown request to the machine. The effect is similar to the power button
on a physical machine.
287
q or quit
other host system without any interruption in availability. It is possible to change hosts permanently or just during maintenance.
with migration.
The guest on the source and destination hosts must be started in the same way.
-snapshot qemu command line option should not be used for migration (and this qemu
parameters used are the same as on the source host plus the -incoming tcp:ip:port
parameter, where ip specifies the IP address and port specifies the port for listening
to the incoming migration. If 0 is set as IP address, the virtual machine listens on all
interfaces.
3. On the source host, switch to the monitor console and use the migrate -d tcp:
destination_ip : port command to initiate the migration.
4. To determine the state of the migration, use the info migrate command in the monitor
288
Live Migration
5. To cancel the migration, use the migrate_cancel command in the monitor console on
6. To set the maximum tolerable downtime for migration in seconds, use the
migrate_set_downtime number_of_seconds command.
7. To set the maximum speed for migration in bytes per second, use the migrate_set_speed
bytes_per_second command.
with a running QEMU instance. There are several ways you can access the QEMU monitor using
QMP commands.
30.11.1
The most flexible way to use QMP is by specifying the -mon option. The following example
creates a QMP instance using standard input/output. Note that in the following examples, ->
marks lines with commands sent from client to the running QEMU instance, while <- marks
lines with the output returned from QEMU.
# qemu-system-x86_64 [...] \
-chardev stdio,id=mon0 \
-mon chardev=mon0,mode=control,pretty=on
<- {
"QMP": {
"version": {
"qemu": {
"micro": 0,
"minor": 0,
"major": 2
},
"package": ""
},
289
"capabilities": [
]
}
}
When a new QMP connection is established, QMP sends its greeting message and enters capabilities negotiation mode. In this mode, only the qmp_capabilities command works. To exit
capabilities negotiation mode and enter command mode, the qmp_capabilities command
must be issued first:
290
30.11.2
Instead of the standard input/output, you can connect the QMP interface to a network socket
and communicate with it via a specified port:
# qemu-system-x86_64 [...] \
-chardev socket,id=mon0,host=localhost,port=4444,server,nowait \
-mon chardev=mon0,mode=control,pretty=on
You can create several monitor interfaces at the same time. The following example creates one
HMP instancehuman monitor which understands 'normal' QEMU monitor's commandson
the standard input/output, and one QMP instance on localhost port 4444:
# qemu-system-x86_64 [...] \
-chardev stdio,id=mon0 -mon chardev=mon0,mode=readline \
-chardev socket,id=mon1,host=localhost,port=4444,server,nowait \
291
-mon chardev=mon1,mode=control,pretty=on
30.11.3
Invoke QEMU using the -qmp option, and create a unix socket:
# qemu-system-x86_64 [...] \
-qmp unix:/tmp/qmp-sock,server --monitor stdio
To communicate with the QEMU instance via the /tmp/qmp-sock socket, use nc (see man 1
nc for more information) from another terminal on the same host:
# nc -U /tmp/qmp-sock
<- {"QMP": {"version": {"qemu": {"micro": 0, "minor": 0, "major": 2} [...]
30.11.4
If you run your virtual machines under libvirt (see Part II, Managing Virtual Machines with
libvirt), you can communicate with its running guests by running the virsh qemu-monitor-command :
In the above example, we ran the simple command query-kvm which checks if the host is
capable of running KVM and if KVM is enabled.
292
Tip
If you want to use the standard 'human readable' way of QEMU commands instead of the
JSON format, use the --hmp option:
293
31
32
31 Linux Containers
name but a few tasks). To set up an LXC container, you first need to create a root file system
containing the guest distribution:
There is currently no GUI to create a root file system. You will thus need to open a terminal and use virt-create-rootfs as root to populate the new root file system. In the
following steps, the new root file system will be created in /path/to/rootfs .
Note that virt-create-rootfs needs a registration code to set up a SLE-12 root file
system.
2. Change the root path to the root file system with the chroot command:
chroot /path/to/rootfs
295
Linux Containers
1. Open YaST and go to Virtualization Create Virtual Machines to open the Virtual Machine
Manager.
2. If not already present, add a local LXC connection by clicking File, Add Connection. Select
3. Select the localhost (LXC) connection and click File New Virtual Machine menu.
Select the Operating system container option and click the Forward button.
4. Type the path to the root file system from Procedure31.1, Creating a Root File System and
5. Choose the maximum amount of memory and CPUs to allocate to the container. Then
6. Type in a name for the container. This name will be used for all virsh commands on
the container.
Click Advanced options. Select the network to connect the container to and click the Finish
button: the container will then be created and started. A console will also be automatically
opened.
Make sure not to change the IPv6 setting: this would lead to errors while starting the
network.
296
3. Select the localhost (LXC) connection and click File New Virtual Machine.
Set the patch to the application to be launched. As an example, the field is filled with /
bin/sh , which is fine to create a first container. Click Forward.
4. Choose the maximum amount of memory and CPUs to allocate to the container. Click
Forward.
5. Type in a name for the container. This name will be used for all virsh commands on
the container.
Click Advanced options. Select the network to connect the container to and click Finish.
The container will be created and started. A console will be opened automatically.
Note that the container will be destroyed after the application has finished running.
2. Add the following to the XML configuration, save it and exit the editor.
<domain>
...
<seclabel type="dynamic" model="apparmor"/>
...
</domain>
3. With this configuration, an AppArmor profile for the container will be created in the /
etc/apparmor.d/libvirt directory. The default profile only allows the minimum appli-
cations to run in the container. This can be changed by modifying the libvirt-container-uuid file: this file is not overwritten by libvirt.
297
12 comes with the libvirt LXC driver, sometimes named libvirt-lxc to avoid confusion. The con-
tainers are not managed or configured in the same way in these tools. Here is a non-exhaustive
list of differences.
The main difference comes from the fact that domain configuration in libvirt is an XML file,
while LXC configuration is a properties file. Most of the LXC properties can be mapped to the
domain XML. The properties that cannot be migrated are:
lxc.network.script.up: this script can be implemented using the /etc/libvirt/hooks/network libvirt hook, though the script will need to be adapted.
lxc.network.ipv*: libvirt cannot set the container network configuration from the domain
configuration.
lxc.pivotdir: libvirt does not allow to fine-tune the directory used for the pivot_root .
/.olroot is used.
LXC rootfs can also be an image file, but LXC brute-forces the mount to try to detect the proper
file system format. libvirt-lxc can mount image files of several formats, but the 'auto' value for
the format parameter is explicitly not supported. This means that the generated configuration
will need to be tweaked by the user to get a proper match in that case.
LXC can support any cgroup configuration, even future ones, while libvirt domain configuration,
needs to map each of them.
298
LXC can mount block devices in the rootfs, but it cannot mount raw partition files: the file needs
to be manually attached to a loop device. On the other hand libvirt-lxc can mount block devices,
but also partition files of any format.
299
has several advantages over using LXC as a separate solutionsuch as a unified approach with
other virtualization solutions or independence on the kernel used. This chapter describes steps
needed to migrate an existing LXC environment for use with the libvirt library.
1. Upgrade the host to SUSE Linux Enterprise Server 12 using the official DVD media.
2. After the upgrade, install the libvirt-daemon-lxc and libvirt-daemon-config-network packages.
4. Check if the network configuration on the host is the same as in the container configuration
5. Check the lxc_container.xml file for any weird or missing configuration. Note that
300
1. The baseproduct file is missing (and zypper keeps complaining about it). Create the
# ROOTFS=/var/lib/lxc/lxc_container/rootfs
# ln -s $ROOTFS/etc/products.d/SUSE_SLES.prod $ROOTFS/etc/products.d/
baseproduct
2. Add the DVD repository. Note that you need to replace the DVD device with the one
| Name
| Enabled |
Refresh
--+-----------------------------+------------------------------+--------+-------1 | SLES12-12
| SLES12-12
| Yes
| No
| No
301
Container Migration
If you need to get a console to view the logging messages produced by the container, run:
# virsh -c lxc:/// console lxc_container
302
Glossary
General
Create Virtual Machine Wizard
A software program available in YaST and Virtual Machine Manager that provides a graphical interface to guide you through the steps to create virtual machines. It can also be run
in text mode by entering virt-install at a command prompt in the host environment.
Dom0
The term is used in Xen environments, and refers to a virtual machine. The host operating
system is actually a virtual machine running in a privileged domain and can be called Dom0.
All other virtual machines on the host run in unprivileged domains and can be called domain
U's.
hardware-assisted
Intel* and AMD* provide virtualization hardware-assisted technology. This reduces frequency of VM IN/OUT (fewer VM traps), because software is a major source of overhead, and
increases the efficiency (the execution is done by the hardware). Moreover this reduces the
memory footprint, provides better resource control, and allows secure assignment of specific
I/O devices.
Host Environment
The desktop or command line environment that allows interaction with the host computer's
environment. It provides a command line environment and can also include a graphical
desktop, such as GNOME or IceWM. The host environment runs as a special type of virtual
machine that has privileges to control and manage other virtual machines. Other commonly
used terms include Dom0, privileged domain, and host operating system.
Hypervisor
The software that coordinates the low-level interaction between virtual machines and the
underlying physical computer hardware.
KVM
303
Glossary
The video output device that drives a video display from a memory buffer containing a
complete frame of data for virtual machine displays running in paravirtual mode.
VHS
environment consists of the hypervisor, the host environment, virtual machines, and associated tools, commands, and configuration files. Other commonly used terms include host,
Host Computer, Host Machine (HM), Virtual Server (VS), Virtual Machine Host (VMH), and
VM Host Server (VHS).
VirtFS
VirtFS is a new paravirtualized file system interface designed for improving pass-through
technologies in the KVM environment. It is based on the VirtIO framework.
Virtual Machine
A virtualized PC environment (VM) capable of hosting a guest operating system and associated applications. Could be also called a VM Guest.
A software program that provides a graphical user interface for creating and managing virtual machines.
Virtualized
Xen
xl
A set of commands for Xen that lets administrators manage virtual machines from a command prompt on the host computer. It replaced the deprecated xm toolstack.
304
General
CPU
CPU capping
Virtual CPU capping allows you to set vCPU capacity to 1100 percent of the physical CPU
capacity.
CPU hotplugging
CPU over-commitment
Virtual CPU over-commitment is the ability to assign more virtual CPUs to VMs than the
actual number of physical CPUs present in the physical system. This procedure does not
increase the overall performance of the system, but might be useful for testing purposes.
CPU pinning
Processor affinity, or CPU pinning enables the binding and unbinding of a process or a thread
to a central processing unit (CPU) or a range of CPUs.
Network
Bridged Networking
A type of network connection that lets a virtual machine be identified on an external network
as a unique identity that is separate from and unrelated to its host computer.
Empty Bridge
A type of network bridge that has no physical network device or virtual network device
provided by the host. This lets virtual machines communicate with other virtual machines
on the same host but not with the host or on an external network.
External Network
Internal Network
A type of network configuration that restricts virtual machines to their host environment.
305
CPU
Local Bridge
A type of network bridge that has a virtual network device but no physical network device
provided by the host. This lets virtual machines communicate with the host and other virtual
machines on the host. Virtual machines can communicate on an external network through
the host.
A type of network connection that lets a virtual machine use the IP address and MAC address
of the host.
No Host Bridge
A type of network bridge that has a physical network device but no virtual network device
provided by the host. This lets virtual machines communicate on an external network but
not with the host. This lets you separate virtual machine network communications from the
host environment.
Traditional Bridge
A type of network bridge that has both a physical network device and a virtual network
device provided by the host.
Storage
AHCI
The Advanced Host Controller Interface (AHCI) is a technical standard defined by Intel*
that specifies the operation of Serial ATA (SATA) host bus adapters in a non-implementation-specific manner.
Block Device
Data storage devices, such as CD-ROM drives or disk drives, that move data in the form of
blocks. Partitions and volumes are also considered block devices.
306
Storage
Raw Disk
A method of accessing data on a disk at the individual byte level instead of through its file
system.
A disk image file that does not reserve its entire amount of disk space but expands as data
is written to it.
xvda
The drive designation given to the first virtual disk on a paravirtual machine.
Linux Containers
cgroups
Kernel Control Groups (commonly just called cgroups) are a Kernel feature that allows
aggregating or partitioning tasks (processes) and all their children into hierarchical organized groups to isolate resources.
See also Book System Analysis and Tuning Guide, Chapter 9 Kernel Control Groups.
chroot
A change root (chroot, or change root jail) is a section in the file system that is isolated from
the rest of the file system. For this purpose, the chroot or pivot_root command is used to
change the root of the file system. A program that is executed in such a chroot jail cannot
access files outside the designated directory tree.
container
Can be seen as a kind of virtual machine on the host server that can run any Linux system,
for example openSUSE, SUSE Linux Enterprise Desktop, or SUSE Linux Enterprise Server.
The main difference with a normal virtual machine is that the container shares its kernel
with the host it runs on.
Kernel namespaces
A Kernel feature to isolate some resources like network, users, and others for a group of
processes.
307
Linux Containers
Acronyms
ACPI
Advanced Configuration and Power Interface (ACPI) specification provides an open standard
for device configuration and power management by the operating system.
AER
APIC
BDF
Bus:Device:Function
Notation used to succinctly describe PCI and PCIe devices.
CG
Control Groups
Feature to limit, account and isolate resource usage (CPU, memory, disk I/O, etc.).
EDF
EPT
CPU, the MMU, and the I/O devices. In some recent x86 processors AMD and Intel have begun
to provide hardware extensions to help bridge this performance gap. In 2006, both vendors
introduced their first generation hardware support for x86 virtualization with AMD-Virtu-
alizationTM (AMD-VTM) and Intel VT-x technologies. Recently Intel introduced its second
308
Acronyms
Tables (EPT). EPT-enabled systems can improve performance compared to using shadow
paging for MMU virtualization. EPT increases memory access latencies for a few workloads.
This cost can be reduced by effectively using large pages in the guest and the hypervisor.
FLASK
HAP
HVM
IOMMU
KSM
MMU
by the CPU. Its functions include translation of virtual addresses to physical addresses (i.e.,
virtual memory management), memory protection, cache control, bus arbitration and in
simpler computer architectures (especially 8-bit systems) bank switching.
PAE
309
Acronyms
32-bit x86 operating systems use Physical Address Extension (PAE) mode to enable addressing of more than 4 GB of physical memory. In PAE mode, page table entries (PTEs) are 64
bits in size.
PCID
Process-context identifiers
These are a facility by which a logical processor may cache information for multiple linear-address spaces so that the processor may retain cached information when software
switches to a different linear address space. INVPCID instruction is used for fine-grained TLB
flush, which is benefit for kernel.
PCIe
and smaller physical footprint. Moreover it also has a more detailed error detection and
reporting mechanism (AER), and a native hotplug functionality. It is also backward compatible with PCI.
PSE and PSE36
used inside a page directory entry pointing to a large page. This allows a large page to be
located in 36-bit address space.
PT
Page Table
A page table is the data structure used by a virtual memory system in a computer operat-
ing system to store the mapping between virtual addresses and physical addresses. Virtual
addresses are those unique to the accessing process. Physical addresses are those unique to
the hardware (RAM).
QXL
RVI or NPT
310
Acronyms
Serial ATA
SATA is a computer bus interface that connects host bus adapters to mass storage devices
such as hard disks and optical drives.
Seccomp2-based sandboxing
Sandboxed environment where only predetermined system calls are permitted for added
protection against malicious behavior.
SMEP
SPICE
SXP
TCG
THP
reduce memory consumption and CPU cache usage. KVM is optimized to use THP (via madvise and opportunistic methods) if enabled on the VM Host Server.
TLB
311
Acronyms
VCPU
VDI
VFIO
Since kernel v3.6; a new method of accessing PCI devices from userspace called VFIO.
VHS
VM root
VMM will run in VMX root operation and guest software will run in VMX non-root operation.
Transitions between VMX root operation and VMX non-root operation are called VMX transitions.
VMCS
ponent of processor state called the VMCS pointer (one per logical processor). The value
of the VMCS pointer is the 64-bit address of the VMCS. The VMCS pointer is read and written using the instructions VMPTRST and VMPTRLD. The VMM configures a VMCS using the
VMREAD, VMWRITE, and VMCLEAR instructions. A VMM could use a different VMCS for
each virtual machine that it supports. For a virtual machine with multiple logical processors
(virtual processors), the VMM could use a different VMCS for each virtual processor.
VMDq
VMM
312
Acronyms
When the processor encounters an instruction or event of interest to the Hypervisor (VMM),
it exits from guest mode back to the VMM. The VMM emulates the instruction or other
event, at a fraction of native speed, and then returns to guest mode. The transitions from
guest mode to the VMM and back again are high-latency operations, during which guest
execution is completely stalled.
VMX
VPID
New support for software control of TLB (VPID improves TLB performance with small VMM
development effort).
VT-d
vTPM
313
Acronyms
utions are aware of the underlying virtualization platform, and can therefore interact efficiently
with it. Unmodified operating systems such as Microsoft Windows* are unaware of the virtualization platform and expect to interact directly with the hardware. Because this is not possible
when consolidating servers, the hardware must be emulated for the operating system. Emula-
tion can be slow, but it is especially troubling for high-throughput disk and network subsystems.
Most performance loss occurs in this area.
The SUSE Linux Enterprise Virtual Machine Driver Pack (VMDP) contains 32-bit and 64-bit paravirtualized network, bus and block drivers for several Microsoft Windows operating systems.
These drivers bring many of the performance advantages of paravirtualized operating systems
to unmodified operating systems because only the paravirtualized device driver (not the rest
of the operating system) is aware of the virtualization platform. For example, a paravirtualized
disk device driver appears as a normal, physical disk to the operating system. However, the device driver interacts directly with the virtualization platform (with no emulation) to efficiently
deliver disk access, allowing the disk and network subsystems to operate at near native speeds
in a virtualized environment, without requiring changes to existing operating systems.
The SUSE Linux Enterprise Virtual Machine Driver Pack is available as an add-on product for
openSUSE Leap. For detailed information refer to http://www.suse.com/products/vmdriverpack/.
Refer to the Official VMDP Installation Guide at https://www.suse.com/documentation/slevmdp-22/ for more information.
314
B Appendix
2. Create a server and a client certificate as described in Book Security Guide, Chapter 17
Managing X.509 Certification, Section 17.2.4 Creating or Revoking User Certificates. The
Common Name (CN) for the server certificate must be the fully qualified host name, while
the Common Name for the client certificate can be freely chosen. For all other fields stick
with the defaults suggested by YaST.
Export the client and server certificates to a temporary location (for example, /tmp/
x509/ ) by performing the following steps:
provide the Certificate Password and the full path and the file name under File Name,
for example, /tmp/x509/server.pem or /tmp/x509/client.pem .
c. Open a terminal and change to the directory where you have saved the certificate
and issue the following commands to split it into certificate and key (this example
splits the server key):
d. Repeat the procedure for each client and server certificate you would like to export.
315
Appendix
full path and the file name under File Name, for example, /tmp/x509/cacert.pem .
316
lations. In Xen 4.1, a new toolstack called libxenlight (also known as libxl) was introduced with
technology preview status. libxl is a small, low-level library written in C. It has been designed to
provide a simple API for all client toolstacks (XAPI [http://wiki.xen.org/wiki/XAPI], libvirt ,
xl). In Xen 4.2, libxl was promoted to officially supported status and xend was marked depre-
cated. xend has been included in the Xen 4.3 and 4.4 series to give users ample time to convert
their tooling to libxl, but it has been removed from the upstream Xen project and will no longer
be provided starting with the Xen 4.5 series and SLES 12 SP1.
Although SLES11 SP3 contains Xen 4.2, SUSE retained the xend toolstack since making such
an invasive change in a service pack would be too disruptive for SUSE Linux Enterprise customers. However, SLES12 provides a suitable opportunity to move to the new libxl toolstack
and remove the deprecated, unmaintained xend stack. Starting with SLES 12 SP1, xend is no
longer supported.
One of the major differences between xend and libxl is that the former is stateful, while the
latter is stateless. With xend , all client applications such as xm and libvirt see the same
system state. xend is responsible for maintaining state for the entire Xen host. In libxl, client
applications such as xl or libvirt must maintain state. Thus domains created with xl or not
visible or known to other libxl applications such as libvirt . Generally, it is discouraged to mix
and match libxl applications and is preferred that a single libxl application be used to manage
a Xen host. In SUSE Linux Enterprise 12 , it is recommended to use libvirt to manage Xen
hosts, allowing management of the Xen system through libvirt applications such as virt-
the Xen host, any virtual machines under its management will not be accessible to libvirt ,
and hence not accessible to any of the libvirt applications.
C.1.1
The xl application, along with its configuration format (see man xl.cfg ), was designed to be
backwards-compatible with the xm application and its configuration format (see man xm.cfg ).
Existing xm configuration should be usable with xl . Since libxl is stateless, and xl does not
317
support the notion of managed domains, SUSE recommends using libvirt to manage SLES12
Xen hosts. SUSE has provided a tool called xen2libvirt , which provides a simple mechanism
to import domains previously managed by xend into libvirt . See SectionC.2, Import Xen Domain Configuration into libvirt for more information on xen2libvirt .
C.1.2
XL design
DOMAIN is the numeric domain id, or the domain name (which will be internally translated to
Although xl/libxl was designed to be backward-compatible with xm/xend, there are a few differences that should be noted:
xl/libxl does not support sharing storage across DomU's via w! in domain configuration
files.
xl/libxl is relatively new and under heavy development, hence a few features are still missing
with respect to the xm/xend toolstack:
C.1.3
318
XL design
You must remove any Python code from your xm domain configuration files.
It is recommended to capture the libvirt domain XML from all existing virtual machines
using virsh dumpxml DOMAIN_NAME DOMAIN_NAME.xml .
Note
Currently, live migrating virtual machines running on a SLES11 SP3 Xen host to a SLES12
Xen host is not supported. The xend and libxl toolstacks are not runtime-compatible.
Virtual machine downtime will be required to move the virtual machines from SLES11
SP3 to a SLES12 host.
virt virtualization library (see The Virtualization book for more information on libvirt ).
xen2libvirt provides an easy way to import domains managed by the deprecated xm /xend tool-
stack into the new libvirt /libxl toolstack. Several domains can be imported at once using its
--recursive mode
xen2libvirt is included in the xen-tools package. If needed, install it with
zypper install xen-tools
319
-c , --convert-only
Converts the domain configuration to the libvirt XML format, but does not do the import
to libvirt .
-r , --recursive
Converts and/or imports all domains configuration recursively, starting at the specified
path.
-f , --format
Specifies the format of the source domain configuration. Can be either xm , or sexpr (Sexpression format).
-v , --verbose
Suppose you have a Xen domain managed with xm with the following configuration saved
in /etc/xen/sle12.xm :
kernel = "/boot/vmlinuz-2.6-xenU"
memory = 128
name = "SLE12"
root = "/dev/hda1 ro"
disk = [ "file:/var/xen/sle12.img,hda1,w" ]
Convert it to libvirt XML without importing it, and look at its content:
# xen2libvirt -f xm -c /etc/xen/sle12.xm > /etc/libvirt/qemu/sles12.xml
# cat /etc/libvirt/qemu/sles12.xml
<domain type='xen'>
<name>SLE12</name>
<uuid>43e1863c-8116-469c-a253-83d8be09aa1d</uuid>
<memory unit='KiB'>131072</memory>
<currentMemory unit='KiB'>131072</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='xenpv'>linux</type>
<kernel>/boot/vmlinuz-2.6-xenU</kernel>
320
</os>
<clock offset='utc' adjustment='reset'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/var/xen/sle12.img'/>
<target dev='hda1' bus='xen'/>
</disk>
<console type='pty'>
<target type='xen' port='0'/>
</console>
</devices>
</domain>
To import the domain into libvirt , you can either run the same xen2libvirt command
without the -c option, or use the exported file /etc/libvirt/qemu/sles12.xml and
define a new Xen domain using virsh :
usually sufficient.
You can also use the libvirt framework using the virsh command. In this documentation
only the first OPTION for virsh will be shown. To get more help on this option do a:
virsh help OPTION
321
C.3.1
Notation Conventions
To easily understand the difference between xl and xm commands, the following notation is
used in this section:
TABLEC.1:NOTATION CONVENTIONS
Notation
Meaning
(-) minus
(+) plus
C.3.2
it.
it.
Options
Task
(+) -v
(+) -N
(+) -f
mand
commands if it detects that xend is also running, this option will force the execution of
those commands, even though it is unsafe
C.3.3
Unchanged Options
322
Notation Conventions
TABLEC.3:COMMON OPTIONS
Options
Task
libvirt equivalent
destroy DOMAIN
virsh destroy
domid DOMAIN_NAME
virsh domid
domain
DOMAIN_ID
domname DOMAIN_ID
Converts a DOMAIN_ID to a
virsh domname
DOMAIN_NAME
help
virsh help
mands)
pause DOMAIN_ID
virsh suspend
virsh resume
name of DOMAIN_ID to
NEW_DOMAIN_NAME
1. virsh
dumpxml DOMAINNAME
>
DOMXML
name in DOMXML
323
Unchanged Options
Options
Task
libvirt equivalent
3. virsh
undefine DOMAINNAME
4. virsh
define DOMAINNAME
virt-view DOMAIN_ID
virsh vncdisplay
virsh setvcpus
virsh vcpuinfo
324
Unchanged Options
Options
Task
libvirt equivalent
vcpu-pin DOMAIN_ID
virsh vcpupin
<VCPU|all> <CPUs|all>
dmesg [-c]
virsh nodecpustats
virsh nodememstats
argument is mandatory
debug-keys KEYS
325
a CPU_POOL
Unchanged Options
Options
Task
libvirt equivalent
cpupool-destroy CPU_POOL
block-detach DOMAIN_ID
DevId
virsh detach-disk
by DOMAIN_ID . network-de-
virsh attach-interface
virsh attach-device
virsh attach-device
getenforce
for a domain
326
Unchanged Options
Options
Task
setenforce <1|0|Enforc-
ing|Permissive>
libvirt equivalent
C.3.4
Removed Options
List of xm options which are no more available with the XL toolstack and a replacement
solution if available.
C.3.4.1
Domain Management
Task
Equivalent
(-) log
(-) delete
virsh undefine
main names
(-) new
virsh define
(-) start
virsh start
main management
327
Removed Options
Task
Equivalent
(-) dryrun
xl -N
(-) reset
Reset a domain
virsh reset
(-) domstate
virsh domstate
(-) serve
stdio
TIONS
virsh resume
to memory
virsh managedsave
virsh suspend
subcommand. Similar to
C.3.4.2
USB Devices
USB options are not available with xl/libxl toolstack. virsh has the
detach-device options but it does not work yet with USB .
attach-device and
Task
(-) usb-add
328
Removed Options
Task
(-) usb-del
(-) usb-attach
(-) usb-detach
(-) usb-list
(-) usb-list-assignable-devices
(-) usb-hc-create
(-) usb-hc-destroy
C.3.4.3
virtual port
virtual port
port
troller
troller
CPU Management
CPU management options has changed. New options are available, see: Section C.3.5.10, xl
cpupool-*
TABLEC.6:CPU MANAGEMENT REMOVED OPTIONS
Task
(-) cpupool-new
(-) cpupool-start
329
ment
Removed Options
Task
(-) cpupool-delete
C.3.4.4
ment
Other Options
TABLEC.7:OTHER OPTIONS
Task
(-) shell
(-) change-vnc-passwd
(-) vtpm-list
(-) block-configure
C.3.5
C.3.5.1
Changed Options
create
VARS
330
Changed Options
Options
Task
Options
Task
(-) -s , --skipdtd
(-) -x , --xmldryrun
(-) --path
(-) --help_config
(-) -n , --dryrun
(-) -c , --console_autoconnect
(-) -q , --quiet
Quiet mode
(-) -p , --paused
331
fore creating
script
Changed Options
Options
Task
(+) -V , --vncviewer
(+) -A , --vncviewer-autopass
C.3.5.2
vncviewer process
console
Option
Task
(+) -t [pv|serial]
C.3.5.3
info
xl info
332
Changed Options
Options
Task
(-) -n , --numa
Numa info
(-) -c , --config
C.3.5.4
dump-core
Options
Task
(-) -L , --live
(-) -C , --crash
(-) -R , --reset
C.3.5.5
list
333
Changed Options
Options
Task
(-) -l , --long
(-) --state==STATE
SXP format
state
Options
Task
(+) -Z , --context
(+) -v , --verbose
C.3.5.6
mem-*
Options
Task
334
Changed Options
Options
Task
C.3.5.7
loon driver
migrate
Options
Task
(-) -l , --live
Use live migration. This will migrate the domain between hosts without shutting down
the domain
(-) -c , --change_home_server
335
domain
(default:30)
Changed Options
Options
Task
(-) --abort_if_busy
(-) --log_progress
(-) -s , --ssl
pend
Options
Task
(+) -s SSHCOMMAND
(+) -e
(+) -C config
C.3.5.8
Domain Management
Options
Task
(-) -a , --all
336
Changed Options
Options
Task
(-) -w , --wait
Option
Task
(+) -F
Option
Task
(+) -c
337
Changed Options
Options
Task
(+) -p
(+) -e
(+) -d
(+) -V , --vncviewer
(+) -A , --vncviewer-autopass
vncviewer process
Options
Task
(-) -w , --wait
(-) -a
before returning
(-) -R
(-) -H
338
Changed Options
Option
Task
(+) -F
Option
Task
er|sleep|s3resume> VCPU
C.3.5.9
xl sched-*
xl sched-credit OPTIONS
Options
Task
Domain
339
Changed Options
Options
Task
Options
Task
(+) -s , --schedparam
cpupool
rameters
xl sched-credit2 OPTIONS
Options
Task
Domain
340
default is 256
Changed Options
Option
Task
xl sched-sedf OPTIONS
TABLEC.30:xm sched-sedf REMOVED OPTIONS
Options
Task
onds
onds
time (0 or 1)
Options
Task
Domain
341
cpupool
Changed Options
C.3.5.10
xl cpupool-*
Option
Task
(-) -l , --long
Options
Task
(-) -n , --dryrun
(-) --help_config
C.3.5.11
342
Changed Options
Option
Task
(+) -f
Option
Task
(-) -l , --long
TABLEC.36:OTHER OPTIONS
Option
libvirt equivalent
virsh attach-disk/attach-device
xl block-list DOMAIN_ID
virsh domblklist
component(s)>
C.3.5.12
Network
TABLEC.37:NETWORK OPTIONS
Option
libvirt equivalent
xl network-list DOMAIN(s)
virsh domiflist
virsh detach-interface
343
Changed Options
Option
libvirt equivalent
xl network-attach DOMAIN(s)
virsh attach-interface/attach-device
Removed Options
Option
Task
(-) -l , --long
C.3.6
New Options
TABLEC.39:NEW OPTIONS
Options
Task
TIONS VARS
vm-list
cpupool-numa-split
344
numa node
New Options
Options
Task
<type:path>
pci-assignable-list
<BDF>
loadpolicy POLICY_FILE
allows runtime updates to the policy. Loading new security policy will reset runtime
changes to device labels
345
External links
xl command
xl.cfg
xl.cfg [http://xenbits.xen.org/docs/unstable/man/xl.cfg.5.html] domain configuration
file syntax.
xl disk
tion option.
XL vs Xend
comparison.
BDF doc
tion].
libvirt
346
D GNU Licenses
This appendix contains the GNU Free Documentation License version 1.2.
GNU Free Documentation License
Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. 51 Franklin St, Fifth
Floor, Boston, MA 02110-1301 USA. Everyone is permitted to copy and distribute
verbatim copies of this license document, but changing it is not allowed.
0. PREAMBLE
The purpose of this License is to make a manual, textbook, or other functional and
useful document "free" in the sense of freedom: to assure everyone the effective free-
dom to copy and redistribute it, with or without modifying it, either commercially or
non-commercially. Secondarily, this License preserves for the author and publisher a
way to get credit for their work, while not being considered responsible for modifications made by others.
This License is a kind of "copyleft", which means that derivative works of the document
must themselves be free in the same sense. It complements the GNU General Public
License, which is a copyleft license designed for free software.
We have designed this License to use it for manuals for free software, because free
software needs free documentation: a free program should come with manuals pro-
viding the same freedoms that the software does. But this License is not limited to
software manuals; it can be used for any textual work, regardless of subject matter or
duration, to use that work under the conditions stated herein. The "Document", below,
refers to any such manual or work. Any member of the public is a licensee, and is
addressed as "you". You accept the license if you copy, modify or distribute the work
in a way requiring permission under copyright law.
A "Modified Version" of the Document means any work containing the Document or
a portion of it, either copied verbatim, or with modifications and/or translated into
another language.
The relationship could be a matter of historical connection with the subject or with
related matters, or of legal, commercial, philosophical, ethical or political position
regarding them.
The "Invariant Sections" are certain Secondary Sections whose titles are designated, as
being those of Invariant Sections, in the notice that says that the Document is released
under this License. If a section does not fit the above definition of Secondary then it is
not allowed to be designated as Invariant. The Document may contain zero Invariant
Sections. If the Document does not identify any Invariant Sections then there are none.
The "Cover Texts" are certain short passages of text that are listed, as Front-Cover
Texts or Back-Cover Texts, in the notice that says that the Document is released under
this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may
be at most 25 words.
revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available draw-
347
ing editor, and that is suitable for input to text formatters or for automatic translation
to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged
to thwart or discourage subsequent modification by readers is not Transparent. An
image format is not Transparent if used for any substantial amount of text. A copy
that is not "Transparent" is called "Opaque".
Examples of suitable formats for Transparent copies include plain ASCII without
markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly
available DTD, and standard-conforming simple HTML, PostScript or PDF designed
for human modification. Examples of transparent image formats include PNG, XCF
and JPG. Opaque formats include proprietary formats that can be read and edited only
by proprietary word processors, SGML or XML for which the DTD and/or processing
tools are not generally available, and the machine-generated HTML, PostScript or PDF
produced by some word processors for output purposes only.
The "Title Page" means, for a printed book, the title page itself, plus such following
pages as are needed to hold, legibly, the material this License requires to appear in the
title page. For works in formats which do not have any title page as such, "Title Page"
means the text near the most prominent appearance of the work's title, preceding the
beginning of the body of the text.
A section "Entitled XYZ" means a named subunit of the Document whose title either
is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in
another language. (Here XYZ stands for a specific section name mentioned below, such
as "Acknowledgements", "Dedications", "Endorsements", or "History".) To "Preserve the
Title" of such a section when you modify the Document means that it remains a section
"Entitled XYZ" according to this definition.
The Document may include Warranty Disclaimers next to the notice which states that
this License applies to the Document. These Warranty Disclaimers are considered to
be included by reference in this License, but only as regards disclaiming warranties:
any other implication that these Warranty Disclaimers may have is void and has no
effect on the meaning of this License.
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either commercially or
noncommercially, provided that this License, the copyright notices, and the license
notice saying this License applies to the Document are reproduced in all copies, and
that you add no other conditions whatsoever to those of this License. You may not
use technical measures to obstruct or control the reading or further copying of the
copies you make or distribute. However, you may accept compensation in exchange
for copies. If you distribute a large enough number of copies you must also follow the
conditions in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have printed cov-
ers) of the Document, numbering more than 100, and the Document's license notice
requires Cover Texts, you must enclose the copies in covers that carry, clearly and
legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover
Texts on the back cover. Both covers must also clearly and legibly identify you as the
publisher of these copies. The front cover must present the full title with all words
of the title equally prominent and visible. You may add other material on the covers
in addition. Copying with changes limited to the covers, as long as they preserve the
title of the Document and satisfy these conditions, can be treated as verbatim copying
in other respects.
If the required texts for either cover are too voluminous to fit legibly, you should put
the first ones listed (as many as fit reasonably) on the actual cover, and continue the
rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than
100, you must either include a machine-readable Transparent copy along with each
Opaque copy, or state in or with each Opaque copy a computer-network location from
GNU Licenses
which the general network-using public has access to download using public-standard
N.
network protocols a complete Transparent copy of the Document, free of added ma-
terial. If you use the latter option, you must take reasonably prudent steps, when you
O.
begin distribution of Opaque copies in quantity, to ensure that this Transparent copy
will remain thus accessible at the stated location until at least one year after the last
time you distribute an Opaque copy (directly or through your agents or retailers) of
that edition to the public.
It is requested, but not required, that you contact the authors of the Document well
before redistributing any large number of copies, to give them a chance to provide
you with an updated version of the Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document under the condi-
tions of sections 2 and 3 above, provided that you release the Modified Version under
precisely this License, with the Modified Version filling the role of the Document, thus
licensing distribution and modification of the Modified Version to whoever possesses
a copy of it. In addition, you must do these things in the Modified Version:
A.
B.
peer review or that the text has been approved by an organization as the authoritative
definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up
to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified
Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be
added by (or through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or by arrangement
to use their names for publicity for or to assert or imply endorsement of any Modified
The author(s) and publisher(s) of the Document do not by this License give permission
List on the Title Page, as authors, one or more persons or entities respon-
State on the Title page the name of the publisher of the Modified Version,
Include, immediately after the copyright notices, a license notice giving the
public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
Preserve in that license notice the full lists of Invariant Sections and required
Cover Texts given in the Document's license notice.
Include an unaltered copy of this License.
Preserve the section Entitled "History", Preserve its Title, and add to it an
item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing
the Modified Version as stated in the previous sentence.
Preserve the network location, if any, given in the Document for public
access to a Transparent copy of the Document, and likewise the network
locations given in the Document for previous versions it was based on. These
may be placed in the "History" section. You may omit a network location
for a work that was published at least four years before the Document itself,
or if the original publisher of the version it refers to gives permission.
Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this License,
under the terms defined in section 4 above for modified versions, provided that you
include in the combination all of the Invariant Sections of all of the original documents,
unmodified, and list them all as Invariant Sections of your combined work in its license
notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and multiple identical
Invariant Sections may be replaced with a single copy. If there are multiple Invariant
Sections with the same name but different contents, make the title of each such section
unique by adding at the end of it, in parentheses, the name of the original author or
publisher of that section if known, or else a unique number. Make the same adjustment
to the section titles in the list of Invariant Sections in the license notice of the combined
work.
In the combination, you must combine any sections Entitled "History" in the various
original documents, forming one section Entitled "History"; likewise combine any sec-
tions Entitled "Acknowledgements", and any sections Entitled "Dedications". You must
delete all sections Entitled "Endorsements".
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents released
under this License, and replace the individual copies of this License in the various
documents with a single copy that is included in the collection, provided that you
follow the rules of this License for verbatim copying of each of the documents in all
other respects.
You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted
document, and follow this License in all other respects regarding verbatim copying
of that document.
Title of the section, and preserve in the section all the substance and tone of
in.
A compilation of the Document or its derivatives with other separate and independent
Preserve all the Invariant Sections of the Document, unaltered in their text
an "aggregate" if the copyright resulting from the compilation is not used to limit the
and in their titles. Section numbers or the equivalent are not considered
part of the section titles.
M.
gives permission.
E.
L.
You may add a section Entitled "Endorsements", provided it contains nothing but en-
K.
the same title as a previous version if the original publisher of that version
D.
J.
titles to the list of Invariant Sections in the Modified Version's license notice. These
you may replace the old one, on explicit permission from the previous publisher that
as the publisher.
I.
your option designate some or all of these sections as invariant. To do this, add their
were any, be listed in the History section of the Document). You may use
requirement.
H.
as Secondary Sections and contain no material copied from the Document, you may at
made by the same entity you are acting on behalf of, you may not add another; but
cipal authors, if it has fewer than five), unless they release you from this
G.
If the Modified Version includes new front-matter sections or appendices that qualify
the Document, and from those of previous versions (which should, if there
with at least five of the principal authors of the Document (all of its prin-
F.
Use in the Title Page (and on the covers, if any) a title distinct from that of
C.
Delete any section Entitled "Endorsements". Such a section may not be in-
348
GNU Licenses
If the Cover Text requirement of section 3 is applicable to these copies of the Docu-
ment, then if the Document is less than one half of the entire aggregate, the Document's
Cover Texts may be placed on covers that bracket the Document within the aggregate,
or the electronic equivalent of covers if the Document is in electronic form. Otherwise
they must appear on printed covers that bracket the whole aggregate.
8. TRANSLATION
Translation is considered a kind of modification, so you may distribute translations of
the Document under the terms of section 4. Replacing Invariant Sections with trans-
with the Invariant Sections being LIST THEIR TITLES, with the
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
If you have Invariant Sections without Cover Texts, or some other combination of the
three, merge those two alternatives to suit the situation.
leasing these examples in parallel under your choice of free software license, such as
the GNU General Public License, to permit their use in free software.
lations requires special permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the original versions of
these Invariant Sections. You may include a translation of this License, and all the
license notices in the Document, and any Warranty Disclaimers, provided that you
also include the original English version of this License and the original versions of
those notices and disclaimers. In case of a disagreement between the translation and
the original version of this License or a notice or disclaimer, the original version will
prevail.
tory", the requirement (section 4) to Preserve its Title (section 1) will typically require
changing the actual title.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document except as expressly
provided for under this License. Any other attempt to copy, modify, sublicense or
distribute the Document is void, and will automatically terminate your rights under
this License. However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such parties remain in
full compliance.
Documentation License from time to time. Such new versions will be similar in spirit
to the present version, but may differ in detail to address new problems or concerns.
See http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number. If the Document
specifies that a particular numbered version of this License "or any later version" ap-
plies to it, you have the option of following the terms and conditions either of that
specified version or of any later version that has been published (not as a draft) by
the Free Software Foundation. If the Document does not specify a version number of
this License, you may choose any version ever published (not as a draft) by the Free
Software Foundation.
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the
with...Texts. line with this:
349
GNU Licenses