Prepared by Alison Chaiken
October 3, 2010
Offered under cc-by-sa.
The qemu emulator and kvm virtual machine are two of the hottest, slickest technologies on the Linux platform. The qemu-kvm combination provides the user with significant support for hardware virtualization. An OS running under qemu-kvm can interact with and even control devices installed in the host computer.
Why would an ordinary desktop user who doesn't run a datacenter care about virtualization? A few reasons are apparent to me:
alison@tomales ;-) ifconfig virbr0 virbr0 Link encap:Ethernet HWaddr 6E:7E:E9:82:3F:0E inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:11 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:2640 (2.5 KiB)
Begin by installing qemu, qemu-img, qemu-kvm and libvirt. When libvirtd is running, the virbr0 device is created. (See above.) In order to have access to the network, modify /etc/sysctl.conf to allow NAT or bridged networking for your guest system.
Installation of the prebuilt MeeGo qemu image is almost too easy following the detailed instructions. Note the use of a special installation method for qemu-gl:
sudo yum localinstall qemu-gl-0.12.4-5.1.i386-fc12.rpm --nogpgcheck
Also, on Fedora 13 I had to install libvirt in addition to the packages specified on the MeeGo site. libvirt is what provides access to the network. Some configuration of libvirt is necessary using virtsh.
sudo qemugl -name MeeGo -m 1024 -boot c -net nic,model=e1000 -net hostfwd=tcp:127.0.0.1:6666-:22 / -enable-kvm -vga std -enable-gl -device virtio-gl-pci -hda / /opt/meego/meego-netbook-ia32-1.0.80.12.20100727.1-sdk-pre0901.raw
The pre-built MeeGo image starts up remarkably quickly. The fact that the image is running the 2.6.35 kernel (as of October 2010) is impressive, but instead of the much vaunted btrfs filesystem, the prebuilt image has the creaky old ext3. The chromium browser segfaults, perhaps because without forwarding port 80 there's no HTTP connection.
Ssh connections via
ssh meego@127.0.0.1 -p 6666
do work as the documentation suggests.
CORRECTION after 11/2010 MeeGoCon: qflasher is in fact publicly available without an IMEI, if challenging to find. (Thanks, Leinir!) See these helpful instructions. As far as I can make out, there's no way to boot even the "open" handset images without owning an N900 and having access to a valid IMEI. (The situation with the IVI images appears to be similar.) The .ubiimg flash image is available but without the bootloader. Without the bootloader or the qflasher utility, there's no way to create a bootable image. Presumably access to these files is restricted because they contain propietary firmware for the Bluetooth, video and wireless. Following the instructions leads to the error message
qemu: fatal: Trying to execute code outside RAM or ROM at 0x00018020
NOTE: see CORRECTION above. There is a qflasher source rpm available but it doesn't create a qflasher executable. As far as I can make out, users who want to test-drive the handset preview must build from source and use their own flash filesystem creator and bootloader to create a bootable image. Even this option may not be available to all users:
Usage Requirements To be able to use MIC2, your host machine to run mic2 must have Intel(r) Atom(tm) or Intel(r) Core(tm) 2 CPU (support for SSSE3), this is a hard requirement (ARM image is exceptional)
I also tried installing MeeGo using a method similar to PCBSD (below). First create a "hard disk":
alison@bonnet ;-) sudo qemu-img create -f raw /opt/meego/meego1.0-netbook.raw 4G Formatting '/opt/meego/meego1.0-netbook.raw', fmt=raw size=4294967296 alison@bonnet ;-) file /opt/meego/meego1.0-netbook.raw /opt/meego/meego.raw: x86 boot sector; partition 1: ID=0x83, active, starthead 1, startsector 63, 512002 sectors; partition 2: ID=0x83, starthead 223, startsector 512065, 7349579 sectors; partition 3: ID=0x82, starthead 93, startsector 7861644, 524286 sectors, code offset 0xb8
Then run the installer from the "cdrom":
alison@bonnet ;-) sudo qemugl -m 1024 -enable-kvm -boot d -hda /opt/meego/meego1.0-netbook.raw -cdrom /opt/meego/meego-netbook-chromium-ia32-1.0-20100524.1.img -vga std -usb -net nic,model=e1000 -net user,hostfwd=tcp:127.0.0.1:6666-:22 -name meego1.0-netbook -localtime
Then boot from the hard disk:
alison@bonnet ;-) sudo qemugl -name MeeGo -m 1024 -boot c -net nic,model=e1000 -enable-kvm -vga std -enable-gl -device virtio-gl-pci -hda /opt/meego/meego.raw -localtime -no-reboot
Unfortunately a lovely wallpaper comes up, but the image doesn't appear to boot all the way.
Note: requires at least 14 GB of disk space.
qemu-kvm has no man page, so use
qemu-kvm --help
Begin by downloading the 3.6 GB PCBSD 8.1 iso image to INSTALLDIR:
INSTALLDIR=/opt cd $INSTALLDIR wget ftp://mirrors.isc.org/pub/pcbsd/8.1/amd64/PCBSD8.1-x64-DVD.iso
Now create a virtual disk drive image for your new OS to use. The PCBSD bootloader doesn't appear to recognize qemu's native qcow2 format, so use raw. Unfortunately, while a qcow2 image is growable, the raw image is 10 GB in size immediately. The PCBSD installer demands a disk at least this large.
alison@tomales ;-) sudo qemu-img create -f raw $INSTALLDIR/pcbsd.raw 10G Formatting '//pcbsd.raw', fmt=raw size=10737418240 alison@tomales ;-) file $INSTALLDIR/pcbsd.raw /opt/pcbsd.raw: x86 boot sector; partition 1: ID=0xee, active, starthead 1, startsector 1, 20971519 sectors, code offset 0x31
Now boot your ISO and begin the installation:
qemu-kvm --cdrom $INSTALLDIR/PCBSD8.1-x64-DVD.iso -hda // $INSTALLDIR/pcbsd.raw -boot d -m 4096 -vga std -name PCBSD8.1 // -localtime -no-reboot
Here we're provisioning the VM with 4 GB of memory, electing to boot from the CDROM, choosing the standard VGA graphics driver and telling the installer to write to the "disk" image pcbsd.raw. Unless I specified the standard vga, the system defaulted to "cirrus," which did not work.
Just wait and let the bootloader timeout so that the default installer will run. A series of choices will be presented as with most Linux installers. I elected to install all the options (jails, krb, etc.) that were unfamiliar from Fedora 13 with Gnome. Installation took about four hours on a dual-core AMD x86_64 system. The interface in qemu has some oddities, notably that it's necessary to move the cursor away from installer soft buttons to release them. Apparently a button-up event doesn't occur when the mouse button is released, only cursor is moved away. Also, the qemu window will grab the cursor and prevent it from being moved outside the VM window. To release the cursor, the user must press and release the Ctrl-Alt keys.
When the installation is finished, open a terminal window using the launcher in the lower left-hand corner and halt the machine using the new root account.
For subsequent boots, forget about the "cdrom" and boot directly from the new disk image:
qemu-kvm -snapshot -hda $INSTALLDIR/pcbsd.raw -boot c -m 4096 -usb // -soundhw all -net nic,model=e1000 -vga std -net // user,hostfwd=tcp:127.0.0.1:6666-:22 -name PCBSD8.1 -localtime // -no-reboot
For some reason, my PCBSD image is very slow, much slower than the MeeGo one. I'm still investigating why this might be.