Virtual PC printer driver

A method and system for printing from a guest operating system that executes in a virtual PC. In the guest operating system, a special printer driver (or extension to an existing printer driver) is installed. The printer driver receives print data from the guest operating system and applications that execute therein. The printer driver or an extension thereof forwards the print data or data derived therefrom to a host component that executes in a host operating system. The host component forwards the print data or data derived therefrom to the normal print mechanisms within the host operating system.

FIELD OF THE INVENTION

The invention relates generally to computers, and more particularly to virtual computers.

BACKGROUND

With the multitude of operating systems and versions thereof, developers have created software that provides virtual machines (sometimes referred to as virtual PCs). A virtual PC is a software-created environment that may appear, to the operating system and applications that execute therein, to have most or all the elements associated with an actual PC. The software-created environment may be so complete that the operating system and applications that execute on a virtual PC may not be able to determine that they are executing in a virtual environment.

Providing virtual PCs is useful for many reasons including debugging and supporting applications designed to execute on multiple versions of one or more operating systems, having access on a single machine to applications that are only available for different operating systems, and so forth. To execute multiple operating systems on one actual computer, a user may load a primary operating system on the computer, load software to create one or more virtual PCs, and then load one or more other operating systems that execute in the one or more virtual PCs. This allows, for example, an Apple® (or other) operating system to provide a virtual PC to host a Microsoft® operating system, a UNIX® operating system, a LINUX® operating system, another Apple® operating system, or some other operating system.

Providing a virtual PC that seamlessly and effectively provides all the functionality of a real PC has eluded those skilled in the art. This is particularly true with respect to printing functions associated with the virtual PC.

SUMMARY

Briefly, the present invention provides a method and system for printing from a guest operating system that executes in a virtual PC. In the guest operating system, a special printer driver (or extension to an existing printer driver) is installed. The printer driver receives print data from the guest operating system and applications that execute therein. The printer driver or an extension thereof forwards the print data or data derived therefrom to a host component that executes in a host operating system. The host component forwards the print data or data derived therefrom to the normal print mechanisms within the host operating system.

The method and system described herein are able to obtain print data from a guest operating system without resorting to hardware emulation to obtain that data. That is, in accordance with aspects of the invention, a printer port does not need to be emulated in order to print from a guest operating system and applications that execute therein. In accordance with other aspects of the invention, printing from a guest operating system may be performed without extensive user configuration.

DETAILED DESCRIPTION

Exemplary Operating Environment

Printer Driver

FIG. 2shows a view of a graphical user interface that operates in accordance with various aspects of the invention. In the user interface, there is a desktop205that includes four windows210-213. Windows210,211, and213represent views of applications that execute on the operating system that is native to the device upon which the graphical user interface is shown. The native operating system is sometimes referred to as the host operating system or simply as the host. Virtual PC window212represents the graphical user interface of an operating system and related applications that execute on a virtual PC. The operating system that executes on the virtual PC is sometimes referred to as a guest operating system or simply as a guest. When maximized, the view shown in the virtual PC window212may be indistinguishable from a view shown if the guest operating system were run natively on the device.

FIG. 3is a block diagram that illustrates exemplary components that may be used to practice the invention in accordance with various aspects of the invention. A host operating system (OS)305provides a virtual PC for a guest OS310. The guest OS310may include an application315, a printer driver320, and a printer driver extension325. The host OS305includes a virtual PC component330, and a host machine printer driver335. Also shown is a printer340.

The application315may interact with the printer driver320when the application is attempting to print to a printer. In one embodiment of the invention, the printer driver320comprises a generic PostScript® printer driver. A generic Postscript® printer driver may receive data in a variety of formats and translate the data into PostScript®. It will be understood, however, that other printer drivers and formats may be used without departing from the spirit or scope of the present invention.

In another embodiment of the invention, the graphic data that is sent from application315and received by the printer driver320is sent unmodified by the printer driver320to the printer driver extension325. In other words, the raw data that is received from application315for printing by the printer driver320is sent to the printer driver extension325. This raw data is then sent to the virtual PC component330and may then be translated by the virtual PC component330into another format or may be sent directly to the host machine printer driver335. Sending the raw data that is received from the application315to the host machine printer driver335may be particularly useful when the host and guest operating systems are similar or identical (e.g., a Windows® operating system hosting another Windows® operating system) as no translations or loss of fidelity may occur.

The printer driver extension325receives the output from the printer driver320and sends the output outside the virtual PC on which the Guest OS310executes to the virtual PC component330. In one embodiment, the printer driver extension325transfers the output it receives from the printer driver320to the virtual PC component using direct memory transfers of 4K sized blocks. It will be understood, however, that many other transfer mechanisms and/or block sizes may be used without departing from the spirit or scope of the invention. The printer driver extension325may wait until it has received a predefined or selected size of output from the printer driver320before it sends the output to the virtual PC component330.

The printer driver extension325may be structured to intercept the output from the printer driver320and to stop the printer driver320from sending the output to a virtual printer port (not shown) (e.g., LPT1) associated with the Guest OS310. This may be done to prevent any output from the printer driver320from being transmitted to the Host OS305through port emulation mechanisms.

The printer driver320may inform the printer driver extension325when a print job is finished. This may be done through the use of an API call, a callback, or some other mechanism without departing from the spirit and scope of the invention.

