Access Files on Virtual Disks
It might be necessary for a backup application to access individual files or groups of files on the virtual disks. For example, data protection applications might need to restore individual files on demand.
You can find the interfaces to accomplish this in the
VixMntapi
library associated with VixDiskLib
. The VixMntapi
library allows disks or volumes of a virtual machine to be mounted and examined as needed. VixMntapi
provides access at the file system level, whereas VixDiskLib
provides access at the sector level.To mount a virtual disk
- Locate the path names of all the virtual disks associated with a snapshot.
- CallVixDiskLib_Open()to open all of these virtual disks. This gives you a number ofVixDiskLibhandles, which you should store in an array.
- CallVixMntapi_OpenDiskSet()to create aVixDiskSetHandle, passing in the array ofVixDiskLibhandles that you created in step 2.
- PassVixDiskSetHandleas a parameter toVixMntapi_GetVolumeHandles()to obtain an array ofVixVolumeHandlepointers to all volumes in the disk set.
- CallVixMntapi_GetOsInfo()to determine what kind of operating system is involved, and decide where important pieces of information are to be found.
- For important volumes, callVixMntapi_MountVolume()thenVixMntapi_GetVolumeInfo(), which reveals how the volume is set up. (Unimportant volumes include swap partitions.)
- If you need information about how the guest operating system sees the data on this volume, you can look in the data structureVixVolumeInforeturned byVixMntapi_GetVolumeInfo(). For example,VixVolumeInfo::symbolicLink, obtained usingVixMntapi_GetVolumeInfo(), is the path on the proxy where you can access the virtual disk’s file system using ordinary open, read, and write calls.
Once you are done accessing files in a mounted volume, there are
VixMntapi
procedures for taking down the abstraction that you created. These calls are:- VixMntapi_DismountVolume()for each volume handle
- VixMntapi_FreeOsInfo()andVixMntapi_FreeVolumeInfo()
- VixMntapi_CloseDiskSet()
This leaves the
VixDiskLib
handles that you obtained in the beginning; you must dispose of them properly.