20101201_kvmx

Download Report

Transcript 20101201_kvmx

Introduction to KVM
Andrea Chierici
Virtualization tutorial
Catania 1-3 dicember 2010
What is KVM





Kernel Virtual Machine
Is a Full virtualization solution for Linux on AMD64
and Intel 64 hardware
Is a Linux kernel module built for the standard
Linux kernel
Can run multiple, unmodified virtualized guest
Windows and Linux operating systems
The KVM hypervisor in Red Hat Enterprise Linux
is managed with the libvirt API and tools built for
libvirt, virt-manager and virsh.
Andrea Chierici
2
Guest mode


With KVM every virtual machine is a regular
Linux process, scheduled by the standard
Linux scheduler.
KVM adds a third mode to the standard
kernel and user modes, the guest mode.
 Guest
mode processes are processes that are
run from within the virtual machine.
 The guest mode, just like the normal mode, has
its own kernel and user-space variations.
Andrea Chierici
3
Key Features (1)

Overcommitting
 allocating
more virtualized CPUs or memory
than the available resources on the system.
 CPU overcommitting allows virtualized guests
to run on fewer servers and in higher
densities.
 Memory overcommitting allows hosts to utilize
memory and virtual memory to increase guest
densities.
Andrea Chierici
4
Key Features (2)

KSM
 Kernel
SamePage Merging (KSM) is used by the
KVM hypervisor to allow KVM guests to share
identical memory pages
 These shared pages are usually common
libraries or other identical, high-use data.
 KSM allows for greater guest density of identical
or similar guest operating systems by avoiding
memory duplication.
Andrea Chierici
5
KVM installation

A typical KVM installation consists of the following
components:
 Device
driver for managing the virtualization
hardware; this driver exposes its capabilities via a
character device /dev/kvm.
 User-space component for emulating PC hardware;
currently, this is handled in the user space and is a
lightly modified QEMU process.
 The I/O model is directly derived from QEMU’s, with
support for copy-on-write disk images and other
QEMU features.
Andrea Chierici
6
Packages

To fully utilize the KVM support built into
the kernel the following packages are
required:
 qemu-kvm
 virt-manager
 virt-viewer
 python-virtinst
Andrea Chierici
7
Architecture
Andrea Chierici
8
QEMU


KVM uses a program called QEMU
QEMU is a process emulator that offers many features:





can save and restore the state of the virtual machine with all
programs running
VMs can be equipped with many types of hardware, and virtual
hard disk images can be stored so that they only take up disk
space that the guest OS actually uses
Uses VNC to access the VM display
The OS can be installed both locally on the virtualization node
HDDs or on the SAN. Booting VMs from SAN allows having
diskless servers.
KVM has the ability to take advantage of the latest kernel
optimizations, advancements and hardware compatibility
Andrea Chierici
9
qcow2





qcow2 is a QEMU disk image format.
It is a copy-on-write format.
QEMU can use a base image which is read-only, and
store all writes to the qcow2 image.
Versatile format
Use it to have smaller images (useful if your filesystem
does not support holes, for example on FAT32),


optional AES encryption,
zlib based compression and support of multiple VM
snapshots
Andrea Chierici
10
Libvirt





Libvirt is a hypervisor-independent virtualization API that is
able to interact with the virtualization capabilities of a range of
operating systems.
libvirt is free software available under the GNU Lesser
General Public License.
The libvirt project aims to provide a long term stable C API.
The libvirt Open Source project currently supports Xen,
Qemu, KVM, LXC, OpenVZ, VirtualBox, OpenNebula, and
VMware ESX.
The RHEL libvirt package supports Xen and KVM on RHEL5
and only KVM on RHEL6
Andrea Chierici
11
virsh



The virsh command-line tool is built on the
libvirt management API
operates as an alternative to the graphical
virt-manager application
can be used
 read-only
mode by unprivileged users
 with root access, full administration functionality.


Ideal for scripting virtualization administration
Included in the libvirt-client package.
Andrea Chierici
12
virt-manager





graphical desktop tool for managing virtualized guests
can be used to perform virtualization administration,
virtualized guest creation, migration and configuration
tasks
allows access to graphical guest consoles
can view virtualized guests, host statistics, device
information and performance graphs
can manage the local hypervisor and remote
hypervisors using the same interface and methods.
Andrea Chierici
13
Difference between KVM and Xen

Xen is an external hypervisor

assumes control of the machine and divides resources among guests.
 it does have its own scheduler, memory manager, and machine
intialization packages added to Linux
 On the other hand, KVM is part of Linux and uses the regular Linux
scheduler and memory management.


KVM is much smaller and simpler to use; it is also more featureful; for example
KVM can swap guests to disk in order to free RAM.
KVM only run on processors that supports x86 hvm (vt/svm
instructions set)

Xen allows running modified operating systems on non-hvm x86
processors using a technique called paravirtualization.
 KVM does not support paravirtualization for CPU but may support
paravirtualization for device drivers to improve I/O performance.
Andrea Chierici
14
Difference between KVM and VMware
VMware is a proprietary product. KVM is
Free Software released under the GPL.
 Vmware is primarily a piece of software
that fully virtualizes the x86 architecture.
 It is pretty much the industry standard and
has great performance scalability.
 large and complex software package

Andrea Chierici
15
Difference between KVM and
QEMU

QEMU uses emulation; KVM uses
processor extensions (HVM) for
virtualization.
Andrea Chierici
16
Virtualized and emulated devices

Emulated devices are virtual devices which exist entirely in
software.


Emulated drivers may use either a physical device or a virtual
software device


