Running a Chromium OS image under KVM

Getting the VM image

Please follow the Build Instructions document. It contains a section about building Chromium OS VM image. I will assume that you have followed them to the point where you have a virtual machine image with tweaks that you want there.

Linux QEMU-KVM

Linux KVM is a recommended virtual machine solution for Chromium OS (x86) since it is well supported by Linux community and quite fast (kernel based virtualization, also supports native virtualization for modern Intel and AMD CPUs). If present, KVM infrastructure can be utilized by QEMU as well.

Installing KVM on Ubuntu machine

In case you don't have KVM on installed on your machine yet, please run the following command:

on Ubuntu Hardy, run:

sudo apt-get install kvm

or on Ubuntu Lucid run:

sudo apt-get install qemu-kvm

Enabling native virtualization in BIOS

Before running KVM for the first time, it's highly recommended that you reboot your machine and check that your BIOS settings has enabled native virtualization. Intel calls these technologies VT-x, on AMD machines they are called AMD-V or AMD-Virtualization. You can see the list of supported CPUs at http://en.wikipedia.org/wiki/Intel_VT-x, if you don't have one of them KVM will still work but slower.

Running Chromium OS in QEMU-KVM

QEMU-KVM has number of options that can tweak how VM session is run. The following set of options seemed to work well for Chromium OS image:

on Ubuntu Hardy (TODO: need nic,model=e1000 on Hardy too?):

sudo kvm -m 1024 -std-vga -net nic -net user -redir tcp:922::22 -hda chromiumos_qemu.image

while on Ubuntu Lucid, there are few minor syntax changes:

sudo kvm -m 1024 -vga std -pidfile /tmp/kvm.pid -daemonize -net nic,model=e1000 -net user,hostfwd=tcp::922-:22 -hda ~/vm/linux-0.2.img

 You can see them by running kvm --help to get all the details there, but here is the brief overview of those used in the previous command:

-m megs         set virtual RAM size to megs MB [default=128]

-hda file       use 'file' as IDE hard disk 0 image, this is where you plug your Chromium OS image file path

-net nic        create a new Network Interface Card and connect it to VLAN; emulate an e1000 network adapter.

-net user       connect the user mode network stack to VLAN

-std-vga        simulate a standard VGA card with VESA Bochs Extensions. On Lucid, -vga std

-redir [tcp|udp]:host-port:[guest-host]:guest-port
                redirect TCP or UDP connections from host to guest. On Lucid, see hostfwd details.

-nographic      Disable graphical output.  Access the vm through ssh.
                Note that by default, -nographic directs the emulated serial port to stdio. This may make stdin invisible on an invoking
                terminal, so it is highly recommended to invoke -nographic with '-serial none'.

-serial [vc|stdio|none|...]
                Redirect virtual serial port to
                    vc: direct to virtual console (default for graphical mode). 
                    stdio: standard in/out (default nographic mode, but breaks terminal); 
                    none: disable virtual serual port

Once kvm command is run, a new window is created and your Chromium OS image will start its boot sequence. After few short seconds, OS will boot into its login or OOBE screen (depending where you left of last time). 

Note: If you're using Lucid, for convenience you can also use cros_start_vm.

./bin/cros_start_vm --image_path <your_image> # This is in src/scripts.



 
Please note that we qemu-kvm currently does not support hardware acceleration. As a result of that, you will see the red warning sign 'Unaccelerated graphics' in the upper left corner as soon as Chromium OS GUI starts.

Please note that once you click within QEMU/KVM window, it will 'grab' your mouse pointer. You can release the mouse by pressing Ctrl+Alt.  

The virtual machine monitor console can be reached within the emulation window by pressing Ctrl+Alt+2. This should open a qemu command where number of useful commands can be run from. Their full description can be found at http://en.wikibooks.org/wiki/QEMU/Monitor. You can always return back to Chromium OS by pressing Ctrl+Alt+1 from the monitor screen.
Tip: to use virtual terminal in Chromium OS, enter virtual machine monitor console by Ctrl+Alt+2 then type sendkey ctrl-alt-f2 and switch back from monitor by Ctrl+Alt+1.  The opposite can be done by sendkey ctrl-alt-f1.


Comments