Virtualizace
Tomas Krajca, xkrajca@fi.muni.cz
Obsah
VM ~ hypervisor(host, guest1...guestn)
Guestn ~ VHDDs + VNICs + VPrinters + VCPUs + VRAM + ... + VT
Motivation
Benefits
- Virtual HW never gets old (out of warranty)
- Migration
- Resource utilization/energy consumption
- Scalability/availability
- Disaster recovery scenarios
Shortcomings
- Complexity/special knowledge of V technologies
- Propagation of a single physical HW failure
Types of virtualization
- Containers/OS-level virtualization
- Multiple isolated user-space instances in one OS - resource/impact limitation for each user
- Virtual hosting environments, Applications isolation
- +Little overhead, -not as flexible
- Chroot, BSD jail, VServer, OpenVZ/Virtuozzo, ...
- HW emulation
- Emulates specific type of HW for guests (i386, x86_64, mips, ...)
- Dynamic binary translation, precompiled
- +Simple/fast, -not as flexible
- QEMU (qemu-system-x86_64, qemu-system-mips, ...)
- Server/desktop virtualization/isolation, HW drivers testing/development
- Paravirtualization
- SW interface of the underlying HW to VMs
- +Certain tasks can be executed directly on HW, -Guest OS has to be ported
- e.g. XEN - Domain 0 (VMM) provides SW interface for Domains U
- Server/desktop virtualization/isolation, cloud computing
- User-mode Linux, Lguest, XEN, VMware
- Full virtualization
- Complete HW simulation
- +Guest OS does not have be ported (guest OS appears to run on bare HW)
- Server/desktop virtualization/isolation, cloud computing
- KVM, XEN, VMware
Virtual managers
- CLI-based - plain qemu/kvm, virsh/libvirt
- GUI-based - VMM/virt-manager
- Cloud-based - Eucalyptus
Virtual hard drives
- vvfat: Virtual VFAT, vpc: Windows Virtual PC
- dmg: Macintosh disk image
- cloop: Linux compressed loop
- vmdk: VMware virtual machine disk format
- qcow2?: QEMU Copy-on-write
- raw: Raw file system
- cow: User-mode Linux copy-on-write
- vdi: VirtualBox
Demo (Qemu/RHEL)
# yum install -y qemu
# qemu-img create -f raw qemu-hdd.raw 5G
Formatting 'qemu-hdd.raw', fmt=raw size=5368709120
# qemu-system-i386 -hda ./qemu-hdd.raw -m 512 -net nic -net user -localtime -boot d -cdrom ubuntu-12.04.1-server-i386.iso -vnc :1 # install
# # net: 10.0.2.0/24, DHCP, VLAN0, GW .2, DNS .3
# qemu-system-i386 -hda ./qemu-hdd.raw -m 512 -net nic -net user -localtime -vnc :1 # boot
# # migration ~ copy/move virtual hard drive, launch again
# cp ./qemu-hdd.raw /backup/qemu-hdd.raw # backup
# qemu-img info ./qemu-hdd.raw
image: qemu-hdd.raw
file format: raw
virtual size: 5.0G (5368709120 bytes)
disk size: 387M
# fdisk -l qemu-hdd.raw
Disk qemu-hdd.raw: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders, total 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000427f0
Device Boot Start End Blocks Id System
qemu-hdd.raw1 2048 9437183 4717568 83 Linux
qemu-hdd.raw2 9439230 10483711 522241 5 Extended
qemu-hdd.raw5 9439232 10483711 522240 82 Linux swap / Solaris
# mount -o loop,offset=$((2048*512)) qemu-hdd.raw tmp/
Literatura