Emulated devices do not require a real hardware device to back
them.
The device level instructions are completely translated by the
KVM hypervisor
A system has a number of virtual CPUs (VCPUs) relative to
the number of physical processor cores.

The number of virtual CPUs is finite and represents the total
number of virtual CPUs that can be assigned to guest virtual
machines.
Andrea Chierici
17
Para-virtualized drivers (1)

Para-virtualized drivers are device drivers
that increase the I/O performance of
virtualized guests.
 Para-virtualized
drivers decrease I/O latency and
increase I/O throughput to near bare-metal levels
 must be installed on the guest operating system


Included in latest RHEL4,5,6
Must be manually installed on windows guests
Andrea Chierici
18
Para-virtualized drivers (2)


Para-virtualized network driver
Para-virtualized block driver



all storage devices supported by the hypervisor attached to the
virtualized guest
Para-virtualized clock
Balloon driver

allows guests to express to the hypervisor how much memory they
require
 allows the host to efficiently allocate memory to the guest and allow free
memory to be allocated to other guests and processes
 Guests can mark sections of the guest's RAM as not in use (balloon
inflation)
 When the guest requires the freed memory again, the hypervisor can
reallocate RAM to the guest (balloon deflation)
Andrea Chierici
19
KVM VM Migration (1)

Migration is the term for the process of moving a virtualized
guest from one host to another



Offline
Live
useful for:




Load balancing - guests can be moved to hosts with lower usage
Hardware failover - when hardware devices on the host start to
fail
Energy saving - guests can be redistributed to other hosts and
host systems powered off to save energy and cut costs in low
usage periods.
Geographic migration - guests can be moved to another location
for lower latency or in serious circumstances
Andrea Chierici
20
KVM VM Migration (2)

Migration only moves the virtualized guest's memory.

The guest's storage is located on networked storage which
is shared between the source host and the destination.
 Without shared storage migration is not possible

Offline migration suspends the guest then moves an
image of the guest's memory to the destination host

Live migration is the process of migrating a running
guest from one physical host to another physical host
Andrea Chierici
21
KVM requirements

The KVM hypervisor requires:

an Intel processor with the Intel VT and the Intel 64 extensions, or
 an AMD processor with the AMD-V and the AMD64 extensions.

The working guest storage methods are:









files on local storage,
physical disk partitions,
locally connected physical LUNs,
LVM partitions,
NFS shared file systems,
iSCSI,
GFS2 clustered file systems, and
Fibre Channel-based LUNs
SRP devices (SCSI RDMA Protocol), the block export protocol used in
Infiniband and 10GbE iWARP adapters.
Andrea Chierici
22
KVM limitations






Virtualized guests support up to a maximum of 64 virtualized CPUs
in Red Hat Enterprise Linux 6.0
It is not recommended to have more than 10 virtual CPUs per
physical processor core
SCSI emulation is limited to 16 virtualized (emulated) SCSI devices.
KVM is limited to a maximum of four virtualized (emulated) IDE
devices per guest
Para-virtualized devices, which use the virtio drivers, are PCI
devices. Presently, guests are limited to a maximum of 32 PCI
devices
Live migration is only possible with CPUs from the same vendor
(that is, Intel to Intel or AMD to AMD only).
Andrea Chierici
23
Application limitations


There are aspects of virtualization which make
virtualization unsuitable for certain types of
applications.
Applications with high I/O throughput requirements
should use the para-virtualized drivers for fully
virtualized guests.
 Without
the para-virtualized drivers certain
applications may be unstable under heavy I/O loads.
 The following applications should be avoided for their
high I/O requirement reasons: kdump, netdump
servers
Andrea Chierici
24
KVM compatibility
Operating system
Red Hat Enterprise Linux 3 x86
Red Hat Enterprise Linux 4 x86
Support level
Optimized with para-virtualized drivers
Optimized with para-virtualized drivers
Red Hat Enterprise Linux 4 AMD 64 and Intel 64
Optimized with para-virtualized drivers
Red Hat Enterprise Linux 5 x86
Optimized with para-virtualized drivers
Red Hat Enterprise Linux 5 AMD 64 and Intel 64
Optimized with para-virtualized drivers
Red Hat Enterprise Linux 6 x86
Optimized with para-virtualized drivers
Red Hat Enterprise Linux 6 AMD 64 and Intel 64
Optimized with para-virtualized drivers
Fedora 12 x86
Fedora 12 AMD 64 and Intel 64
Fedora 13 x86
Fedora 13 AMD 64 and Intel 64
Windows Server 2003 R2 32-Bit
Windows Server 2003 R2 64-Bit
Optimized with para-virtualized
Optimized with para-virtualized
Optimized with para-virtualized
Optimized with para-virtualized
Optimized with para-virtualized
Optimized with para-virtualized
Windows Server 2003 Service Pack 2 32-Bit
Optimized with para-virtualized drivers
Windows Server 2003 Service Pack 2 64-Bit
Optimized with para-virtualized drivers
Windows XP 32-Bit
Windows Vista 32-Bit
Windows Vista 64-Bit
Windows Server 2008 32-Bit
Windows Server 2008 (and R2) 64-Bit
Windows 7 32-Bit
Windows 7 64-Bit
Optimized with para-virtualized
Supported
Supported
Optimized with para-virtualized
Optimized with para-virtualized
Optimized with para-virtualized
Optimized with para-virtualized
Andrea Chierici
drivers
drivers
drivers
drivers
drivers
drivers
drivers
drivers
drivers
drivers
drivers
25
References
KVM: http://www.linux-kvm.org
 Libvirt: http://libvirt.org
 QEMU: http://wiki.qemu.org/Manual
 Gruppo virtualizzazione CCR
[email protected]

Andrea Chierici
26