7. KVM : overview
Kernel-based Virtual Machine, a Kernel module that
turns Linux into a hypervisor
Created by Quramnet (bought by Red Hat 2008)
Supports x86 (32 and 64 bit), s390, Powerpc
Included in Linux kernel since 2.6.20
Needs a CPU with virtualization extention !
8. KVM : overview
● Each vm is a process
● Each virtual cpu is a thread
● Open source
9. Features
CPU and memory overcommit
High performance paravirtual I/O
Hotplug (cpu, block, nic)
SMP guests
Live Migration
Power management
11. KVM : differences
Not your typical VMWare workstation or VirtualBox.
VirtManager comes close but still a little rough on the
edges
KVM is meant for virtualization on servers. Desktop
usage is not always ideal
(think vSphere, HyperV,..).
15. Libvirt : overview
● “The Virtualization API”
● Toolkit to interact with the virtualization layer
● Written in C
● LGPL
● Has bindings for common languages (Python,
Ruby, Perl, PHP, Java,..)
● Supports AMQP via libvirt-qpid
16. Libvirt : overview
● Provides management of
– Virtual machines
– Virtual networks
– Storage
● Does NOT provide multi node management
features like load balancing
● Suspend / resume support
25. Virsh usage
Connect to hypervisor on the localhost
virsh connect qemu:///system
virsh connect qemu:///system
or
virsh
virsh
Connect to hypervisor on remote system over SSH
virsh -c qemu+ssh://user@host.domain.foo/system
virsh -c qemu+ssh://user@host.domain.foo/system
27. Virsh : storage
● Define storage pool
● Local filesystem (ext3, ext4,...)
● Directory based
● ISCSI
● NFS
● LVM (uses volume group)
● Physical disk
● multipath
28. Virsh : create storage pool
<pool type="dir">
<name>LOCAL-STORAGE</name>
Xml file -> <target>
<path>/VMS</path>
</target>
</pool>
[root@localhost ~]# virsh pool-define dir_pool.xml
[root@localhost ~]# virsh pool-define dir_pool.xml
Pool LOCAL-STORAGE defined from dir_pool.xml
Pool LOCAL-STORAGE defined from dir_pool.xml
[root@localhost ~]# virsh pool-start LOCAL-STORAGE
[root@localhost ~]# virsh pool-start LOCAL-STORAGE
Pool LOCAL-STORAGE started
Pool LOCAL-STORAGE started
29. Virsh : create storage pool
[root@localhost ~]# virsh pool-list
[root@localhost ~]# virsh pool-list
Name
Name State
State Autostart
Autostart
-----------------------------------------
-----------------------------------------
default
default active
active yes
yes
LOCAL-STORAGE
LOCAL-STORAGE active
active no
no
[root@localhost ~]# virsh
[root@localhost ~]# virsh pool-autostart LOCAL-STORAGE
pool-autostart LOCAL-STORAGE
Pool LOCAL-STORAGE
Pool LOCAL-STORAGE marked as autostarted
marked as autostarted
30. Virsh : create VM
● VM is defined in xml file
● Manual creation of VM's disks
[root@localhost ~]# qemu-img create
[root@localhost ~]# qemu-img create /VMS/vm02-fromxml.img 5G
/VMS/vm02-fromxml.img 5G
Formatting '/VMS/vm02-fromxml.img',
Formatting '/VMS/vm02-fromxml.img', fmt=raw size=5368709120
fmt=raw size=5368709120
● Define VM in libvirt and start it
[root@localhost ~]# virsh define vm02_from_xml.xml
[root@localhost ~]# virsh define vm02_from_xml.xml
Domain vm02-fromxml defined from vm02_from_xml.xml
Domain vm02-fromxml defined from vm02_from_xml.xml
[root@localhost ~]# virsh start vm02-fromxml
[root@localhost ~]# virsh start vm02-fromxml
Domain vm02-fromxml started
Domain vm02-fromxml started
32. Virsh : list vm's
[root@localhost ~]# virsh list --all
[root@localhost ~]# virsh list --all
Id Name
Id Name State
State
----------------------------------
----------------------------------
4 vm01
4 vm01 running
running
- vm02-fromxml
- vm02-fromxml shut off
shut off
[root@localhost ~]#
[root@localhost ~]#
41. virtio
● "full virtualization" is a nice feature because It
allows you to run any operating system
virtualized.
● However, it's slow because the hypervisor has
to emulate actual physical devices.
42. virtio
● Virtio drivers solve this
● Virtio drivers know they run in a virtualized
environment. (no emulation)
● Virtio drivers operate with hypervisor
45. Virt-install
● Can create VM and disks in one go
[root@localhost ~]# virt-install --connect qemu:///system --graphics
[root@localhost ~]# virt-install --connect qemu:///system --graphics
vnc,listen=0.0.0.0 --name=vm01 --ram 512 --disk pool=LOCAL-
vnc,listen=0.0.0.0 --name=vm01 --ram 512 --disk pool=LOCAL-
STORAGE,size=10,bus=virtio,cache=none /
STORAGE,size=10,bus=virtio,cache=none /
--network network=default,model=virtio /
--network network=default,model=virtio /
--location=http://ftp.debian.org/debian/dists/squeeze/main/installer-amd64
--location=http://ftp.debian.org/debian/dists/squeeze/main/installer-amd64
Cannot open display:
Cannot open display:
Run 'virt-viewer --help' to see a full list of available
Run 'virt-viewer --help' to see a full list of available command line
command line
options
options
Domain installation still in progress. You can reconnect
Domain installation still in progress. You can reconnect to
to
the console to complete the installation process.
the console to complete the installation process.
46. Virt-viewer
● Connect to the VM's console with
– RDP
– VNC
– SPICE
● Default vnc port -> 5900
● virt-viewer
virt-viewer -c qemu:///system xpsp2
virt-viewer -c qemu:///system xpsp2
47. virt-clone
● Clones an existing VM (Duh!!)
● Copies disk images
● Defines new machine based on source
– MAC address is auto generated
● Deploy many similar machines from one image
(template).
51. Virtual Machine Manager
● A GUI for virsh and virt-*
● Runs only on Linux/Unix
● Can discover machines running libvirtd (nodes)
● Local development / testing
54. libguestfs
● Manipulation of VM images
● Inspection of VM images
● Exists out of several separate tools
– List is available on http://virt-tools.org/docs/index.html
● No need to login on the VM itself
● Can be run on an active VM
55. What is this image?
Is it still needed?
Developers like to keep stuff
56. Libguestfs : virt-inspector
● What if you just have an image
● You cannot login to machine
● You would like to know what version of a
package is installed
● Generate list of all VM's
57. Libguestfs : virt-inspector
Inspect the domain
virt-inspector -d WIN7
virt-inspector -d WIN7
Inspect an image
[root@HV01 VMS]# virt-inspector -a /var/lib/libvirt/images/WIN7.img
[root@HV01 VMS]# virt-inspector -a /var/lib/libvirt/images/WIN7.img
63. Libguestfs : virt-tar-out
● Create backups from files on the VM
# virt-tar-out -d vm01 /home home-vm01.tar
# virt-tar-out -d vm01 /home home-vm01.tar
● Create backups from files on the disk image
# virt-tar-out -a /VMS/vm01.img /home home-vm01-disk.tar
# virt-tar-out -a /VMS/vm01.img /home home-vm01-disk.tar
65. Virt-v2v : short overview
● Tool to automate migrations to KVM/RHEV
● Migrate to KVM or RHEV from
– XEN
– VMWare
– KVM
● Installs virtio drivers and reconfigures machine
● Can be scripted for bulk operations
71. sVirt
“Old” days
Machines where physically separated
and “attackable” via the network
72.
73. sVirt
With Virtualization :
A flawed hypervisor can give access to ALL VM's
running on it
Bypassing network security
74.
75. sVirt
sVirt :
Apply MAC for guest and resources
MAC policy is set by hypervisor host
Based on SELinux
(don't reinvent the wheel)
Auto apply or manual
82. RHEV 2.x
● RHEV (Red Hat enterprise Virtualization)
– Red Hat started adopting KVM (actually they bought it)
– Released 2.1
– Running on Windows platform ( the horror.. )
– RHEV 2.2 will be latest release in 2.x series
83. RHEV 3.0
● Port from .Net to Java
● Manager runs on Jboss
– no more windows server side
● Hypervisor based on RHEL 6
– Gives performance increase
● Local storage
● Reporing engine included
● WAN optimized SPICE
84. RHEV 3.0
● Power User portal
– Users can manage their own environment
● RESTful API
● Will be open sourced
86. OVA
● Open Virtualization Alliance
● Foster the adoption of KVM as an enterprise-
ready open virtualization solution
● Accelerate the emergence of an ecosystem of
third-party solutions around KVM.
● Encourage interoperability, promote best
practices, and highlight examples of customer
successes.
89. conclusions
● KVM is till young
● Adoption is growing
● Builds on Linux features (feature velocity)
– Selinux, Cgroups, Scheduler, ...
● A lot of community activity
● scalability
● Growing ECO system
● No vendor lockin
● OVA (open virtualization alliance)
93. BoxGrinder : overview
● Create a VM “offline”
● Runs on JBOSS
● Use puppet/chef/.. to configure it further
● Move from Fedora to RHEL by adjusting the file
●