System virtual machines fall into two categories: Type 1 hypervisors (left), which run directly on the host hardware, and Type 2 hypervisors (right), which run on top of another operating system. Both are capable of running multiple independent instances of one operating system or different operating systems, all of which behave as though they are solely in control of the system.
Can a computer exist without hardware? It can if it’s a virtual machine. A virtual machine is software that’s capable of executing programs as if it were a physical machine—it’s a computer within a computer. Virtual machines can be divided into two broad categories: process virtual machines and system virtual machines.
A process virtual machine is limited to running a single program. A system virtual machine, on the other hand, enables one computer to behave like two or more computers by sharing the host hardware’s resources. A system virtual machine consists entirely of software, but an operating system and the applications running on that OS see a CPU, memory, storage, a network interface card, and all the other components that would exist in a physical computer. For the remainder of this discussion, we’ll use the term “virtual machine” to refer to a system virtual machine.
Software running on a virtual machine is limited to the resources and abstract hardware that the virtual machine provides. Since a virtual machine can provide a complete instruction set architecture (ISA, a definition of all the data types, registers, address modes, external input/output, and other programming elements that a given collection of hardware is capable of working with), a virtual machine can simulate hardware that might not even exist in the physical world.
Using virtual machines, a computer can run several iterations of an operating system—or even several different operating systems—with each OS isolated from and oblivious to the existence of the others. The only requirement is that each operating system must be capable of supporting the underlying hardware. And, of course, there must be enough resources (memory, hard disk space, CPU cycles, and so on) to support everything. You could use a virtual machine to run Linux on top of Windows, for instance, or you could run two versions of Windows and use one as a sandbox for testing software you wouldn’t trust on a “real”
The software that manages this trick is known as a hypervisor. A Type 1 (native) hypervisor is a program that runs directly on the host hardware, i.e., as an operating system in and of itself. Microsoft’s Hyper-V, formerly known as Windows Server Virtualization, is one example of a Type 1 hypervisor. A Type 2 (hosted) hypervisor, such as Microsoft’s Virtual PC 2007, runs on top of another operating system.
IBM developed the technology for its big-iron mainframe computers in 1967, but the Intel x86 architecture at the foundation of IBM PC-compatible machines was not well suited for running hypervisors. Achieving full virtualization required exceedingly complex code, which hampered runtime performance. Although it remained a fixture in mainframe and midrange computer systems, virtual machine technology saw very little progress during the 1980s and 1990s.
In the last few years, however, AMD and Intel both developed extensions to their x86 architectures that render newer CPUs much more suitable for running hypervisors. AMD has dubbed its extensions AMD Virtualization (AMD-V); Intel calls its extensions Intel Virtualization Technology (Intel VT). AMD-V is present in many newer AMD CPUs, including the Athlon 64 and Athlon 64 X2 (socket AM2 only), the Phenom X3 and X4, and second-generation Opteron server parts.
You’ll find Intel VT in about half of Intel’s Core 2 Duo desktop processors (the E6600 through E6850, and the E8200 through E8600), all of its Core 2 Quad and Core 2 Extreme desktop processors, and its quad-core Xeon and Itanium server procs (the Itanium version is formally known as Virtualization Technology for IA-64). Intel’s upcoming Core CPU will feature Intel’s VT-d (Virtualization Technology for Directed I/O), which will enable guest virtual machines to directly use peripheral devices, such as a network interface device. Although AMD-V and Intel VT are similar, they’re not compatible; a hypervisor that supports only AMD-V will not take advantage of the virtualization extensions in an Intel CPU and vice versa. Fortunately, hypervisors that support both sets of extensions are common.
What are virtual machines good for? The most common application today is server deployment. A virtual machine can make much more efficient use of a server’s hardware by running several instances of the same operating system and the same applications in parallel, or even different operating systems and applications.
In either scenario, each instance thinks it has sole access to the hardware and behaves accordingly. The hypervisor dynamically assigns virtual resources (such as processors and memory) to physical resources so that the hardware is never left idle. Virtual machines are also useful as test platforms: System designers and application developers can experiment with new code without disrupting or interfering with the usual production environment.
But virtual machines are useful for individual users, too. Experimenting with different operating systems—such as Linux—on one computer is just one example. Trying out new software—especially shareware—is another. If a program renders your system unstable, you can blow away the virtual machine without any consequences. Or if you’re paranoid about privacy, you could create a virtual machine explicitly for web browsing: Isolate all your personal information on one installation that you never use for web surfing. Fire up the virtual machine when you do want to browse the web and tracking cookies, spyware, and any other Internet detritus you encounter will be trapped there, where it can’t harm your production environment.
Getting started with virtual machines is certainly cheap enough: Several programs are available for free, including Microsoft’s Virtual PC and Sun Microsystems’s VirtualBox (the latter of which is capable of running Windows as a guest operating system running on Linux).