Add Virtualization to Your Development Toolbox

t’s time again to open up your developer’s toolbox and make room for the new must-have tool, virtual machines. As a software consultant, I find myself traveling from customer to customer and constantly working in new development environments. As interesting as that is, a new environment means installing and configuring new tools. Inevitably, a tool install or uninstall fails, I remove a piece of software that I end up needing again later, different versions of tools conflict, or I just plain screw things up. Since my development laptop is my only laptop, wiping out and reinstalling the drive is not a fun task.

Enter virtual machines. Virtualization technology has come a long way in the past few years, and hardware is now fast enough to make a virtual machine feasible for interactive development. Virtualization software, such as Microsoft Virtual PC or VMWare Workstation, allows you to run another complete operating system?a virtual machine (VM)?in your current operating system. Although virtual machines have been gaining popularity on the server side recently, their growth on the client side has been limited?especially in a development environment.

This article presents some interesting uses of virtual machines, gives you some recommendations for getting the most from VM development, and shows why every developer should have a VM on his or her utility belt.

 
Figure 1. Eclipse Running in a Virtual Machine on WinXP

Playing in the Sandbox
During most development projects, you add and remove new third-party libraries and software as the project and requirements progress. Unfortunately, constant installing and uninstalling of applications can quickly damage the Microsoft Windows registry. Just one bad installer can really mess things up. Setting up your development environment in a guest machine (the operating system running in a virtual machine) gives you a system that you can easily recover if damaged. It also gives you peace of mind that no matter what goes wrong, you can still use the expensive new software that you just activated on your laptop. Figure 1 shows Eclipse running in a virtual machine on WinXP.

A virtual machine can provide an excellent development sandbox that forms a clear barrier between your development environment and your personal computer. If your project requires working with potentially unsafe code, such as a virus or low-level data manipulator, a virtual machine can do the trick. You can configure a VM to allow or block network access to the guest operating system, while allowing you to retain network access on your host machine (the machine running the virtualization software). If your project scans personal data, such as a desktop search bar, a VM may be the only thing protecting your personal information from the crawler during development.

Start Testing with a Clean Slate
Some projects require a clean slate for proper testing. Installers are notoriously difficult to test and debug because an error in the installer may leave behind artifacts that render future tests invalid. The only proper way to test an installer is to start with a clean slate each time. However, wiping out and reinstalling an operating system can be very time consuming, especially in a heterogeneous test environment. The solution: a virtual machine with a replicated hard drive.

Most VM software products use virtual hard drives. A virtual drive is simply a single file on the host operating system that emulates a hard drive of a given size to the guest operating system. Some products even allow you to use “growing” virtual drives, which let you specify a very large size for the drive but start small and grow as needed.

The benefit of a virtual drive is that you can easily copy it. Just create a master image, copy it, test your project, and throw it away. This testing pattern provides a sterile environment for each test, yet it doesn’t require any more time than a standard file copy.

You can extend the clean slate concept to multiple guest operating systems by just creating different master virtual disks. Test your installer on Linux, Windows 2000, and WinXP by just booting different virtual hard disks on the same host machine.

Training and Demos in the Field
Of course project development is not the only use for virtualization. A virtual machine with a configured virtual hard disk serves as an excellent training platform as well. The disks can be easily replicated and destroyed as required. As a trainer, you know that every student’s machine is configured in exactly the same way, since they are all copies of the same master image. Constraining the student to a VM prevents destruction to the host operating system, which translates into more uptime for a training facility.

A recent project I was on used a virtual disk as a preconfigured demonstration platform. The sales team (or the poor engineer paired with a salesman) could grab a copy of the demonstration disk and the virtualization software and hit the road. The use of a preconfigured system limits the downtime of waiting for an engineer to build the system and reduces the occurrence of configuration errors in the field.

Which VM Software Is Right for Me?
The first important act of adding virtualization to your toolbox is choosing the virtual machine software you want to use. You have a few choices here, with the two major contenders being Microsoft Virtual PC and VMWare Workstation. A third, less obvious choice is User Mode Linux (UML). Each of these products has its own pros and cons (which are beyond the scope of this article), but ask yourself the following key questions when choosing a product:

  1. Which operating system(s) will run on the host machine? Virtual PC runs on Windows and OSX, VMWare Workstation on both Windows and Linux, and UML on only Linux.
  2. Which guest operating systems will I run? Virtual PC and VMWare work with most, although they have a small “officially supported” operating system list. UML runs only another Linux kernel.
  3. Will I migrate the guest machines to a server or enterprise product? Both Microsoft and VMWare provide server products that can use virtual disks from their client products. If your enterprise is already using a server product, choose a client product to match.
  4. Does my enterprise already have a license to a product? Many developers do not realize that most MSDN subscriptions include access to Virtual PC. If you have a subscription, check if you already have access to a product license.
 
Figure 2. Virtual PC Guest Machine Configuration Dialog

A few other up and coming virtualization products are available, but many are not mature enough to use in a production environment. The more mature products, like Virtual PC, include simple configuration dialogs that let you configure many pieces of the guest machine’s hardware, as shown in Figure 2.

Integrating a virtual machine may appear tricky at first, but remember that it is just another machine on the network. Smart use of shared folders or a network file system (NFS) can allow you to easily share data between guest machines or between the guest and host machines. If you use MS Windows as your guest operating system, don’t forget to look at the sysprep tool for preparing the operating system for reuse. Forgetting to do this can cause problems if you use the virtual machine in a networked environment.

Drawbacks and Limitations
You must consider some tradeoffs when using virtualization. Depending on the usage type, a virtual machine’s performance may not be as good as that of the host machine. Managing the virtual disks can be difficult if they are too large and difficult to move or copy. Depending on the guest operating system and length of its use, you may need to purchase multiple licenses to keep everything legal. Even with these limitations, virtual machines have a lot going for them.

Add Virtualization to Your Toolbox
I hope you see the value of using virtualization as a development tool. Easily recoverable systems and a protected sandbox environment drastically reduce downtime during development and testing. Preconfigured demonstration and training machines mean increased productivity and a reduced error rate when you take them into the field. Virtualization products are now affordable and readily available for almost all host and guest platforms. Simplify your life, make some room in your development toolbox, and add virtualization to your next project.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: