Today I was inspired by an article in the February 27th issue of Infoworld Magazine written by Tom Yager titled, “What virtualization is — and what it isn’t,” which was regarding misuse of the term “virtualization.” He goes on to briefly identify a few ways that the term is used correctly, as well as incorrectly, in some modern software products, namely VMWare software, Apple’s Rosetta binary translator, and Microsoft’s Virtual PC for Mac. I’m going to take a slightly different direction here, but I’ll touch on those products.
Definitions: Virtualization and Emulation
Virtualization is a broad term that refers to the abstraction of resources across many aspects of computing. The context I will be discussing today is with regards to local hardware virtualization. What this means is that multiple operating systems, or multiple copies of the same operating system (OS), can run simultaneously on a single set of hardware, and retain access to all aspects of the hardware. When one or more of the installed operating systems requests access to a piece of hardware, the layer that performs the virtualizing intercepts that call, and if the hardware is currently being used by another instance of an installed OS, it schedules the hardware call to happen as soon as possible. If the hardware is available, or once it becomes available, the call is passed on to the hardware and any responses from hardware are directed right back to the calling OS. This is a very fast process, as there is minimal interaction here, and the installed operating systems run at near full speed. (See my previous post on Xen Virtualization to get a brief look at one way that this can work.) Emulation is recreating an entire hardware architecture in software, then typically running an OS under that (though it could be used in a much “smaller” way, such as running a single program or even translating a single instruction.) As you can probably imagine, a program that acts like it is an entire piece of hardware is hardly simple and is typically much slower than the real hardware it is emulating.
Which to use when, and why?
Emulation is handy when you want to run an operating system or program from a completely different system on your machine. Think, for example, of playing Super Nintendo games on your computer, or running a Commodore 64 program under Windows or Mac OS. This can also be used for things like developing software that would be encoded on a chip to would be embedded in a consumer product, such as a calculator, a remote control, a television, or even a clothes washer! Emulation is likewise good when you are developing a new hardware product, such as a CPU, but want to get the design right before you manufacture ten, a thousand, or a million of them. You can create the entire hardware architecture in software and then work under that software as though you have the final device right in front of you. If you find bugs in the design, or something you could optimize to work better, you can change the emulation software; Once you have everything designed the way you want it, you can send the design out to be prototyped, tested, and manufactured. Virtualization, on the other hand, is used when you want to run multiple OS’s (or multiple copies of an operating system) on a single machine. One reason you might do this is if you are designing a distributed system (such as a cluster of machines) and you are trying to develop some software (such as communications protocols) that requires testing across many machines at once, but you only have one or two machines with which to test. (This example works best when you have multiprocessor/multicore machines to work with.) Another reason is if you want to run Windows, Linux, and FreeBSD simultaneously on one machine…without “dual-booting” or using emulation! (Examples chosen at random…many other combinations are possible, and I am not endorsing any particular product, nor trying to slight any product.) A third, and particularly useful, use of this kind of virtualization is for if you want to separate out individual parts of a complex system…such as a mail server solution. One way (and there are many ways) you could separate this example is to have the MTA (mail transfer agent, the actual program that receives the mail) running on one virtual machine, run an anti-virus/anti-malware scanner on a second virtual machine, and have a webmail interface running on a third virtual machine. (As you may guess, there are a number of other ways to set up this system, as I have glossed over a few parts of this complex system, such as the mail store, imap & pop servers, databases to store virtual addresses, and more.) This would allow you to use just one machine to accomplish this goal, while giving each conceptual part of the system it’s own dedicated resources…and no single part of the system could bring down another part. (Have any of you ever had an Apache server running a webmail client use all your available memory, causing failure or extreme delays in the MTA that is trying to receive e-mail? It can happen…)
Final thoughts for tonight…
Well, I hope to have brought a little insight to the question of what virtualization and emulation are in one context, and given enough examples to give you an idea of how each works as well as some potential uses for each. It turns out that I didn’t mention the products from the first paragraph again, but there is tons to talk about when it comes to virtualization, even when used exactly as it is defined here, and there a plenty of other meanings to the term. So, don’t be surprised if I end up talking about these concepts often…it is a field in which I am interested and use in my everyday life as a systems administrator.