Contents
kvm ( Kernel-based Virtual Machine )
grep -E '^flags.*(vmx|svm)' /proc/cpuinfo
Packages
- qemu-kvm 1.2.0
- qemu-1.7.0
- libvirt-1.2.0
- virtio-win-0.1-74
- virt-manager 0.10.0 – virtinst 0.600.4 – virt-viewer 0.5.7
- augeas-1.1.0
- febootstrap 3.18 [deprecated]
- supermin-4.1.5
- hivex-1.3.8
- libguestfs-1.24.2
qemu-kvm -hda WinXP.vmdk -win2k-hack -m 256 -vga std -boot d -cdrom WinXP.iso -no-acpi -localtime
qemu-kvm winxp.qcow2 -cdrom winxp.iso
qemu-kvm archlinux.vdi
# qemu-img convert -f vdi win2003.vdi -O qcow2 win2003.qcow2 # qemu-img convert -f qcow2 winxp.qcow2 -O qed winxp.qed
qemu-img create -f qcow2 virtualdisk 5G
$ qemu-img info WinXP.vmdk image: WinXP/WinXP-disk1.vmdk file format: vmdk virtual size: 4.0G (4294967296 bytes) disk size: 3.6G
kvm archlinux.qcow2
qemu-img -f qcow2 vdisk1 10g qemu-img -f qcow2 vdisk2 10g qemu-img -f qcow2 vdisk3 10g qemu-img -f qcow2 vdisk4 10g kvm \ -cdrom systemrescuecd-x86-2.3.1.iso \ -drive file=vdisk1,if=virtio \ -drive file=vdisk2,if=virtio \ -drive file=vdisk3,if=virtio \ -drive file=vdisk4,if=virtio
User Authentication
sudo saslpasswd2 -a libvirt ebal Password: ****** Again (for verification): ******
kvm on lvm
# lvcreate -L 5G vg01 -n winxp # kvm -cpu host -m 2048 /dev/vg01/winxp -cdrom winxp.iso -boot d
kvm on lvm on virtio
qemu-kvm -drive file=/dev/vg01/wintest,if=virtio -cdrom winxp.iso -m 1024 -usb -fda viostor-0.1-22.img -cpu host -boot d
virsh qemu-attach
qemu-kvm /dev/vg01/wintest -cdrom winxp.iso -m 1024 -usbdevice tablet -name wintest -vnc :1 -monitor unix:/tmp/wintest,server,nowait -boot menu=on -fda viostor-0.1-22.img virsh qemu-attach PID
kernel initrd
Boot specific kernel image with initrd image
/usr/bin/qemu-system-x86_64 -kernel vmlinuz -initrd core.gz
dnsmasq
default example
<network> <name>default</name> <uuid>20afd66e-3b86-4d3d-b7d8-57d03c28ef0c</uuid> <bridge name="virbr0"/> <forward/> <ip address="192.168.122.1" netmask="255.255.255.0"> <dhcp> <range start="192.168.122.2" end="192.168.122.254"/> <host mac='52:54:00:ea:05:c5' name='winxp' ip='192.168.122.20' /> </dhcp> </ip> </network>
qemu-kvm supported machine types
qemu-kvm -M ?
qemu-kvm driver
qemu-kvm -device ?
libvirt operating system support
virt-install --os-variant list
spice channel
host
-device virtio-serial -chardev spicevmc,id=vdagent,name=vdagent -device virtserialport,chardev=vdagent,name=com.redhat.spice.0
usb
# lsusb Bus 001 Device 010: ID 058f:6387 Alcor Micro Corp. Flash Drive
sudo kvm winxp.clone -m 1024 -usb -device usb-host,hostbus=1,hostaddr=10 -cpu host -usbdevice tablet
arm
qemu-system-arm -M versatilepb -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile -hda debian_lenny_armel_standard.qcow2 -append "root=/dev/sda1"