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

Procedure

  1. Locate the path names of all the virtual disks associated with a snapshot.
  2. Call VixDiskLib_Open() to open all of these virtual disks. This gives you a number of VixDiskLib handles, which you should store in an array.
  3. Call VixMntapi_OpenDiskSet() to create a VixDiskSetHandle, passing in the array of VixDiskLib handles that you created in step 2.
  4. Pass VixDiskSetHandle as a parameter to VixMntapi_GetVolumeHandles() to obtain an array of VixVolumeHandle pointers to all volumes in the disk set.
  5. Call VixMntapi_GetOsInfo() to determine what kind of operating system is involved, and decide where important pieces of information are to be found.
  6. For important volumes, call VixMntapi_MountVolume() then VixMntapi_GetVolumeInfo(), which reveals how the volume is set up. (Unimportant volumes include swap partitions.)
  7. If you need information about how the guest operating system sees the data on this volume, you can look in the data structure VixVolumeInfo returned by VixMntapi_GetVolumeInfo(). For example, VixVolumeInfo::symbolicLink, obtained using VixMntapi_GetVolumeInfo(), is the path on the proxy where you can access the virtual disk’s file system using ordinary open, read, and write calls.

Results

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() and VixMntapi_FreeVolumeInfo()
  • VixMntapi_CloseDiskSet()

This leaves the VixDiskLib handles that you obtained in the beginning; you must dispose of them properly.