# Patent

## Title
Sharing files among different virtual machine images

## Abstract

A method for sharing files among different virtual machine images includes steps of a) creating a first virtual image including one or more files; b) determining whether there exists a second virtual image that is similar to the first virtual image; c) comparing the one or more files of the first and second virtual images to determine a set of common files; d) creating a common file collection with the set of common files; f) creating a second version of the first virtual image with files in the first virtual image that are not in the common file collection; g) creating a second version of the second virtual image with files in the second virtual image that are not in the common file collection; h) receiving a request for modification of the file within one of the virtual images; and i) determining whether the file to be modified is in the set of common files.

## Background
CROSS-REFERENCE TO RELATED APPLICATIONS
This application relates to improvements on the invention of U.S. patent application Ser. No. 10/795,153, which is hereby incorporated by reference.
STATEMENT REGARDING FEDERALLY SPONSORED-RESEARCH OR DEVELOPMENT
Not Applicable.
INCORPORATION BY REFERENCE OF MATERIAL SUBMITTED ON A COMPACT DISC
Not Applicable.
FIELD OF THE INVENTION
The invention disclosed broadly relates to the field of information processing systems, and more particularly relates to the field of virtual machine images.
BACKGROUND OF THE INVENTION
Virtual machine (VM) software currently enables users to run multiple operating systems on a single physical machine by supporting VM bundles that encapsulate an entire hard disk as well as the state of the system RAM (random-access memory). Users often need to run the multiple VMs based on the same operating system. For example, one may want to run two Microsoft XP operating system images and two Linux operating system images in the same computer. It is wasteful to replicate the same OS system files in all of the XP images or in all of the Linux images. Consider, for example, an upgrade patch to be downloaded for upgrading an application program or the operating system. When multiple images exist, all must be modified to keep them in synchronization. Therefore, there is a need for a method and system that overcomes the above wasteful replication.
SUMMARY OF THE INVENTION
Briefly, according to an embodiment of the invention, a method includes steps of a) creating a first virtual image including one or more files; b) determining whether there exists a second virtual image that is similar to the first virtual image; c) comparing the one or more files of the first virtual image with the one or more files of the second virtual image to determine a set of common files; d) creating a common file collection with the set of common files; f) creating a second version of the first virtual image with files in the first virtual image that are not in the common file collection; g) creating a second version of the second virtual image with files in the second virtual image that are not in the common file collection; h) receiving a request for modification of the file within one of the virtual images; and i) determining whether the file to be modified is in the set of common files.



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 is a flowchart of a method of creating VM images according to an embodiment of the invention.
FIG. 2 is a high level block diagram showing an information processing system storing OS images according to another embodiment of the invention.
FIG. 3 is a flowchart of a method for applying modification to files according to another embodiment of the invention.
FIG. 4 is a flowchart of a method for applying a modification to a file in all virtual images.
FIG. 5 is a flowchart of another method for applying modifications to files according to another embodiment of the invention.



