Sunday, 10 June 2007

Installing Qemu on Windows Vista

Qemu introduction from Wikipedia

QEMU emulates a full computer system, including a processor and various peripherals. It can be used to provide virtual hosting of several virtual computers on a single computer.

Qemu author, Fabrice Bellard, also wrote a Linux kernel module (with preliminary ports to FreeBSD and Windows) named KQEMU or QEMU Accelerator, which notably speeds up i386 emulation on i386 platforms. This is accomplished by running user mode code directly on the host computer's CPU, and using processor and peripheral emulation only for kernel mode and real mode code. KQEMU also supports a kernel emulation mode in which portions of kernel mode code run on the host's CPU

Qemu official page:

Qemu ported to Windows:

First we download a zip package:

Next unzip archives to a folder.

There are some clues at file README-en.txt, and a html manual at qemu-doc.html.

Qemu is now ready to be run:
so exec qemu-win.bat and a small linux test image "linux.img" is emulated.

NOTE: When a mouse cursor is missing, type Ctrl and Alt key together. Please use Alt
and Tab on WindowsMe.

NOTE: To exit from Linux, press Ctrl-Alt-2 keys together then you will see (qemu) prompt.

Then type quit: (qemu) quit

Running Qemu:

I have downloaded a Ubuntu iso cdrom image: ubuntu-7.04-desktop-i386.iso

First I exec C:\Windows\System32\cmd.exe to open a comand line window, and then:
>cd <qemu-directory-path>
>qemu -L . -m 512 -cdrom ubuntu-7.04-desktop-i386.iso

Argument options have the following meanings:
-Lbios pathin our example actual directory "."
-mavailable memoryDefault is 128 meg, I set it to 512
-cdromiso cdrom image pathIso image to emulate a cdrom

Qemu gives this warning:
Could not open '\\.\kqemu' - QEMU acceleration layer not activated

To avoid this message, install qemu accelerator, which will improve qemu speed:
(NOTE: uninstall any previous version accelerator you have before installing this one)
Qemu accelerator Kqemu-1.3.0pre11


Right now we don't have network available. We check at this doc for some clues: HowToNetwork-en.html

I have decided to use a TAP (virtual ethernet network interface) to have full internet access: TapWin32-en.html

First we need a VPN driver for windows: OpenVPN driver download page.
Download and install this program: openvpn-2.0.9-install.exe

Once installed go to Programs menu and then
-> OpenVPN -> Add a new TAP-Win32 virtual ethernet adapter

If all has gone fine, a tap device will appear at:

Control panel -> Network and Sharing Center -> Manage networks

Remember the TAP interface name because it will be passed as an argument to qemu, i.e. in my computer is "Local area connection 2"

Now we have to establish a NETWORK SOFTWARE BRIDGE in windows vista.

Network bridge (Wikipedia)

A network bridge connects multiple network segments at the data link layer (layer 2) of the OSI model.
In our case the bridge will interconnect a real network interface with our TAP interface at data link layer, so both interfaces will share same IP address.

Howto set up a network bridge at windows xp and vista: Win XP network bridge set up.

Select both interfaces pressing ctrl key, and right click the mouse.
Select "Bridge connections" at the pop up menu and wait till network bridge will be completed.

After bridge completion gonna set up its network configuration:
right click at bridge icon -> properties -> Internet protocol version 4

If you have a dhcp server you can set bridge interface to automatically get its IP address.

I use a static network configuration at my LAN.

(change values to suit your network.)


To check the network at console window we can make some pings:
ping (checking gateway)

Time of truth arrives, we launch qemu:
qemu -L . -m 512 -cdrom ubuntu-7.04-desktop-i386.iso -net nic -net tap,ifname="Local area connection 2"

at ubuntu guest system I configure the network with a free IP address on my LAN:
DNS 194.179...

pings work:
ping (checking the gateway)

If you have Internet access through your LAN, you can now open a browser and surf on the Internet from inside your qemu guest system. :-)

More info about bridging:


Qemu HowTo Floppy Cdrom

3 comentarios:

ViRz said...

the only guide simple enough to understand (NETWORK SET UP FOR QEMU ON WINDOWS VISTA).

most importantly, it works. thanks.

Vicente Hernando said...

Thank you for your comment!

José Moya said...

It is one of the easiest methods I've read on the net, but:

1) "Bridging" does not always work. I've had sporadic success with "shared internet connection" and many failures with bridging.

2) I think there is some ramdom element working here. I've tried bridging about 20 times in 48 hours, with different encapsulations, and checked the traffic with ethereal. Host saw emulation, emulation saw nothing.

3) Another random element: Using model=pcnet gave me better results than model=ne2000