Wednesday, 18 July 2007

Installing Qemu on a Ubunty Feisty System

That simply command will install qemu emulator:
$sudo aptitude install qemu

Right now, qemu works as an emulator, that is, emulates every guest system instruction on the host system.
Emulating is a slow working mode, but if qemu runs on a x86 platform, it is possible to execute guest code directly as host code so speed will improve. (That is called virtualization)


INSTALLING KQEMU MODULE

To use virtualization mode in qemu, we have to install kqemu.

#aptitude install kqemu-common
That package has some documentation and a configuration file, but is not really kqemu module

$sudo aptitude install kqemu-source # Installs kqemu module sources


Compiling sources:

NOTE: You will need libc6-dev package to be able to compile kqemu sources.
If you haven't it: $sudo aptitude install libc6-dev

$sudo su # Becoming root

#cd /usr/src
# tar xvfj kqemu.tar.bz2
#cd modules/kqemu
# ./configure
#make
#make install


kqemu module is now installed!!

Gonna load kqemu module:
#modprobe kqemu

and then run qemu:
#qemu -m 256 -cdrom .....

Appears an error:
"Could not open '/dev/kqemu' - QEMU acceleration layer not activated"

This bug occurs because qemu searchs for a module which major number equals zero and kqemu-common has set it to 250.

To solve that:
#rmmod kqemu
#gedit /etc/modprobe.d/kqemu


and change 250 by 0

again:
#modprobe kqemu
#qemu -m 256 -cdrom .......



SETTING THE NETWORK IN QEMU

If you dont specify network options when invoking qemu, then defaults apply.

This default options are: -net nic -net user
-net nic : emulates a NE2000 network interface card.
-net user: use the user mode network stack which requires no administrator priviledge to run.

That should be enough to have network working in your virtual machine but with some limitations:
* Pings are not available.
* By default User mode network stack allow us to navigate and connect to our host system, but not to act as a server.

User mode network stack has a built in dhcp server that will provide us an ip address.

If everything has gone fine you can open a browser and surf on the internet.

If you cannot connect to internet, open a console and type:
$ifconfig

check if virtual nic has its associated ip address and if not, exec this command:
$sudo dhclient eth0 # eth0 is your virtual nic

try your browser again.


NOTE: Another way to configure the network in qemu consists in using a tap device and a network software bridge, instead of using user mode network stack.

0 comentarios: