qemu -- What Is It?
|
Qemu is an open-source Virtual Machine. If you want to know more about the
general concept of virtual machines, check out Virtual Machine
Intro.
Qemu is one of the most easily available Virtual Machines in that it is open
source and available for the most popular operating systems. Interface-wise,
qemu is a minimalist product, using command line parameters to create and run
guest operating systems.
|
The computer on which qemu is installed is called the host. Within the qemu
engine can be installed other operating systems which run on the host. The
operating systems installed in qemu are called guests.
Qemu can exist on Linux, Windows, and MacOSX hosts. On these respective
hosts can be installed guest operating systems of Linux, Windows, and
DOS.
To increase execution speed, kqemu accelerator packages are available
for some architectures that let code run directly on the host
hardware. Particularly, newer versions of Windows running in Linux can
make use of these accelerators.
The result is that you can choose a host that you like for most
of your work, and still be able to run other guest operating systems
in a window on your host.
How do you get Qemu?
In many versions of Linux, qemu is already included in the
distribution. I use Debian Etch, and the entire qemu package
(version 0.8.2) was ready to be installed by the Debian
package manager.
The procedure is:
sudo apt-get install qemu qemu-launcher
|
This command installs both the qemu Virtual Machine and a GUI utility named
qemu-launcher. Qemu-launcher makes it easier to configure and install new guests
in the qemu Virtual Machine. Basically the qemu-launcher creates the qemu
command line arguments from menu selections presented to the user.
Also included in the Debian distribution is the kqemu accelerator
package. Kqemu, depending upon architecture and the guest system, can
considerably speed up the performance of a guest OS.
To install the kqemu package, you'll first need to be sure that the
header files for you currently running distribution are installed. If
using Debian, do the following:
apt-get install linux-headers-`uname -r`
In Debian, the kqemu package needs to be installed using the
module assistant utility. The procedure is:
sudo apt-get install kqemu-common kqemu-source
sudo module-assistant prepare kqemu
sudo module-assistant auto-install kqemu
|
Once installed, you can make use of the kqemu accelerator by either loading the
module automatically at boot by listing the kqemu module in
/etc/modules, or by doing a sudo modprobe kqemu prior to running
qemu.
Frankly, I suggest you go directly to bellard.org to get the latest version of
qemu. Qemu is a relatively new product, and many additional features and fixes
are being implemented in each revision.
I realize that getting a new version of something for Linux can
lead to a difficult install sometimes. But installing the new qemu is
very easy.
Just download the latest Linux qemu binary as a tar-zip, copy the file to
the root directory, and as root, untar it. It will then automatically unpack
into the proper /usr directories.
Installing the latest kqemu is also easy, though it does require you
to have your Linux system headers installed. Using the make utility
(check the kqemu README) provides an easy install.
If you decide to get the latest version, be sure to check the
install instructions in case they've changed.
How Do You Install A Guest Into qemu?
To install a guest OS into qemu you can use qemu-launcher if you have it. It makes
installing a new guest a simple point and click affair.
If you don't have qemu-launcher, you can put the guest OS into the cdrom
and do the steps in the following example:
qemu-img qemu_winxp 5000M
qemu -m 256 -boot d -cdrom /dev/cdrom -hda qemu_winxp \
-net nic,vlan=0 -net user,vlan=0 -localtime -no-qemu
|
In the example, the first command uses the qemu-img command to create
an image file for the new guest, called qemu_winxp in the example. The command
also needs the file size, given as 5000M in the example, which is 5000
megabytes, or 5 gigabytes.
The second line launches the qemu Virtual Machine on the new file,
instructing it to use no more than 256 megabytes of memory, boot from the cd
(-boot d), and use /dev/cdrom for the cdrom. The remaining arguments
setup the network capability and turn off the accelerator, a safe thing to do
on install.
Note: If you are going to install Windows 2000, add the -win2k-hack parameter to
prevent an erroneous disk-full error that will abort your install.
Incidentally, while qemu runs systems reasonably well, especially with the
kqemu accelerator, it installs some guest systems very, very slowly. We
may be talking a couple of hours. Why it is so slow I do not know.
How do you launch a qemu guest?
To launch qemu with the installed guest OS (Windows XP in this example):
qemu -m 256 -hda qemu_winxp -net nic,vlan=0 -net user,vlan=0 \
-localtime -kernel-kqemu
|
In this example, the kqemu accelerator is set to its highest level with the
-kernel-kqemu parameter. Should qemu fail with this parameter, just
remove the parameter which defaults to only using kqemu to accelerate user
programs, and not the entire guest OS.
You can review the qemu man page or the qemu html documentation to see all
the other parameters that can be included on the qemu command line. Additional
parameters allow connections to parallel ports, serial ports, and usb, among
other things.
When in a qemu guest window, you can switch to a qemu status window with the keys:
While in this window you can check the status of the kqemu accelerator with
the info kqemu command, for example. If your command line turns on usb
support with the -usb parameter you can use the status window to see the
IDs of the plugged in devices and mount the one or ones you wish, or unmount
them (if you've already unmounted them from the Windows guest). Just do a
help command in the status window to see all the commands you may use
there.
In my Debian system, I found that I had to make one system change in order
to get usb working in qemu. Without the fix, trying to use usb in qemu failed
because of a privilege issue. The fix involved getting group access to the
usbfs virtual driver. This was accomplished as follows:
1) If you have the file /etc/init.d/mountkernfs.sh, find the line:
domount usbfs usbdevs ...
2) Add to the line:
... ,devgid=1000,devmode=664
where in my case, 1000 was my group number.
3) Reboot, and now qemu should work with usb.
|
With this fix, the usb support of the 0.9.1 engine seems work well, though
the mechanism is a bit clumsy compared to other Virtual Machines. You must
mount a device by either its bus and id, or its product code and vendor id.
To exit the status window and get back to the guest OS window, use the following
key combination:
To get keyboard and mouse control out of the guest window, use the
CNTL-ALT key combination. To get back into the qemu guest window,
just click the mouse in the guest window.
Networking with this qemu launch command is simple. Just set up your guest
to use DHCP, and usually other guest network parameters can be left alone.
More advice on setting up qemu can be found at Qemu Installation Notes.
Personal Observations
I've tested qemu on Freedos, Windows NT, Windows 2000, and Windows XP guest
systems. The Windows 2000 and Windows XP systems took a couple of hours to
install. Freedos and Windows NT run quite well in my 1 gigahertz system.
Windows 2000 and Windows XP are sluggish, I'm sure some of the sluggishness is
because in my AMD architecture I can't successfully run the systems with
full (-kernel-kqemu) acceleration.
I've also installed all of these operating systems into the VMware
Server Virtual Machine. In all cases the installs took less time, and
once the VMware additions were installed (in the Windows OS's) the systems all
ran very well. No particular slowdown of any of the systems was noticed.
I also installed Windows 2000 into Virtualbox for comparison. Virtualbox runs
guest systems as fast as VMware as near as I can tell, and much faster than qemu, at least
when full use of kqemu can't be utilized.
Still, the handiness of launching an OS with a command file instead of a GUI is
refreshing to me. So I use Freedos and Windows NT mostly from my qemu installs because
of that ease of use.
One peculiarity I found was with the serial port implementation. I have a
quickpad IR. It comes with Windows software than can be used to move text
files between the quickpad and the computer. The connection is through a serial
port.
In the qemu guest I can verify that the serial port is working by using it
to upload and download files to my HP48 calculator. Yet I cannot establish
communication with the quickpad.
With Windows running in VMware, I can communicate with the quickpad. I don't yet know
why the qemu serial port doesn't work with the quickpad interface.
|