Using virtual machines via emulators on your computer can have several
interests:
- First, I've been attracted by the ability to run old and/or
closed-source programs in their native environments. For instance,
I've bought ages ago a nice electronic English dictionary for
Windows. After my switch to linux, I was able to use it for a time via
Wine, but at some place they broke the support of such 16-bits
programs. And I will certainly not reboot my computer each time I want
to search for a translation. So I now run a virtual Win98 machine
using Qemu. This virtual machine also helps to check the rendering of
this very web page by Internet Explorer. This point is not
Windows-specific: old closed-source linux programs can benefit from emulation
useful. Think for instance of a scientific software that rely on libc5:
how many linux systems can still run it these days ? Even for open-source
programs, emulation can be relevant: think of the difficulties to port
openoffice from 32-bits to 64-bits (ok, in this particular example, a
chroot environment is probably better suited than a complete
emulation).
- Then, for teaching compilers (or other hardware-related topics),
it's really nice to consider first a clean assembly language,
and in particular a RISC one, such as MIPS (see here for instance).
But Mips machines aren't so common nowadays, so let's emulate! Moreover, this way,
there is less risk of crashing the whole computer ;-).
- Moreover, compilers are still an hot research topic. I'm currently
involved in a project
whose goal is to produce certified compilers. Once again, a RISC
architecture (PowerPC) was chosen as target, both for simplicity and
industrial relevance. Once again, without any PowerPC machine in the
nearby, I've tried to emulate one.
- Emulation can also bring additional security, thanks to isolation
of different layers. For instance, my win98 machine can be attacked
by a virus or worm, I (relatively) don't care: I've no sensible data
in the virtual machine, the underlying linux host will hopefully not
be affected, and anyway this attack cannot survive a reboot of the
virtual machine since its image file is read-only (thanks to the
snapshot feature of qemu).
Of course, this security aspect isn't absolute: few emulators have
been written with security as primary goal and few audits have been
done on them. The Chroot example shows that sometimes one can evade
from jail...
- But of course, the main reason is ... it's fun !
Concerning the virtual machines presented below, the main goal is
pedagogical: having access to a complete gcc compiler toolchain on
something that isn't x86. So don't be surprise to end on a raw
console. It was just enough for my needs. Up to you to install and run
fancy graphical programs, and let me now if you succeed. Of course,
the Win98 virtual machine is another story, but I cannot redistribute
it, so I will just say a few work of it.
By the way, I would like to thank here all the developpers of these
great emulators such as qemu, pearpc,
gxemul, etc. Moreover,
even if qemu's reputation is sometimes disputed amongst free software
community, due to the existence of the proprietary kernel module
kqemu, I would like to stress the fact that qemu itself is indeed free
sotfware (more precisely LGPL). And kqemu is not necessary for the
examples described here: it is designed to improve emulation of PC on
PC, and even in this situation (e.g. Win98 on Linux) the emulation on a
modern machine is quick enough without kqemu.