Thursday, July 31, 2008

Thinking Outside the (Virtual) Box (2)

Previously I described how I installed WinXP Pro on a VirtualBox virtual PC, as a last ditch attempt to get MS Office running on my box. It turned out that VirtualBox is amazingly fast, even on my old laptop, so I decided to go ahead and install MS Office. But first there were several lesser chores to complete: Window$ Update and installing a printer.

Windows Update was easy enough - but tedious: my installation media is from 2002 (SP1). Several hundred megabytes and a few virtual reboots later, and the upgrade process was complete. Installing the printer, however, was less of a picnic.

Our HP Officejet 5510 all-in-one is connected via USB to my laptop, driven by HPLIP and managed by CUPS. My plan was to setup an IPP printer on the virtual Windows machine, similar to the setup on my wife's real laptop.

HP ships an installation CD with its printers with shit-load of useless software, which takes forever to install. It was only after installing and using HPLIP that I realized how shitty it really is on Windows. What's really strange about this is that HP provides the software for both Windows and Linux. Go figure.

Anyhow, my point is that the CD isn't required: HP provides a "corporate" version of the printing drivers, a lean 34MB (!?) package, that you can download from their website, in case you need to install the printer in a "corporate environment" (read: when the printer is not directly connected to your computer).

I did not anticipate any problem here:
  1. download the corporate driver package (it's a self extracting archive),
  2. launch it, (it should happily extract itself to C:\temp)
  3. find the freshly extracted setup.exe and launch it,
  4. connect a printer directly to the USB port, and let plug-n-play do its stuff.

This very same procedure worked nicely on my wife's laptop. But not on the virtual PC. That setup.exe just died several seconds after starting - no error message, no BSOD, it just dies.WTF?

What do you do when you have no decent logging, no source code and no strace to help you start figuring out what's wrong? easy: you guess. Oh, and you're very likely to guess wrong and end up doing some damage before hitting the right solution, if at all.

Guess #1: a corrupted download. It took a while to verify - my link to the HP website was damn slow at the time - but both md5sum and sha1sum insisted that I got all the bits and in the right order.

Guess #2: just before it died, the installer seemed to setup a recovery point. Maybe that's the problem? I disabled the system restore feature (and, in the process, lost any previously created recovery point) and tried again. Same result.

Guess #3: it suddenly dawned on me - the installer dies because it can't find any USB controller. The Open-Source Edition of VirtualBox does not support USB. This seemed like a plausible explanation, yet I had no supporting evidence. I also had my doubts: this was the corporate driver package, which should support a network-printer configuration.

And if this theory was right, what do I do now? it looked hopeless. But I had an idea: maybe there's a software only virtual USB controller out there, that can be used to fool the installer into thinking that there's USB on my virtual PC?

As improbable as this may seem, such a beast does exist - it's called the Device Simulation Framework - and is written by none other than Microsoft itself. It's also freely distributed as part of the WDK - the Windows Driver Kit. Getting the WDK ISO image is a bit of a chore, but it can be done. Eventually.

Once downloaded, you only need to mount the ISO image into a virtual optical drive, and follow the DSF installation instructions:
  1. double click dsfx86runtime.msi in the \dsf directory,
  2. create a virtual USB controller:
    • open a Command Prompt window,
    • navigate to the \Program Files\dsf\softehci folder,
    • run softehcicfg /install


This time around the installer did not die. I guessed right. Whew.

My next problem was to convince the plug-n-play machinery that the printer drivers should actually be installed, so that I could specify it as the IPP printer's driver. With my wife's PC it was easy: I simply hooked up the printer directly to one of its USB ports, and a new printer icon was automagicly installed. But, as we already know, VirtualBox OSE does not have USB...

I tried double clicking some of the .inf files that were installed, I tried running some of the setup executables that were also installed. I shouldn't have done that - but it was late at night, and I wasn't thinking straight. Luckily nothing happened. Which was also unfortunate.

It took another guess to get this done: I shared the USB printer on my wife's laptop (which isn't really connected to anything - I kept it installed just in case), and added a printer on the virtual PC that points to this shared printer. The drivers were then automatically installed, and I could then create yet another printer to point to the real printer via its CUPS URL.

For some reason I can't print a test page from the printer's property pages, but otherwise printing works just fine.

The rest of the story is rather boring: I installed MS Office, and then ran Microsoft Update several times, until no updates were left to install.

Finally, I installed the VirtualBox Guest Additions. The Guest Additions provide shared folders, auto screen resize, auto input focus for keyboard and mouse, and the cool-yet-useless seamless mode.

Next time: running a live-HDD under VirtualBox.

No comments:

Post a Comment