David HM Spector
If there's anything positive that can be said about the current IT climate, it's that IT professionals sure have learned to do more with less. It seems that no one has any budget for new equipment and even the old machines of dearly departed (read: laid-off) employees seem to have been sold off long ago to recoup some tiny fraction of their original value, just to make ends meet.
So if you're still in the game, need to test lots of software configurations for your products and services, and aren't allowed to buy or lease any new hardware, what do you do? Clearly, repeatedly building and wiping out a machine or two for software testing is tedious and time-consuming. In this Linux in the Enterprise article, we'll examine some software solutions that will help you "create" enough machines to test against without spending anything more than a little time and some disk space.
A Ship in a Bottle
As we've covered previously, it's possible to emulate a Windows system under Linux with commercial products like VMware or Win4Lin. This is very useful if you need to access a legacy Office suite such as Microsoft Windows, or if you want to consolidate a number of servers into a virtual server farm to cut down on your overall box count.
VMware can also be used to run instances of *BSD and Linux (Win4Lin is a Windows-only emulator). However, the abstracted hardware interfaces of these programs, which provide only the most common hardware facilities, can cut down on the kinds of configurations you can create.
This can limit utility in intensive software testing, where you might need to create wildly diverse hardware and software configurations to ensure that your system will work on the broadest possible collection of systems likely to be used by your customers.
There are several other tools available to run multiple instances of Linux (and other OSes) on the same machine that can give developers a lot more control over the kinds of hardware and software emulated. These tools can also allow a lot more control over how you interact with the virtual machines, which can allow for very sophisticated process and kernel debugging not possible in a VMware environment.
These systems, the majority of which are open source, come in three basic flavors: hardware emulators that simulate an actual piece of hardware, down to the PCI slots and CPU registers; OS emulators; and bridge libraries that run as traditional UNIX/Linux processes and provide an API compatible with that of the system they are emulating.
We'll cover the OS emulators and bridge libraries first, since they're a subset of the overall emulation issue.
Bridge libraries are link libraries that allow you to write to or call Application Programming Interfaces (APIs) that emulate the functionality of some other system.
CodeWeavers' CrossOver Office is a prime example of such a library. CodeWeavers has implemented a clone of the Win32 run-time API that is sufficient to allow a Windows-based application (such as Office or PowerPoint) to run without having to install any part of the Windows operating system itself.
This is an awe-inspiring technical accomplishment, since it's well-known that Microsoft has specifically embedded a lot of application support code directly into its operating systems, specifically to stop people from running other operating systems while using its flagship applications. (Technically, this is called "bundling" or "tying," and is one of the key points in the anti-trust case against Microsoft.)
CodeWeavers is great if you absolutely must run PowerPoint while using KDE or another X11-based window manager on your x86 Linux box, but it doesn't (and isn't meant to) solve the problem of system-level emulation, and won't be of much use if you need to test your software against a lot of different system configurations.
Unlike bridge libraries, which provide a mechanism that allows people to run various subsets of other programs, OS-specific emulators try to provide a complete proxy for the software environment they're replacing.
WINE is probably the best known of these kinds of programs. WINE provides a complete replacement for the Win32 API that will, when its development is completed, allow x86-based Windows applications to run without a copy of Windows installed on your machine. This is useful if you don't want to have to jump through endless hoops just to run a Windows application on your desktop. Unlike a hardware emulator, WINE lets you run a Windows application in a typical X Window session without emulating a whole machine.
DOSEMU is a basically WINE for the pre-1988 universe. Instead of providing a Win32 API, it emulates the DOS API, and even comes with a MS-DOS work-alike called FreeDOS. This is very useful for running those really old programs you just can't live without, but can't be bothered to upgrade to their bloated (and often more expensive) Windows counterparts.
The really heavy action (in terms of this article, anyway) can be found in systems that emulate entire systems of hardware. With these systems, you have the ultimate flexibility to meet your needs in terms of emulated systems for software development and configuration testing.
Bochs is an x86 hardware emulator that is probably the closest thing in the open source world of hardware emulators to the commercial product VMware. Bochs emulates an entire system including common I/O devices, and is a good choice if you need to emulate standard systems running *BSD, Linux, or Windows.
A great aspect of Bochs is the fact that it's a true emulator -- it can be run on any UNIX/Linux platform. This means you can even emulate Windows and other x86 operating system platforms on your PPC Linux box, or even on an IBM mainframe.
Plex86 is a hardware emulator like Bochs (in fact, Plex86 is the current project of Bochs project initiator Kevin Lawton), but it achieves a much higher emulation speed because it makes use of x86-specific code to speed up its hardware emulation.
User-Mode Linux (UML) is the Swiss Army knife of emulators. It works in a slightly different way than traditional hardware emulators -- it allows you to define virtual computers that have equipment that doesn't actually exist in your underlying host system. This can be very handy for configuration testing, where you need to make sure your software works on a wide variety of hardware without having to go out and buy all of the hardware in your test configurations.
UML consists of a set of kernel patches that allow you to "boot" other OSes in console windows on your machine. A nice aspect of this is that these virtual OSes don't have to run as root or require special privilege. This means that Joe User can run several "guest" operating systems in his own process space without running the risk of crashing a multi-user machine.
So complete is the virtualization process that you can even run X11 on the virtual systems. This can become quite confusing, especially if you have enough systems running, because the X11 applications of the virtual systems are on the same desktop as those of the native X server.
Other tools used by UML allow you to create customized bootable disk images that represent the software system you wish to run -- this is where you can install your software-to-be-tested, or of course, like any good Linux system, you could have your ship-in-a-bottle make use of the network to access any needed software.
Of all of the systems mentioned here, UML is probably the most powerful and the most complete/complex. A good long session with strong coffee, the sugar vehicle of your choice, and the User-Mode Linux documentation is recommended to get the most out of using UML.
The Bottom Line
Just because we're in the middle of the nastiest technology retrenchment seen in the last 20 years doesn't mean you can't still get quality work done on less than a beer budget. Thanks to the very talented folks who have created the tools we've described here, we can all still get some work done, and probably learn some new, marketable skills in the process.
General Purpose Emulators:
- Bochs: http://bochs.sourceforge.net/
- Plex86: http://www.plex86.org/
- VMware: http://www.vmware.com/
- User-Mode Linux: http://user-mode-linux.sourceforge.net/
- WINE: http://www.winehq.com/
- Win4Lin: http://www.netraverse.com/
- CrossOver Office: http://www.codeweavers.com/
David HM Spector is President & CEO of Really Fast Systems, LLC, an infrastructure consulting and product development company based in New York
Read more Linux in the Enterprise columns.
Return to the Linux DevCenter.