Virtual machines have been around for a long time but they really have not become common place in many development shops. It is unfortunate since virtual machines provide so many benefits to developers and testers alike. This article will discuss some of the benefits of virtual machines and review two of the most popular virtual machine software packages available for Windows.
A Virtual Machine?
A virtual machine, simply put, is a virtual computer running on a physical computer. The virtual machine emulates a physical machine in software. This includes not only the processor but the instruction set, the memory bus, any BIOS commands and critical machine hardware such as the system clock and and DMA hardware. Depending upon the machine peripheral devices are generally virtualized including storage devices like floppy drives, hard drives and CD drives. Video, keyboard and mouse support are also common. A virtual machine must look and act just like the real thing so standard software, like operating systems and applications, can run without modification.
Emulation software (the term we will use for applications that create and run virtual machines) generally define a basic machine to emulate rather than supporting a wide variety of devices. This reduces the amount of work that must be done and keeps things simple. For Windows-based emulations you can expect a Pentium 4+ processor with basic SCSI and/or IDE drive support, floppy disk and basic CD/DVD reading along with all the required hardware. This is enough to run most applications. So even if you are running a multiprocessor non-Intel processor the virtual machines will still see a Pentium 4. The emulation software is responsible for mapping the virtual devices back to the real devices, when appropriate. For example writes to the virtual hard drive must be written to the backing file for the drive.
Emulation software generally allows for some manipulation of the virtual devices. At a minimum this would generally include how much memory to make accessible to the virtual machine, how many (and how large) the hard drives are, whether sound cards or ports are available, etc. These virtual machine settings are generally stored in a custom file by the emulation software. Additionally the virtual hard drives are also generally stored as files. These files can get really large since they are emulating a real computer.
In emulation software the machine running the virtual machines (in our case Windows) is known as the host. The virtual machine itself is known as the guest.
Why Does It Matter To Me?
So what does this mean to developers and testers. Let’s look at a few scenarios that developers and testers find themselves in. For testers it is important that they test software against the various supported operating systems that an application runs against. The traditional approach is to run multiple physical machines, each with a different operating system. This is bad for several reasons. Space, maintenance, power and feasibility come to mind. Deployment of the software to these various machines can also be an issue. Instead a tester can run multiple virtual machines on one physical machine. Each virtual machine could have a different operating system. The application can be deployed to the virtual machines and tested.
Another advantage of virtual machines is reproducibility. Build and test environments generally need to be well controlled. It would be undo work to have to wipe out a machine and rebuild it after each build or test run. A virtual machine allows the environment to be set up once. The environment is then captured. Any changes made after the capture can then be thrown away after the build or test run. Most emulation software packages offer this in some form or another.
Another scenario, your application is currently released as version 1. Because of how the application is written you can only run a single version of your application on a machine. When you start development on version 2 you have to remove version 1. Part way through development an issue is found in the version 1 software that you need to replicate and fix. You can uninstall version 2 and install version 1, find and fix the issue and then revert back but that is a lot of work. A nicer approach is to have a virtual machine with version 1 installed. When you need to go back to version 1 you just start up the virtual machine. Even better is that you can easily compare the behavior of the two versions side by side rather than having to switch between two computers.
IT departments have already found the benefits of running virtual servers over having multiple physical servers. Development and testing share many of the same benefits. Virtualization has become a buzzword in the industry. Windows is becoming more virtualized so even if you aren’t using virtual machines today you may be in the future.
Which Emulation Software Is Best?
You have decided to try virtual machines out. Now which software to use? Fortunately, or perhaps not, there are not too many options available. Each have their strengths and weaknesses. First we’ll give a brief overview of each and then we’ll compare them by looking at features important to good emulation software.
Microsoft Virtual PC
Version used: Virtual PC 2007
Microsoft purchased Connectix many years back for their virtual machine software. They rebranded it Microsoft Virtual PC (VPC). There have only beeen two versions: 2004 and 2007. It comes in either PC or Server edition but we will only talk about PC.
VPC is the primary mechanism by which Microsoft deploys demo and beta products to customers. They generate VPC images that can be downloaded and run. If you do a lot of beta testing for Microsoft then VPC will be a requirement.
Windows Virtual PC
Version used: Windows Virtual PC
This is an updated version of Virtual PC. The reason it is listed separately is because it only supports Windows 7 and later operating systems. WVPC is basically VPC with some new enhancements. It is relevant enough that if you are running Windows 7 and you want to use VPC then you should be using WVPC instead.
WVPC supports loading of existing VPC images so you can easily upgrade from VPC. Once you upgrade though you won’t be able to go back.
One very interesting feature of WVPC (which no other application has) is XP mode. WVPC ships with (or at least you can download) a free image XP for use in WVPC. When running this image you can seamlessly integrate any installed application into Windows 7. What this means is that you can install an application under WVPC and run it directly from Win7. When you click on the generated shortcut it will start WVPC and the XP image in the background and provide a seamless desktop to run it under. This mode was developed almost entirely to allow you to run XP applications that normally would not run under Win7. Primarily this is designed for corporate environments but it works well enough to be of general use.
Version used: VMWare Workstation 7
VMWare has been around for years (since at least the 90s). As with VPC there are either workstation or server editions but we will restrict ourselves to the workstation edition.
A nice feature of VMWare is that it can run, albeit with a reconfiguration, VPC images as well. Once you load it into VMWare though you will no longer be able to use it in VPC.
Version used: Qemu v0.9.1
I have little experience with Qemu so I will not review it here. It’s biggest strengths are that it is open source, free and can emulate non-Intel processors. Its weaknesses include it is not as stable or easy to use as the other products and it does not perform as well, in my experience. It is command-line driven although there are some addins that give it a user interface. It is definitely something to watch for down the road.
A caveat is in order before we discuss the features. I used VMWare for many years in the 90s. I loved all the features it had. When I switched jobs my new employer would not justify the cost of virtual machines. At the same time I received a complimentary copy of VPC. I used VPC for several years since I did not own a copy of VMWare anymore. Beyond 64-bit support I could not justify the cost of VMWare. Recently VMWare was nice enough to give me a complimentary copy of VMWare and I now run both versions, at least for now.
VMWare Workstation : $199
WVPC: Free (requires Win7)
For some shops cost does not matter but for many it does. $200 is not much money for software but for single developers, like myself, it can be hard to justify free for most situations. VPC wins here. However it is important to note that VMWare has a program called VMWare Player that allows you to run virtual machines. It is free but does not allow for configuration changes.
Running a virtualized machine on top of a regular machine is going to be slower in most cases. Therefore performance of both the guest and host are important. Virtual machines make heavy use of the processor, memory and hard drive space. A host system must have a really strong processor (preferably multiprocessor), a lot of memory and a lot of fast hard drive space to get good performance out of a guest.
VPC and VMWare both run about the same in my experience. VMWare has a slight performance advantage when running guests when certain device options are set (discussed later) but otherwise they both run really well. VMWare also seems to shut down guests faster than VPC. However VPC handles undo faster.
WVPC has similar performance to VPC. WVPC generally prefers to hibernate VMs rather than shutting them down. This results in faster start ups at the cost of more hard drive space.
Common: Pentium 4, SCSI and IDE drives, CD/DVD drive, network cards, SoundBlaster card, SVGA
VMWare: USB devices, multiple processors, 64-bit processors, 3D graphics
WVPC: USB devices, multiple processors
VMWare has superior device support to VPC. Beyond support for USB devices attached to the host machine VMWare also supports emulating a 64-bit processor. This is a fundamental feature that may sway many people to VMWare. 64-bit processors have been around a while. Many people are running 64-bit versions of Windows as a host. It is therefore logical that people will want to run a 64-bit guest machine. Only VMWare can do that at this point.
VMWare also supports 3D graphics with hardware acceleration. My experience at this point though is that it is sufficent to run basic apps but not sufficient to run 3D games and the like. It simply is too slow.
WVPC is catching up to VMWare in terms of hardware (especially with XP mode). It does support multiple processors but only limited. One area to be concerned about though is the host CPU. The host CPU must support virtualization otherwise WVPC will not run. All modern CPUs support this feature but some older processors do not. Confirm virtualization support before deciding on WVPC.
(UPDATE: 3/28/2010 – Effective immediately WVPC no longer requires a host CPU with virtualization support. An update to WVPC removes this requirement.)
Operating System Support
VPC: DOS (unsupported), All versions of 32-bit Windows except servers (Servers work but are unsupported), OS/2 Warp (certain versions), Others (unsupported)
VMWare: DOS, All versions of 32/64-bit Windows, most variants of Linux and FreeBSD
WVPC: 32-bit versions of Windows
VPC and VMWare support basically the same operating systems. If it runs under the virtualized hardware then it will run. Non-Windows operating systems are unsupported, but work, in VPC. OS/2 Warp is documented as supported with VPC but I have never gotten it to work properly. To be fair I have never gotten it to work under VMWare or Qemu either.
WVPC is really designed to get legacy XP machine running under Win7. It does technically support any 32-bit Windows version but no other operating system is formally supported. This is actually a step back from VPC’s support.
The big point here is that, since VMWare emulates a 64-bit processor, you can run 64-bit operating systems. Therefore VMWare takes the win here just for that. Running a 64-bit guest under 32-bit host can solve many issues when trying to migrate from 32 to 64-bits. I run this way quite a bit and it works well.
Both VMWare and VPC support cloning of existing virtual machines but in different ways. Cloning is important when you want to set up multiple guests with the same, or similar, environment. Installing an operating system is time consuming. With cloning you can set up the environment once and then reuse the environment in different guests. To understand the differences between VPC and VMWare’s approaches you must understand how cloning works.
The simplest approach to cloning is simply copying the virtual machine directory and doing a little renaming. This works in both VPC and VMWare. VMWare actually detects this and offers to make a few adjustments. While doable this is not the best approach because it wastes a lot of space, especially if the cloned guest does not change much. We will not refer to this approach anymore.
The better approach is to difference a base image. With differencing only the changes made to a guest are stored. With differencing the amount of space a clone takes is less because it only tracks the changes. However it needs the base image to run properly. Even more important though is that the base image cannot change without invalidating the clone.
VPC supports cloning but it is not directly obvious how to do it. Basically you would set up a new virtual machine with a regular virtual drive. You would then create a new virtual drive. Within the wizard is an option to create a differencing disk (off an existing virtual drive). Replacing the original virtual drive created when the virtual machine was created with the new virtual drive results in a clone. While not obvious, it works.
VMWare does basically the same thing but it exposes these options easily within the main UI. The clone option is exposed for each virtual machine. When you select this option you can chose to do a differencing clone or a full copy. As with VPC this creates a brand new virtual machine.
WVPC follows in VPCs footprints for cloning support. For WVPC, where you want XP mode support, the best solution is to copy the base XP image and then use it as the hard drive for the new virtual machine. This is the closest you’ll get to cloning.
For easy of use VMWare wins here but otherwise the products are identical.
Along the same lines as cloning is undo support. After you’ve made changes to a guest it is sometimes important to undo those changes. Without direct undo support you would have to resort to cloning. Both VPC and VMWare support undo.
VPC/WVPC exposes this as an option in the virtual machine settings. By default it is disabled so all changes made to the guest are permanent. When undo support is enabled VPC tracks the changes made for the current session in a separate file (a difference disk again). When the session finally ends VPC asks if you want to save the changes permanently, save them for later or throw them away. If you decide to save the changes permanently then VPC will merge the differences in. This can take up to 10 minutes. If you opt to save the changes until later then the differencing disk is retained. When the session starts again you will be able to resume from where you left off. Finally if you decide to throw away the changes then the differencing disk is deleted.
VMWare does things differently. VMWare uses snapshots instead. With snapshots VMWare basically uses differencing disks for each snapshot beyond the first one. Unlike VPC it does not prompt after you close a session. Instead you snapshot the guest when you want and it tracks changes from there. Another advantage of snapshots is that you can have multiple versions. With VPC you have the base image with or without changes. With VMWare you have the base image along with any number of snapshots containing changes. A big, big negative for VMWare is the number of files needed to support snapshots and all the space they take up. There really is no good way to clean this mess up even when you don’t want snapshots.
For simple undo support VPC/WVPC wins here but if you want multiple variants then VMWare is the winner. Personally I prefer the simplistic on/off support of VPC. Normally I set up a VM with a bunch of changes. If they stick then I want it permanent. If they don’t then I want to undo it. I don’t see the big benefit in multiple undo levels especially when cloning is involved.
Another critical area for emulation software is how well it integrates the guest and the host. At a minimal the guest must be able to transfer files to and from the host. VPC and VMWare both support this but in different ways.
VPC allows you to identify one or more folders on the host machine to be exposed to the guest. Each folder is exposed as a separate drive to the guest. Whether the folder is exposed each time the virtual machine restarts or not is optional. The guest can have read-only access, if desired.
VMWare also allows you to identify one or more folders on the host machine to be exposed to the guest. However VMWare exposes all the folders as subfolders of a single network folder. As with VPC the folders may or may not be writable and can be persisted or not.
WVPC has an even nicer integration over VPC. It allows you to identify the local drives that you want to directly integrate with in the VM. This eliminates the need to set up network shares or map drives and is really nice.
I personally prefer WVPC’s approach of using truly integrated drives. In a close second is VPC’s mapped drives. While you are limited to 26 shared folders they all look like drives. With VMWare’s network folder approach the drives are accessed using UNC paths. For some applications, like .NET, this introduces problems. For .NET security of a network application is different than a local application.
Another host-guest communication features is copying and pasting. It is very common to want to copy something (other than a file) from the guest to the host or vice versa. Both VPC and VMWare support copying and pasting using the clipboard from/to the guest. This is optional in the products but should generally be left enabled.
Finally there is actually getting to and from the guest. VPC creates a separate window for each guest. To give control to the guest you need only move the mouse within the window and click (by default). To return control to the host a keystroke is used. If a certain keystroke is pressed while inside the guest the Ctrl+Alt+Del key sequence is generated. If you accidentally press Ctrl+Alt+Del while the guest is active then VPC will intercept it and let you know, although the host will still receive it as well.
VMWare follows a similar approach in that moving the mouse within the window and clicking will give the guest control. It also uses special keystrokes to send the special Windows keystrokes and detects if you press them while inside the guest. What is different is that VMWare uses a single, tabbed window to house the virtual machines. Each guest gets its own tab. Within the tab you can see either the guest window or the configuration window.
WVPC in normal mode works just like VPC. In XP mode though you run apps as though they are running natively on the host machine when in fact they are running in VMs. This is really cool, when you need that feature.
Each emulation software has tools that it can install into the guest. These additions generally include optimized video and network drivers and support for the host-guest communications. Neither product has an advantage here.
VMWare supports an interesting features that VPC/WVPC lacks. VMWare can install a Visual Studio addin. This addin allows you to debug code on the guest directly rather than relying on remote debugging. For developers this is an excellent feature.