Running PCBSD and MeeGo under qemu-kvm

Prepared by Alison Chaiken
October 3, 2010
Offered under cc-by-sa.

PCBSD desktop in VM
PCBSD desktop running under qemu-kvm on Fedora 13.


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:

  1. Virtualization is potentially an even more convenient route to test-driving a new piece of software than a LiveCD. For example, changes to the virtual hard disk during a qemu-kvm session will be saved, meaning that configurations and preferences need only be entered once. Also, according to Chris Wright of RedHat, qemu-kvm should run at 80% of native speed, much faster than any LiveCD application.
  2. Unlike a LiveCD session, a qemu instance can run applications meant for different hardware. Cross-platform emulation, after all, was the original purpose of qemu.
  3. A qemu-kvm session is contained in a regular desktop window, which can be iconified, paused, sent signals, etc. Thus a user can chat using his/her regular IRC client in one window while running a non-native OS in another. As Greg Marsden pointed out in a recent presentation, profiling and testing an OS running under qemu is easier than when it's running on bare metal.

General instructions for qemu-kvm

alison@tomales ;-) ifconfig virbr0
virbr0    Link encap:Ethernet  HWaddr 6E:7E:E9:82:3F:0E  
          inet addr:  Bcast:  Mask:
          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.

How to get Qemu monitor

Running MeeGo Netbook Image under qemu-gl using pre-built image

MeeGo desktop in VM
As befits a netbook OS, MeeGo takes up less screen real estate.

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: /
-enable-kvm -vga std -enable-gl -device virtio-gl-pci -hda /

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.

MeeGo bridged network connection
With forwarding of port 22 and an active SSH connection, MeeGo VM reports UDP and TCP connections.

Ssh connections via

ssh meego@ -p 6666 

do work as the documentation suggests.

Running MeeGo Handset Preview under qemu

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)

Running MeeGo Netbook Image under qemu-gl using installer

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: -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.

Set-up of PCBSD 8.1 under qemu-kvm

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:


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.

PCBSD installer
The PCBSD installer starting up.

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: -name PCBSD8.1 -localtime //
PCBSD bootloader
The bootloader with its options.

For some reason, my PCBSD image is very slow, much slower than the MeeGo one. I'm still investigating why this might be.