Introduction to Virtualization & KVM By Zahra Moezkarimi ICT Research Institute Software Platform Laboratory
Outline Virtualization History Overview Advantages and Limitations Types of virtualization Virtualization and Cloud Computing KVM Overview Features Tools QEMU & KVM Set up and Configure a VM KVM and Cloud Computing November 2014 Introduction to Virtualization and KVM 2
History Virtualization is not a new concept We focus on virtualization concepts related to the data center 60s 1998 2003 IBM - CP/CMS on S360, VMWare Xen Then KVM/Hyper-v, November 2014 Introduction to Virtualization and KVM 3
Overview The physical server is called the host The virtual servers are called guests Hypervisor (Virtual Machine Manager) Type 1 (runs directly on hardware) Type 2 (runs on a host OS) November 2014 Introduction to Virtualization and KVM 4
Advantages Advantages and Limitations 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 November 2014 Introduction to Virtualization and KVM 5
Types of virtualization What hardware we can virtualized? Virtualization falls into three categories: Operating System Storage Applications It s helpful to distill these broader categories into eight! November 2014 Introduction to Virtualization and KVM 6
Types of virtualization (Cont.) Operating System Virtualization Application Server Virtualization Application Virtualization Management Virtualization Network Virtualization Hardware Virtualization Storage Virtualization Service Virtualization November 2014 Introduction to Virtualization and KVM 7
Service Virtualization The macro definition of virtualization Delivering an application over the network Application availability No final definition! November 2014 Introduction to Virtualization and KVM 8
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 November 2014 Introduction to Virtualization and KVM 9
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: Simplify VMM software Optimizing for performance November 2014 Introduction to Virtualization and KVM 10
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 November 2014 Introduction to Virtualization and KVM 11
KVM Overview Features Tools Qemu & KVM Set up and Configure a VM KVM and Cloud Computing November 2014 Introduction to Virtualization and KVM 12
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) November 2014 Introduction to Virtualization and KVM 13
KVM overview (cont.) Unmodified guest images Each VM has private virtualized hardware Open source software KVM's parts are licensed under various GNU licenses Open Virtualization Alliance (OVA) November 2014 Introduction to Virtualization and KVM 14
KVM Architecture November 2014 Introduction to Virtualization and KVM 15
KVM Features Some KVM features include: CPU and memory overcommit High performance paravirtual I/O Hotplug (cpu, block, nic) SMP guests Live Migration Power management November 2014 Introduction to Virtualization and KVM 16
KVM - Tools libvirt (API) Virsh Qemu VirtManager Libguestfs November 2014 Introduction to Virtualization and KVM 17
KVM and QEMU libvirt + Virtual Machine Manager GUI choose the Virt Type as: KVM QEMU a grep of the process ID The acceleration type KVM: accel=kvm QEMU: accel=tcg November 2014 Introduction to Virtualization and KVM 18
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 November 2014 Introduction to Virtualization and KVM 19
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 Near native performance QEMU Type-2 hypervisor QEMU + KVM Type-1 hypervisor November 2014 Introduction to Virtualization and KVM 20
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 umlutilities Kvm-ok (INFO: /dev/kvm exists KVM acceleration can be used ) modprobe kvm-intel nested=1 qemu-img create xamin.qcow2 20G November 2014 Introduction to Virtualization and KVM 21
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 Visual Tools VMM / Virtual Machine Manager Aqemu GKVM November 2014 Introduction to Virtualization and KVM 22
KVM and Cloud Computing KVM as a backend for cloud solutions and Businesses Openstack OpenNebula Eucalyptus Vmmanager November 2014 Introduction to Virtualization and KVM 23
Future Work Memory virtualization approaches I/O virtualization approaches KVM best practices Migration Virtual-to-Virtual Physical-to-Virtual November 2014 Introduction to Virtualization and KVM 24
Thanks moezkarimi@itrc.ac.ir November 2014 Introduction to Virtualization and KVM 25