About KVM Advantages of Virtualization Using KVM Use Cases Linux Kernel-based Virtual Machine Features of KVM and how to use it in SOHO/SME Sven Vermeulen HCC Vlaanderen 2010/10/04 - Mechelen(Tisselt) Summary About KVM Advantages of Virtualization Outline 1 About KVM What is KVM Using KVM Use Cases Summary About KVM Advantages of Virtualization Outline 1 About KVM What is KVM 2 Advantages of Virtualization At Home At Work (SO) At Work (ME) Using KVM Use Cases Summary About KVM Advantages of Virtualization Outline 1 About KVM What is KVM 2 Advantages of Virtualization At Home At Work (SO) At Work (ME) 3 Using KVM Plain Qemu Using libvirt Using KVM Use Cases Summary About KVM Advantages of Virtualization Outline 1 About KVM What is KVM 2 Advantages of Virtualization At Home At Work (SO) At Work (ME) 3 Using KVM Plain Qemu Using libvirt 4 Use Cases Example Use Cases Using KVM Use Cases Summary About KVM Advantages of Virtualization What is KVM Outline 1 About KVM What is KVM 2 Advantages of Virtualization At Home At Work (SO) At Work (ME) 3 Using KVM Plain Qemu Using libvirt 4 Use Cases Example Use Cases Using KVM Use Cases Summary About KVM Advantages of Virtualization Using KVM What is KVM Linux Kernel-based Virtual Machine Built on the Linux operating system. Use Cases Summary About KVM Advantages of Virtualization Using KVM What is KVM Linux Kernel-based Virtual Machine Built on the Linux operating system. Is heavily relying on kernel-based features Use Cases Summary About KVM Advantages of Virtualization Using KVM Use Cases What is KVM Linux Kernel-based Virtual Machine Built on the Linux operating system. Is heavily relying on kernel-based features Requires x86 hardware with virtualization extensions Intel VT (vmx) AMD-V (svm) and only provides virtual x86 environments Summary About KVM Advantages of Virtualization Using KVM Use Cases What is KVM Uses QEMU As “Runtime” http://wiki.qemu.org Generic, Open Source machine emulator and virtualizer Can use virtualization APIs (“hypervisor”)... Summary About KVM Advantages of Virtualization Using KVM Use Cases What is KVM Uses QEMU As “Runtime” http://wiki.qemu.org Generic, Open Source machine emulator and virtualizer Can use virtualization APIs (“hypervisor”)... but also supports full software emulation Summary About KVM Advantages of Virtualization Using KVM Use Cases What is KVM Uses QEMU As “Runtime” http://wiki.qemu.org Generic, Open Source machine emulator and virtualizer Can use virtualization APIs (“hypervisor”)... but also supports full software emulation Features Pass-through hardware access (esp. useful for USB) Summary About KVM Advantages of Virtualization Using KVM Use Cases What is KVM Uses QEMU As “Runtime” http://wiki.qemu.org Generic, Open Source machine emulator and virtualizer Can use virtualization APIs (“hypervisor”)... but also supports full software emulation Features Pass-through hardware access (esp. useful for USB) raw disk image, copy-on-write images, native disk storage and VMWare images Summary About KVM Advantages of Virtualization Using KVM Use Cases What is KVM Uses QEMU As “Runtime” http://wiki.qemu.org Generic, Open Source machine emulator and virtualizer Can use virtualization APIs (“hypervisor”)... but also supports full software emulation Features Pass-through hardware access (esp. useful for USB) raw disk image, copy-on-write images, native disk storage and VMWare images multiple CPUs (up to 255) Summary About KVM Advantages of Virtualization Using KVM Use Cases What is KVM Uses QEMU As “Runtime” http://wiki.qemu.org Generic, Open Source machine emulator and virtualizer Can use virtualization APIs (“hypervisor”)... but also supports full software emulation Features Pass-through hardware access (esp. useful for USB) raw disk image, copy-on-write images, native disk storage and VMWare images multiple CPUs (up to 255) virtual networking support (incl. access to real network) Summary About KVM Advantages of Virtualization Using KVM Use Cases Summary What is KVM And KVM as “hypervisor” Uses Linux features: Is able to swap out running images (just regular processes) About KVM Advantages of Virtualization Using KVM Use Cases Summary What is KVM And KVM as “hypervisor” Uses Linux features: Is able to swap out running images (just regular processes) Can optimize memory usage using Kernel Sharedpage Merging and a balloon driver About KVM Advantages of Virtualization Using KVM Use Cases Summary What is KVM And KVM as “hypervisor” Uses Linux features: Is able to swap out running images (just regular processes) Can optimize memory usage using Kernel Sharedpage Merging and a balloon driver Supports resource management using control groups About KVM Advantages of Virtualization Using KVM Use Cases Summary What is KVM And KVM as “hypervisor” Uses Linux features: Is able to swap out running images (just regular processes) Can optimize memory usage using Kernel Sharedpage Merging and a balloon driver Supports resource management using control groups Supports paravirtualized PCI, networking and serial access About KVM Advantages of Virtualization Using KVM Use Cases Summary What is KVM And KVM as “hypervisor” Uses Linux features: Is able to swap out running images (just regular processes) Can optimize memory usage using Kernel Sharedpage Merging and a balloon driver Supports resource management using control groups Supports paravirtualized PCI, networking and serial access Runtime environments run as user processes but About KVM Advantages of Virtualization Using KVM Use Cases Summary What is KVM And KVM as “hypervisor” Uses Linux features: Is able to swap out running images (just regular processes) Can optimize memory usage using Kernel Sharedpage Merging and a balloon driver Supports resource management using control groups Supports paravirtualized PCI, networking and serial access Runtime environments run as user processes but is definitely not limited to running Linux guests FreeBSD, Windows (3.11 - 7), MacOS, Android, ChromeOS, ... About KVM Advantages of Virtualization Using KVM Use Cases What is KVM Development KVM is part of Linux kernel development Major development within RedHat labs Qemu through the Qemu project Both are very active Qemu had 4 releases in 2010 KVM is continuously updated with Linux kernel updates Summary About KVM Advantages of Virtualization At Home Outline 1 About KVM What is KVM 2 Advantages of Virtualization At Home At Work (SO) At Work (ME) 3 Using KVM Plain Qemu Using libvirt 4 Use Cases Example Use Cases Using KVM Use Cases Summary About KVM Advantages of Virtualization Using KVM Use Cases At Home Why Virtualization Test out new operating systems (new Ubuntu release) Summary About KVM Advantages of Virtualization Using KVM Use Cases At Home Why Virtualization Test out new operating systems (new Ubuntu release) Isolate dangerous applications (malware-sensitive applications) Demo’s follow later Summary About KVM Advantages of Virtualization At Work (SO) Outline 1 About KVM What is KVM 2 Advantages of Virtualization At Home At Work (SO) At Work (ME) 3 Using KVM Plain Qemu Using libvirt 4 Use Cases Example Use Cases Using KVM Use Cases Summary About KVM Advantages of Virtualization Using KVM At Work (SO) Why Virtualization Simple full-system backups (disk images) Use Cases Summary About KVM Advantages of Virtualization Using KVM At Work (SO) Why Virtualization Simple full-system backups (disk images) Server running multiple servers (cheaper) Use Cases Summary About KVM Advantages of Virtualization Using KVM Use Cases At Work (SO) Why Virtualization Simple full-system backups (disk images) Server running multiple servers (cheaper) Easy testing (snapshot, try upgrade, rollback, ...) Summary About KVM Advantages of Virtualization Using KVM Use Cases Summary At Work (SO) Why Virtualization Simple full-system backups (disk images) Server running multiple servers (cheaper) Easy testing (snapshot, try upgrade, rollback, ...) Desktop virtualization (provisioning, patches, upgrades, ...) Demo’s follow later About KVM Advantages of Virtualization At Work (ME) Outline 1 About KVM What is KVM 2 Advantages of Virtualization At Home At Work (SO) At Work (ME) 3 Using KVM Plain Qemu Using libvirt 4 Use Cases Example Use Cases Using KVM Use Cases Summary About KVM Advantages of Virtualization Using KVM Use Cases At Work (ME) Decouple hardware from software (migration) Summary About KVM Advantages of Virtualization Using KVM Use Cases At Work (ME) Decouple hardware from software (migration) Elevate security requirements (disk encryption, host access, ...) Summary About KVM Advantages of Virtualization Using KVM Use Cases Summary At Work (ME) Decouple hardware from software (migration) Elevate security requirements (disk encryption, host access, ...) Simplified multi-system management (but requires additional tools) Sorry, no demo’s on this part due to too little available resources About KVM Advantages of Virtualization Plain Qemu Outline 1 About KVM What is KVM 2 Advantages of Virtualization At Home At Work (SO) At Work (ME) 3 Using KVM Plain Qemu Using libvirt 4 Use Cases Example Use Cases Using KVM Use Cases Summary About KVM Advantages of Virtualization Using KVM Use Cases Plain Qemu Plain Qemu Commands Most advanced, yet least user friendly aspect Let us demonstrate: Create a (virtual) disk Boot a CD Install a new operating system Create a new image with the first image as base Play with the new operating system We’ll pick Ubuntu 10.04, but first... Summary About KVM Advantages of Virtualization Using KVM Plain Qemu Setup Qemu Networking Virtual network with virtual hub/switch Connect virtual network with real network Allow Internet access from virtual network Example modprobe t u n modprobe kvm−i n t e l t u n c t l −b −u s w i f t −t tap0 i f c o n f i g tap0 1 9 2 . 16 8. 10 0.1 up vde_switch −−numports 4 −−hub −−mod 777 \ −−group users −−t a p tap0 −d s h a r e _ i n t e r n e t . sh echo 1 > / sys / k e r n e l /mm/ ksm / run Okay, now onto the demonstration Use Cases Summary About KVM Advantages of Virtualization Using KVM Plain Qemu Create disk image Create an empty disk of about 20Gb Use type qcow2 (copy-on-write) Example qemu−img c r e a t e −f qcow2 imagename . img 20G Use Cases Summary About KVM Advantages of Virtualization Using KVM Use Cases Summary Plain Qemu Boot from ISO Boot from a downloaded ISO The default console can be accessed using vnc Install the Ubuntu 10.04 operating system Example kvm \ −n e t n i c , model= v i r t i o , macaddr = 0 0 : 1 1 : 2 2 : 3 3 : 4 4 : a0 , v l a n =0 \ −n e t vde , v l a n =0 \ −d r i v e f i l e =imagename . img , i f = v i r t i o , boot=on \ −usb −usbdevice t a b l e t −k n l −be −m 512 \ −cdrom / s r v / v i r t / media / ubuntu −10.04.1− desktop−amd64 . i s o \ −boot d About KVM Advantages of Virtualization Using KVM Use Cases Plain Qemu Use a base image Now we use the image as a base... and then boot the new image Example qemu−img c r e a t e −f qcow2 \ −o b a c k i n g _ f i l e =imagename . img t e s t . img We can always rebase such images when we want to Summary About KVM Advantages of Virtualization Using libvirt Outline 1 About KVM What is KVM 2 Advantages of Virtualization At Home At Work (SO) At Work (ME) 3 Using KVM Plain Qemu Using libvirt 4 Use Cases Example Use Cases Using KVM Use Cases Summary About KVM Advantages of Virtualization Using KVM Use Cases Using libvirt What is libvirt? Open-source API for platform virtualization (supporting KVM, Xen, VMWare) Used by oVirt, virt-manager, virsh Backed by RedHat Advantages over ’regular’ Qemu: Summary About KVM Advantages of Virtualization Using KVM Use Cases Using libvirt What is libvirt? Open-source API for platform virtualization (supporting KVM, Xen, VMWare) Used by oVirt, virt-manager, virsh Backed by RedHat Advantages over ’regular’ Qemu: ’Domains’ run in the background Summary About KVM Advantages of Virtualization Using KVM Use Cases Using libvirt What is libvirt? Open-source API for platform virtualization (supporting KVM, Xen, VMWare) Used by oVirt, virt-manager, virsh Backed by RedHat Advantages over ’regular’ Qemu: ’Domains’ run in the background Technology-agnostic Summary About KVM Advantages of Virtualization Using KVM Use Cases Using libvirt What is libvirt? Open-source API for platform virtualization (supporting KVM, Xen, VMWare) Used by oVirt, virt-manager, virsh Backed by RedHat Advantages over ’regular’ Qemu: ’Domains’ run in the background Technology-agnostic Simple(r) interface Summary About KVM Advantages of Virtualization Using KVM Use Cases Using libvirt Setting up the network Libvirt does not support VDE yet, so requires bridging setup Bridging creates central connection points (bridge) where multiple tap devices can be attached on Summary About KVM Advantages of Virtualization Using KVM Use Cases Using libvirt Setting up the network Libvirt does not support VDE yet, so requires bridging setup Bridging creates central connection points (bridge) where multiple tap devices can be attached on Setup is like before, but now with additional commands: Example b r c t l addbr br0 b r c t l a d d i f br0 tap0 Summary About KVM Advantages of Virtualization Using KVM Use Cases Using libvirt Create a virtual environment Give the runtime a name Use the bridge:br0 networking interface Example v i r t − i n s t a l l −−connect qemu : / / / system −n win7 \ −r 1024 −−vcpus=2 \ −−d i s k path = / s r v / v i r t / win7 / win7base . img , s i z e =20 \ −−vnc −−noautoconsole −−os−t y p e windows \ −−a c c e l e r a t e −−network b r i d g e : br0 \ −−cdrom / s r v / v i r t / media / win7dvd . i s o Summary About KVM Advantages of Virtualization Using KVM Use Cases Using libvirt Working with a virtual environment The virsh tool supports various command-line options Summary About KVM Advantages of Virtualization Using KVM Use Cases Summary Using libvirt Working with a virtual environment The virsh tool supports various command-line options The virt-viewer tool is a VNC viewer that integrates with the domain names About KVM Advantages of Virtualization Using KVM Use Cases Summary Using libvirt Working with a virtual environment The virsh tool supports various command-line options The virt-viewer tool is a VNC viewer that integrates with the domain names The virt-manager tool is a all-in-one graphical tool About KVM Advantages of Virtualization Using KVM Use Cases Summary Using libvirt Working with a virtual environment The virsh tool supports various command-line options The virt-viewer tool is a VNC viewer that integrates with the domain names The virt-manager tool is a all-in-one graphical tool Guess which one we’ll show ;-) About KVM Advantages of Virtualization Example Use Cases Outline 1 About KVM What is KVM 2 Advantages of Virtualization At Home At Work (SO) At Work (ME) 3 Using KVM Plain Qemu Using libvirt 4 Use Cases Example Use Cases Using KVM Use Cases Summary About KVM Advantages of Virtualization Using KVM Use Cases Summary Example Use Cases Testing Try out a new operating system Try out a large upgrade Temporarily install garbage Try out a clean-up We need: qcow2 copy-on-write support (can be against a partition or lvm snapshot), or storage snapshoting About KVM Advantages of Virtualization Using KVM Use Cases Example Use Cases Development Support Development of multi-platform supporting application Test application on several distributions or versions Regression tests on new, upgrade, downgrade and other scenarios We need: Multiple virtual instances Large environment management tooling, like cfengine or jobscheduler qcow2 copy-on-write support Summary About KVM Advantages of Virtualization Using KVM Use Cases Example Use Cases Uninterruptible Process Long-running process (for instance, video rendering) You need a safepoint in case you need to make a potentially destructive decision We need: qcow2 savevm and loadvm support Summary About KVM Advantages of Virtualization Using KVM Use Cases Example Use Cases V2P or P2V You want to migrate/copy your physical system in a virtual one (P2V), or You want to migrate/copy your virtual system to a physical (V2P) We need: Good backup/restore software ;-) Summary About KVM Advantages of Virtualization Using KVM Use Cases Summary So now we know a bit more on virtualization how to run virtual instances ourselves a couple of benefits of using virtual environments Summary About KVM ? Advantages of Virtualization Using KVM Use Cases Summary
© Copyright 2024