Introduction to
Virtualization & KVM
By Zahra Moezkarimi
Outline
Virtualization
– History – Overview
– Advantages and Limitations – Types of virtualization
– Virtualization and Cloud Computing
KVM
– Overview – Features – Tools
History
Virtualization is not a new concept
We focus on virtualization concepts related to the data center
60s’ IBM - CP/CMS on S360, …
1998 VMWare
2003 Xen
Then KVM/Hyper-v, …
Overview
The physical server is called the host
The virtual servers are called guests
Hypervisor (Virtual Machine Manager)
Advantages and Limitations
Advantages
R&D (Agility, Testing) Cost effectiveness
Maintenance
High Availability
Dynamic Load Balancing Less energy consumption Less space
Environmental Issues Migration
Limitations
Not suitable for applications with high demands on processing power Implementation and maintenance difficulties
Types of virtualization
What hardware we can virtualized?
Virtualization falls into three categories:
– Operating System – Storage
– Applications
Types of virtualization (Cont.)
Operating System Virtualization Application Server Virtualization Application Virtualization Management Virtualization Network Virtualization Hardware Virtualization Storage Virtualization Service Virtualization
Service Virtualization
The macro definition of virtualization
Delivering an application over the network Application availability
Typical X86 virtualization approaches
How our VMs interact with physical hardware? Para-virtualization (PV)
– Para virtualization approach, like Xen
– Modified guest OS aware and co-work with VMM Binary Translation (BT)
– Full virtualization approach, like VMWare – Unmodified guest OS
– Translate binary ‘on-the-fly’
Typical X86 virtualization approaches (Cont.)
Hardware-assisted Virtualization
– Full virtualization approach assisted by hardware, like KVM
– Unmodified guest OS – Intel VT-x, AMD-v – Benefits:
Virtualization and cloud computing
Cloud vs Grid, Virtualization and Autonomic computing
Rapid scaling of resources Migration Concept
– Online migration – Offline migration – Virtual-to-Virtual – Physical-to-Virtual
KVM
Overview Features Tools
Qemu & KVM
KVM - overview
Kernel-based Virtual Machine
Linux kernel module (since 2.6.20) Created by Quramnet
bought by Red Hat 2008
Supports x86 (32 and 64 bit), s390, Powerpc
Needs a CPU with virtualization extention (Intel VT or AMD-V)
KVM – overview (cont.)
Unmodified guest images
Each VM has private virtualized hardware Open source software
KVM Architecture
KVM – Features
Some KVM features include:
CPU and memory overcommit High performance paravirtual I/O Hotplug (cpu, block, nic)
KVM - Tools
libvirt (API) Virsh Qemu VirtManager LibguestfsKVM and QEMU
libvirt + Virtual Machine Manager GUI choose the ‘Virt Type’ as:
– KVM – QEMU
a grep of the process ID The acceleration type
Hardware Acceleration
Virtual CPU is actually emulated
Hypervisor has to translate the instructions performance overhead
Modern processors support virtualization extensions
In VT, a slice of physical CPU can be directly mapped to the Virtual CPU
KVM enables this mapping of physical CPU to Virtual CPU TCG: Tiny Code Generator
KVM and QEMU connection
QEMU
– A powerful emulator
– Can emulate a variety of processor types
KVM
– uses hardware extension
– merges its functionality to upstream Qemu
QEMU can make use of KVM when running a target architecture that is the same as the host architecture
Set up a VM
Have a Linux OS X86-64 architecture (arch)
Intel/AMD CPU (egrep –c 'vmx|svm' /proc/cpuinfo) – vmx Intel VT
– svm AMD-V
Check system bios (BIOS, Advanced, CPU option)
apt-get install qemu qemu-kvm kvm virt-manager libvirt libvirt-bin bridge-utils uml-utilities
Kvm-ok (INFO: /dev/kvm exists KVM acceleration can be used ) modprobe kvm-intel nested=1
qemu-img create xamin.qcow2 20G
Set up a VM (Cont.)
Network setting – brctl show – brctl addif br0 eth0 – ifconfig eth0 0.0.0.0 up – ifconfig br0 up – dhclient br0 First time (install):
– kvm -cpu host -m 2G -hda xamin.qcow2 -cdrom xamin.iso -device e1000,netdev=net0 -netdev tap,id=net0 -enable-kvm
Next time (boot):
– sudo kvm cpu host m 2G hda xamin.qcow2 device e1000,netdev=net0 netdev tap,id=net0 -enable-kvm