Dobrica Pavlinušić's random unstructured stuff
Virtualization workshop: Revision 45
Materijali za "Virtualizacija na Linuxu -- jednostavan izbor zar ne?"<http://www.hroug.hr/hr/hroug_konferencija/u_pripremi/hroug2008_rovinj/predavanja_radionice_demogroundi/radionice/virtualizacija_na_linuxu_jednostavan_izbor_zar_ne>

{toc: }

* "Virtualisation in Debian - Present and future"<https://penta.debconf.org/dc8_schedule/events/275.en.html> - DebConf 2008

^ Hardware

^^ CPU

Support for hardware virtualization:

.pre
egrep '^flags.*(vmx|svm)' /proc/cpuinfo
.pre

| | *vmx/svm* | no vmx/svn |
| *USB* | kvm | qemu+kqemu |
| no USB | VirtualBox | |

How much CPU do I use? :-)

.pre
dpavlin@brr:~$ cpufreq-info
cpufrequtils 004: cpufreq-info (C) Dominik Brodowski 2004-2006
Report errors and bugs to cpufreq@lists.linux.org.uk, please.
analyzing CPU 0:
driver: acpi-cpufreq
CPUs which need to switch frequency at the same time: 0
hardware limits: 2.40 GHz - 3.20 GHz
available frequency steps: 3.20 GHz, 2.80 GHz, 2.40 GHz
available cpufreq governors: userspace, powersave, ondemand, conservative, performance
current policy: frequency should be within 2.40 GHz and 3.20 GHz.
The governor "ondemand" may decide which speed to use
within this range.
current CPU frequency is 2.40 GHz.
cpufreq stats: 3.20 GHz:1.80%, 2.80 GHz:0.00%, 2.40 GHz:98.20% (17)
.pre

^^ Disk performance

{include: [Disk performance]}

^ KVM

{include: [KVM]}

^ QEMU

{include: [QEMU]}

^ VirtualBox

Seems to be best supported right now (package in Debian, optional drivers for Windows, starting unmodified VMWare machines -- after you guess right settings that is!)

* "Windows ACPI problem"<http://www.virtualbox.org/ticket/995> - `agp440.sys` problem
* "How to migrate existing Windows installations to VirtualBox"<http://www.virtualbox.org/wiki/Migrate_Windows> - it's applicable to other emulators as well!

OSE version (no USB!) comes in Debian, compile `vboxdrv` with:

.pre
root@llin:~# module-assistant a-i virtualbox-ose
.pre

^ OpenVZ

{include: [OpenVZ]}

^ VMWare

^^ Convert image to monolithic growable disk

This format is supported by other emulators, so it's a best choice.

.pre
dpavlin@llin:/rest/vmware/winxp$ vmware-vdiskmanager -r Windows\ XP\ Professional.vmdk -t 0 /mnt/usb/vmware/win-xp.vmdk
Using log file /tmp/vmware-dpavlin/vdiskmanager.log
Creating a monolithic growable disk '/mnt/usb/vmware/win-xp.vmdk'
Convert: 57% done.

.pre

^^ Resize disk image

.pre
dpavlin@llin:/mnt/usb/vmware$ qemu-img info win-xp.vmdk
(VMDK) image open: flags=0x2 filename=win-xp.vmdk
image: win-xp.vmdk
file format: vmdk
virtual size: 3.0G (3221225472 bytes)
disk size: 3.0G
.pre

There is a way to extend image using only `qemu-img`, but that involves converting image to raw and appending zeros at end to produce larger image. However, we will do that using VMWare's `vmware-vdiskmanager`

.pre
dpavlin@llin:/mnt/usb/vmware$ vmware-vdiskmanager -x 6Gb win-xp.vmdk
Using log file /tmp/vmware-dpavlin/vdiskmanager.log
Grow: 100% done.
The old geometry C/H/S of the disk is: 6241/16/63
The new geometry C/H/S of the disk is: 12483/16/63
Disk expansion completed successfully.

WARNING: If the virtual disk is partitioned, you must use a third-party
utility in the virtual machine to expand the size of the
partitions. For more information, see:
http://www.vmware.com/support/kb/enduser/std_adp.php?p_faqid=1647
.pre

This will make disk unbootable, so we will have to resize partition. Download "GParted"<http://gparted.sourceforge.net/> live CD and resize partition using it...

.pre
kvm -m 512 -hda win-xp.vmdk -no-acpi -std-vga -cdrom /rest/iso/gparted-live-0.3.9-4.iso -boot d
.pre

^^ Convert vmdk to qcow

.pre
dpavlin@llin:/mnt/usb/vmware$ qemu-img convert -O qcow win-xp.vmdk win-xp.qcow
(VMDK) image open: flags=0x2 filename=win-xp.vmdk
dpavlin@llin:/mnt/usb/vmware$ ls -al win-xp.*
-rw-r--r-- 1 dpavlin dpavlin 3190906880 Oct 9 17:41 win-xp.qcow
-rw------- 1 dpavlin dpavlin 3208577024 Oct 9 17:35 win-xp.vmdk
.pre

^ Xen

^ disk speed

this is domU

.pre
root@vega:~# uname -a
Linux vega 2.6.18-6-xen-amd64 #1 SMP Mon Jun 16 23:42:47 UTC 2008 x86_64 GNU/Linux
root@vega:~# hdparm -tT /dev/hda1

/dev/hda1:
Timing cached reads: 5488 MB in 2.00 seconds = 2750.74 MB/sec
Timing buffered disk reads: 318 MB in 3.00 seconds = 105.98 MB/sec
.pre

^ Guest OS

^^ Windows

* `agp440.sys` "killed my VMWare XP installation!"<http://support.microsoft.com/kb/324764>

* `intelppm.dll` blue screen of death -- http://kvm.qumranet.com/kvmwiki/Windows_ACPI_Workaround

* "Install VBEMP x86 Project Universal VESA/VBE Video Display Driver"<http://www.geocities.com/bearwindows/vbemp.htm> to get different resolutions on virtual machine

Remove them:

.pre
cd c:\windows\system32\drivers
del agp440.sys
del intelppm.dll
.pre

Startup script:

.pre
# 3M RFID 810
usbdev=0403:6001

sudo chown -R $USER /proc/bus/usb/*

kvm -m 512 -hda win-xp.vmdk -no-acpi -std-vga -monitor stdio -usb -usbdevice host:$usbdev
.pre

USB sniffing:

.pre
info usbhost
.pre

^^ Solaris

* http://opensolaris.org/os/project/qemu/QEMUGuests/guest/

It will not boot pass "Loading Nexenta..." stage without `kvm` module loaded.

.pre
# to install from iso image
kvm -m 512 -hda solaris.vmdk -cdrom ../iso/nexenta-core-platform_1.0.1-b85-test4_x86.iso -boot d -net nic,model=rtl8139 -net user

# run after installation
kvm -m 512 -hda solaris.vmdk -net nic,model=rtl8139 -net user
.pre

^^ Darwin

* http://www.puredarwin.org/

^^ Plan 9

* http://wiki.glugcen.dc.uba.ar/Empezando_con_Plan9
* http://www.oszoo.org/wiki/index.php/Plan9_070107.zip