DETAILED DESCRIPTION
Referring to FIG. 1, there is shown a flowchart of a method 100 according to an embodiment of the invention. Step 102 creates a first virtual image comprising one or more Operating System files. Step 104 determines whether a similar virtual image exists. If no similar image exists, the method 100 ends. If there is an existing (second) virtual image, then in step 106 we point to the newly-created virtual image (first virtual image) as being similar to the existing virtual image (second virtual image). In step 108, we compare the one or more files of the first virtual image with the one or more files of the second virtual image to determine a set of common files. In step 110 we create a third image comprising a set of common files. In step 116 we create a second version of the first virtual image comprising only files in the first virtual image that are not in the file collection. In step 118 we create a second version of the second virtual image comprising only files in the second virtual image that are not in the file collection.
Referring to FIG. 2 , there is shown a high level block diagram showing an information processing system 200 according to another embodiment of the invention. The system 200 comprises a processor (e.g., one or more microprocessors) 202, an input/output subsystem 206 (e.g., including a user interface and a network interface for communicating with other machines within one or more networks). The system 200 also comprises non volatile storage (e.g., hard disk) 204. According to this embodiment of the invention, the storage 204 comprises virtual images XP0, XP1, and XP2. Each of these has Microsoft XP as its core operating system.
When the user creates a new virtual image, he gives it a name and has an idea of what he is going to install on the virtual image. At this time he identifies a similar virtual image, if he already has one. For instance, when he creates the second XP image (XP2) he points it to the first (XP1) as being similar. After that he installs a brand new XP image into XP2, then he runs a diff program that compares all of the files that are in XP1 with the corresponding files that are in XP2 and creates three images: (1) XP0 which has the common files; (2) XP1 which has only the files in XP1 that are not in XP0, and (3) XP2 that has only the files that are in XP2 and not in XP0.
During runtime, files may be modified in either XP1 or XP2. If the modified file actually turns out to be in XP0, it is removed from XP0 and moved into the appropriate XP1 or XP2 virtual image. At any time one may re-run the diff program to move common files to XP0. If two files are different even by one bit, they do not belong in XP0.
By running the diff program periodically one can easily capture identical changes to the two images. One place where an operation is likely to result in identical changes being applied to multiple virtual images is when security patches are applied to the virtual images. One can apply the patch to XP1 and then to XP2 and then rerun the diff program to synchronize the images again.
Alternatively, if a user can download the security patch and apply it while the virtual images are suspended, then the user can directly apply the patch to XP0 and any files in XP1 and XP2, instead of applying the patches one at a time. One may also lock down the core OS part of XP0 (e.g., directories and/or files) and prevent the creation of differences at run time. So users are prevented from modifying any of the core OS files or adding/deleting files in critical directories. Patches may be applied by the central administrator and replicated to all machines, if this mode of operation is supported, it may be advantageous to create XP0 even if we only have one XP1 on a machine. The foregoing sharing technique is specially important for the case where XP1 and XP2 are carried on portable media as described in U.S. patent application Ser. No. 10/795,153 where storage may be more limited than in non-portable computing apparatuses.
Referring to FIG. 3, there is shown a flowchart of a method 300 according to another embodiment of the invention. In step 302 we receive a modification for a file in a virtual image. The modification may take the form of a patch for an application program hosted by the system 200. In step 304 the system 200 makes a determination of whether the patch applies to a file in the shared collection XP0 or in one of the private collections XP1 or XP2. If the same application version is installed in both virtual machines, the file would most likely be in the shared collection since the same (identical) file is used in both virtual machines. If the determination 304 is that a copy of the file exists in the shared collection, then in step 306 the file is copied from that collection and placed in each private collection. In step 312 the file is removed from the shared collection and in step 314 the file is applied to the appropriate private collection. If the determination 304 is negative, the method 300 proceeds to step 308 where the received modification is applied to the target file. In step 310, the method 300 periodically performs step 502 of method 500.
Referring to FIG. 4, there is shown a flowchart of a method 400 according to another embodiment of the invention. A modification is received in step 402. This modification is for a file in all virtual images. In this method 400 the received modification is applied (steps 406 or 410) regardless of whether step 404 determines the existence of the filed to be modified in the shared collection. If the file is in the private collections, the modification is applied to the copies in the private collections.
Referring to FIG. 5, there is shown a flowchart of method 500 according to another embodiment of the invention. This method 500 is applied to resynchronize changes to files applied separately. In step 502 the files in the virtual images XP1 and XP2 are compared with each other. In step 504, all files that are identical copied from XP1 or XP2 into the shared collection XP0. In step 506, the files are deleted from XP1 and XP2. Then the method ends at this point.
Therefore, while there has been described what is presently considered to be the preferred embodiment, it will understood by those skilled in the art that other modifications can be made within the spirit of the invention.

## Claims

1. A computer-implemented method comprising steps of:
a) creating a first virtual image comprising one or more operating system files;
b) determining whether there exists a second virtual image that is similar to the first virtual image, wherein the second image comprises one or more operating system files;
c) comparing the one or more operating system files of the first virtual image with the one or more files of the second virtual image to determine a set of common operating system files;
d) creating a common operating system file collection comprising the set of common files;
e) creating a second version of the first virtual image comprising only files in the first virtual image that are not in the common operating system file collection;
f) creating a second version of the second virtual image comprising only files in the second virtual image that are not in the common operating system file collection;
g) receiving, during runtime, a request for modification of the operating system file within one or both of the first virtual image and the second virtual image, wherein the request comprises the modification and the modification comprises a security patch; and
wherein the request calls for the modification to be applied to all images and the method further comprises suspending the first and second virtual images, and applying the security patch to the first and second virtual images while the first and second virtual images are suspended, and wherein the security patch is directly applied to the common operating system file collection without migrating the operating system files into private collections;

h) determining whether the file to be modified is in the common operating system file collection;
i) removing the file from the common operating system file collection if the operating system file is in the common operating system file collection;
j) copying the operating system file into both the first and second virtual images; and
k) applying the modification to the operating system file in the requested one or both of the first and second virtual images.

2. The method of claim 1, further comprising periodically comparing the one or more operating system files of the first virtual image with the one or more files of the second virtual image to determine a set of common operating system files.

3. The method of claim 1, wherein the common operating system file collection comprises a core operating system part and the method further comprises locking the core operating system part and preventing modifying any core operating system operating system files or adding and deleting operating system files in specified directories.

4. The method of claim 1, further comprising receiving a patch from a system administrator to be applied to all virtual machines.

5. The method of claim 1, further comprising creating a second virtual image, comprising one or more operating system files, wherein the second virtual image is initially empty, if it is determined that there does not exist a second virtual image that is similar to the first virtual image.