Q: Can I use Virtual PC to make my testing and development job easier?
A: Yes you can... and if you haven't already added Virtual PC to your development process, now is the time to do so!
With it, you can create a custom test environment that can be rebuilt at any time, easily restored to previous states without going through a full installation... all of which requires no additional hardware or software than what you have today.
Background
For those who haven't heard of Virtual PC before, it's free virtual machine software from Microsoft that allows you to install an operating system and applications into a virtual (emulated) computer (complete with BIOS and hardware configuration options) that is isolated from your actual PC and any changes made to the virtual PC affect only it.
The upshot of this is that you are able to more easily deploy and test your software in a clean environment, and once done either wipe out that environment or just wipe out the changes you made to it, perfect for testing your add-in on a clean Windows Home Server.
Terminology
Before going into how we can use Virtual PC 2007 to make our testing and development job easier, you should be familiar with the following terms:
- Virtual PC - The Virtual PC 2007 application
- Virtual machine - Generic term for a virtual PC/environment or a specific configured and installed virtual PC to be run in Virtual PC 2007
- VPC - A specific virtual machine
- Host PC/OS - The computer/operating system on which Virtual PC 2007 is running
- Guest PC/OS - The computer/operating system running within Virtual PC 2007
- Virtual Machine Additions - Software that runs on the guest PC that enables it to take better advantage of the underlying system and interact more seamlessly with the user such as dragging files back and forth between the host PC and the guest PC
Special keys
While Windows Home Server requires you to use the Control+Alt+Delete keystroke to login, Virtual PC requires you to use the keystroke Right Alt+Delete.
Until you have installed the Virtual Machine Additions (discussed later), whenever you click your mouse inside of the VPC window, it will be trapped there... until you press the Right Alt key to release it back to the host environment.
You may also make the VPC full screen by using the right Alt+Enter key combination, as well as bring it out of full screen mode with the same combination. Note that you should not attempt to full screen the VPC until after you have installed the Virtual Machine Additions and after you have logged in to the guest PC.
Requirements
In order to take advantage of Virtual PC you'll need three things:
1. A beefy PC*
2. An installed copy of Virtual PC 2007
3. A licensed copy of Windows Home Server (full or evaluation version)
*Caution: Running any modern operating system in a virtual machine requires significant system resources (hard drive, ram and CPU) and will likely reduce the performance of both the host PC and the guest PC while in use.
Support
It must be mentioned that running Windows Home Server in a virtual machine is completely unsupported by Microsoft and if you have any problems with it, Microsoft support will likely not be willing or able to assist you.
Initial Setup
In order to install Windows Home Server to a VPC (Virtual PC), you first need to create it with the built in wizard, however to save time I've provided an empty VPC here which is simply configured to use 512 megs of ram, 3 virtual hard drives and use undo disks... otherwise you can build it yourself, just make sure that the Virtual PC you create meets the WHS minimum system requirements.
In order to use the empty VPC, simply download it and extract the archive to a hard drive (preferably non-network) with plenty of disk space (at least 10 GB).
Installation
To begin installing Windows Home Server to your new VPC...
1. Insert Windows Home Server Installation DVD into DVD drive of your host PC
1a. Close any AutoPlay or AutoRun dialog that is displayed
2. Launch the VPC by either:
2a. Launch Virtual PC 2007, select the desired virtual machine from the list and press the Start button
2b. Double click on the 'Windows Home Server' file from the empty VPC you've previously downloaded
3. From the CD menu of the new window, select "Use Physical Drive X:" where X is the drive on your host PC where the install DVD has been inserted
3a. If the virtual machine booted faster than you could carry out step 3, after you have done so, use the Action -> Reset option to restart the virtual machine
4. Proceed through the normal setup process
5. When prompted for a CD key, enter your own (but do not activate later when prompted) or simply click Next and accept warning that you will have to enter one within 30 days
6. Specify a name for your Home Server like vmserver or servervm, something that is different (but similar) than any you already have so as to avoid naming conflicts but will make going back and forth between real and virtual easier
7. Grab yourself a sandwich, watch a movie and maybe consider taking a nap as installing Windows Home Server to a virtual environment will take a significant amount of time
Virtual PC Features
While you wait ~3+ hours for Windows Home Server to install, let's discuss some of what Virtual PC does for us.
Aside from being an extra Home Server environment to test with, the virtual hard disks allow you to save only when you want to, this is enabled through the optional use of undo disks.
When enabled, any changes made inside of the guest operating environment (files changed, applications installed/removed, events written to logs, etc) are written to an undo disk instead of the main virtual hard disk where things are mostly read from.
When it comes time to shut down (or forcefully close) the virtual machine you have a choice, do you want to save the state in the undo disk back to the virtual hard disks, thus making the changes permanent, keep the changes in the undo disk so you can keep working in that temporary change set, or throw out the undo disk completely.
Virtual PC will ask you what you want to do whenever you're virtual machine has undo disks enabled (which is the case of the one I've built for you) and the virtual machine is either closed due to it being shut down internally (Start -> Shutdown) or you click the big red x of the Virtual PC window, these options are:
- Save state and save changes - Puts the current virtual machine into a state of suspended animation, enabling you to start up the virtual machine again in the exact state it was in in at the time of the state save.
- Shut down Windows Server 2003 and save changes - Gracefully shuts down the guest PC and saves changes to the undo disk and is equivalent to pressing the power button on the front of a real PC.
- Turn off and save changes - Immediately turns of the virtual machine and keeps any changes made since the last start up to the undo disk and is equivalent of yanking the power cable from a real PC.
- Turn off and delete changes - Immediately turns off the virtual machine and throws out any changes stored in the undo disk and is equivalent to yanking the power cable from a real PC and formatting the hard drive and reloading it with a previous disk image.
- Commit changes to the virtual hard disk - Writes any and all changes in the undo disk to the virtual hard disk.
Choose the operation with care because in many cases once done, it cannot be undone. Personally I tend to stick with Turn off and delete changes after most testing so that I never have to deal with a modified test environment until I really want to, in which case Save state and save changes or Shut down Windows Server 2003 and save changes let me keep those changes so long as I want.
Post-installation configuration
Before using a new guest PC for testing, it's a good idea to configure it just how you want with user accounts (ideally with the same usernames and passwords that you use on your real Home Server and will be working/testing with) and run Windows Update to install all updates you'll want, as well as install the Virtual Machine Additions, to install them:
1. From the Action menu of the parent window, select Install or Update Virtual Machine Additions
2. Read dialog and press Continue button
3. Wait for the installer to launch
If the installer doesn't launch, run x:\Windows\setup.exe where X is the CD/DVD drive within the VPC.
4. Click Next to begin installing and press the Finish button once complete
5. Press the Yes button to restart virtual machine
Once fully updated and configured, shutdown the Virtual PC using Start -> Shutdown and when prompted, Commit the changes to the virtual hard disk.
What you can do
When fully up and running, the experience of testing with Windows Home Server in a virtual machine is very similar to using Remote Desktop to connect to a real Home Server, the key difference (aside from the whole state saving/deleting bits) is that instead of having to configure network shares to easily move files back and forth, a user can simply drag and drop files between the host PC and the guest PC.
30 days later
Unless you activate the copy of Windows Home Server that is running in Virtual PC (which would be bad if you only have a single licenses and already activated the same copy on physical hardware), the server will enter reduced functionality mode which will keep you from doing any additional testing.
When this happens, the best thing to do is delete the VPC files from the host PC, and then extract the empty VPC from the previously downloaded archive and go through this whole process again.
Conclusion
With Virtual PC 2007 and Windows Home Server you can easily test out your new add-in or other software that targets WHS in a pristine test environment that you control every aspect of and quickly and easily create and restore for testing almost anything.
Next week
Next week I will show how you can use Virtual PC and Visual Studio to automatically deploy, test and even debug your add-in with every build without any dragging and dropping, making testing even faster which gives you even more time to write killer add-ins.
Note: The information in this post is based on undocumented and at times deduced information on Windows Home Server and is not officially supported or endorsed by Microsoft and could very easily be wrong or subject to change in future, so please take it and everything else said on this blog with a grain of salt and use with caution.
Read the complete post at http://ihatelinux.blogspot.com/2007/12/whs-developer-tip-8-virtual-pc.html