The virtual PC component330sends the output received from the printer driver extension325to the host machine printer driver335which then sends the output to the printer340. The virtual PC component330may wait until a complete print job is received before it sends the print job to the host machine printer driver335. Alternatively, the virtual PC component330may send data to the host machine printer driver335as the data is received.

The host machine printer driver335may translate the output received from the virtual PC component330into a format suitable for the printer340. In some embodiments of the invention, no translation may be necessary as the printer340may be configured to accept and print the output without translation. For example, if the printer driver extension325sends PostScript®-formatted data to the virtual PC component330which then sends the PostScript®-formatted data to the host machine printer driver335and the host machine printer driver335prints to a PostScript®-capable printer, no translation may be required.

The printer driver320, the printer driver extension325, and/or the host machine printer driver335may be implemented using APIs, through an OS mechanism appropriate for the particular OS, or otherwise without departing from the spirit or scope of the invention.

The printer driver extension325may be installed with or after the Guest OS310is installed. In one embodiment of the invention, the functionality of the printer driver extension325may be included in the printer driver320. In this embodiment, there is no need to have a separate printer driver extension325. It will be understood that implementing the functionality of the printer driver extension325in a software module separate from an existing printer driver may be simpler than creating a new printer driver and adding the functionality of the printer driver extension325because all the routines of an existing printer driver may not need to be implemented in the printer driver extension325. By creating a printer driver extension instead of a new printer driver, a developer may be able to provide just those methods needed to receive and forward output from the printer driver and to stop the printer driver from printing to an emulated hardware device.

The virtual PC component330that communicates with the printer driver extension325may also be installed with the host OS305or at a later time as a separate installation. The virtual PC component330will typically comprise many other components (not shown) in addition to the component that communicates with the printer driver extension325.

The Host OS305may be modified or extended to provide the user with a mechanism for choosing to which printer output from each guest OS may be printed. Each guest OS may be associated with its own unique printer or it may associated with a printer to which other guest OSes are associated.

The guest OS310may also be modified to dispose of any print jobs in a print queue that are directed to the printer driver320upon boot up. For example, the guest OS310may be shut down or cease operation in the middle of printing a list of print jobs. Rather than resuming these print jobs upon startup, the print jobs in the print queue may be cancelled or deleted. In another embodiment of the invention, however, the guest OS310may resume printing of the print jobs in the print queue after the guest OS310has booted up and started normal execution.

It will be recognized that the system described above has many advantages over other mechanisms for printing from a guest OS. One other such mechanism includes emulating a printer port for the guest OS. This mechanism has many problems including knowing when the print job has completed, extraneously printing pages (e.g., at boot up because of boot sequence port transmissions), the slow speed with which the print job is transferred, determining the format of the print job (e.g., PostScript® or otherwise), issues related to what happens if the guest OS is paused, hibernated, or stopped, and the like.

Another mechanism for printing from a guest OS comprises an Epson®-emulated mode in which data received at an emulated printer port is translated into an Epson® dot matrix printer format. This mechanism suffers from low print quality, slow speed, and a small palette of color.

Furthermore, the alternative mechanisms described above also generally suffer when an application attempts to use the emulated printer port for a purpose other than printing (e.g., for scanning, Zip® drives, and the like). Using an emulated printer port for one of these purposes may cause extraneous pages to be printed or have other side effects.

Another mechanism for printing from a guest OS comprises configuring the guest OS to print to a network printer. While this mechanism is more reliable for detecting print jobs and forwarding them appropriately, it may require a great deal of configuration to initially configure a guest OS to print to a network printer.

Another mechanism for printing from a guest OS comprises giving the guest OS control of a USB port that is connected to the desired printer. While this mechanism is also more reliable for printing, it also may require a great deal of configuration to set up the guest OS to print to the desired printer including finding and installing drivers for the guest OS for the selected printer. In addition, while the guest OS has control of the USB port, the printer may not be available for use by the host OS.

Printing from a guest OS to a host OS through a printer driver as describe previously may be used instead of or in addition to the above mechanisms.

FIG. 4is a flow diagram that generally represents exemplary steps that may occur to print from a virtual PC environment in accordance with various aspects of the invention. The process begins at block405. At block410the virtual PC software is installed on the host (if it has not already been installed). At block415, the guest OS is installed on the guest.

At block420, a print job is requested by an application. The print job is printed to the guest printer driver at block425. At block430, the output from the guest printer driver is sent to a virtual PC component on the host. At block435, the virtual PC component on the host sends the output to the host printer driver (or equivalent). The host printer driver (or equivalent) prints to a printer using the output.

At block440, a determination is made as to whether another print job needs to be printed. If not, the process ends at block445. Steps420-435of the process above may be performed each time an application attempts to print.

It will be recognized that aspects of the invention described herein may be applied to many operating systems, currently existing and later developed, without departing from the spirit or scope of the invention. For example, any operating system that is configured with a virtual component (e.g., printer driver extension325) that obtains output from a printer driver (or its equivalent) and sends this output instead to a component executing on the host OS (e.g., virtual PC component330) may use aspects of the invention described herein to obtain reliable printing from a virtual PC. The virtual component that obtains output from the printer driver may need to reformat the output to Postscript® or some other format that the component executing on the host is expecting.