The VixMntapi library supports guest operating systems on multiple platforms. On POSIX systems it requires FUSE mount, available on recent Linux systems, and freely available on the SourceForge Web site.Definitions are contained in the following header file, installed in the same directory as vixDiskLib.h:The VixOsInfo structure encapsulates the following information:
■ Family of the guest operating system, VixOsFamily, one of the following:
■
■
■
■
■ The VixVolumeInfo structure encapsulates the following information:
■ Type of the volume, VixVolumeType, one of the following:
■ GPT – GUID Partition Table. However, VixMntapi does not support GPT partitions.
■ LVM – Logical Volume Manager disk storage.
■ On Windows, numGuestMountPoints is the number of times a basic volume is mapped to a drive letter, or 0 if the volume is not mounted. IDE and boot disk come first. Unimplemented on Linux.To obtain these functions, load the vixMntapi library separately from the vixDiskLib library. On Windows, compile with the vixMntapi.lib library so your program can load the vixMntapi.dll runtime.These calls can be used to mount and read Windows virtual disks on Windows hosts (with at least one NTFS volume) or Linux virtual disks on Linux hosts. Cross-mounting is restricted, though it is possible to mount a virtual disk with a mix of formats, if the mounted partition was formatted with Windows.
Important You should run only one vixMntapi program at a time on a virtual machine, to avoid conflict between registry hives. See Multithreading Considerations for advice on worker threads.The remainder of this section lists the available function calls in the vixMntapi library. Under parameters, [in] indicates input parameters, and [out] indicates output parameters. All functions that return vixError return VIX_OK on success, otherwise a suitable VIX error code.
■ majorVersion [in] VixMntapi major version number, currently must be 1 (one).
■ minorVersion [in] VixMntapi minor version number, currently must be 0 (zero).
■ log [in] Callback function to write log messages.
■ warn [in] Callback function to write warning messages.
■ panic [in] Callback function to report fatal errors.
■ Opens the set of disks for mounting on a Windows or Linux virtual machine. All the disks for a dynamic volume or Logical Disk Manager (LDM) must be opened together.The VixDiskLibHandle type, defined in vixDiskLib.h, is the same as for the diskHandle parameter in the VixDiskLib_Open() function, but here it is an array instead of a single value.
■ diskHandles [in] Array of handles to open disks.
■ numberOfDisks [in] Number of disk handles in the array.
■ openMode [in] Must be 0 (zero).
■ diskSet [out] Disk set handle to be filled in.If you want to mount from a Windows system, first call VixDiskLib_Open() for every disk, then use the returned disk handle array to call VixMntapi_OpenDiskSet(), which returns a disk set handle.If you want to mount from a Linux system, call the function VixMntapi_OpenDisks(), which opens and creates the disk set handle, all in one function.Opens disks for mounting on a Windows or Linux virtual machine. On Linux, the Logical Volume Manager (LVM) is not supported.
■ connection [in] The VixDiskLibConnection to use for opening the disks. Calls VixDiskLib_Open() with the specified flags for each disk to open.
■ diskNames [in] Array of disk names to open.
■ numberOfDisks [in] Number of disk handles in the array. Must be 1 for Linux.
■ flags [in] Flags to open the disk.
■ handle [out] Disk set handle to be filled in.
■ handle [in] Handle to an open disk set.
■ diskSetInfo [out] Disk set information to be filled in.Frees memory allocated by VixMntapi_GetDiskSetInfo().
■ diskSetInfo [in] OS info to be freed.
■ diskSet [in] Handle to an open disk set.Retrieves handles to volumes in the disk set. The third parameter VixVolumeHandle can be a volume handle or an array of volume handles. If you pass an array this function returns the volume handle for the first volume only. If you pass a pointer (such as VixVolumeHandle *volumeHandles) it returns all the volume handles.
■ diskSet [in] Handle to an open disk set.
■ numberOfVolumes [out] Number of volume handles.
■ volumeHandles [out] Volume handles to be filled in.Frees memory allocated by VixMntapi_GetVolumeHandles().
■ volumeHandles [in] Volume handle to be freed.To get operating system information, VixMntapi_GetOsInfo() requires the system and boot volumes to be already mounted. It does not dismount the system volume at the end of this function. Your application should be prepared to handle the “volume already mounted” error gracefully.This function is effective only when used with operating systems of the same type. For instance, a VixMntapi program running on Windows can provide information about the VMDK of a Windows virtual machine, but not about the VMDK of a Linux virtual machine.
■ diskSet [in] Handle to an open disk set.
■ info [out] OS information to be filled in.Frees memory allocated by VixMntapi_GetOsInfo().
■ info [in] OS info to be freed.Mounts the volume. After mounting the volume, use VixMntapi_GetVolumeInfo() to obtain the path to the mounted volume. This mount call locks the source disks until you call VixMntapi_DismountVolume(). The VixMntapi_MountVolume() function cannot mount Linux swap or extended partitions.
■ volumeHandle [in] Handle to a volume.
■ isReadOnly [in] Whether to mount the volume in read-only mode. Does not override openMode.
■ volumeHandle [in] Handle to a volume.
■ force [in] Force unmount even if files are open on the volume.Retrieves information about a disk volume. Some information, such as the number of mount points, requires you to set the open read-only flag. Some information is available only if a volume was previously mounted by VixMntapi_MountVolume(). The Windows registry returns volume information only for mounted disks. On Windows the VixMntapi_GetVolumeInfo() call returns a symbolic link from the VixVolumeInfo structure in the form \\.\vstor2-mntapi10-shared-<longhexnum>\. You can transform this symbolic link into a target path by replacing \\. with \Device and deleting the final backslash, then map a drive letter with DefineDosDevice(DDD_RAW_TARGET_PATH,...) and proceed as if you have a local drive. Alternatively on Windows, you can open a volume with CreateFile() and traverse the file system with FindFirstFile().
■ volumeHandle [in] Handle to a volume.
■ info [out] Volume information to be filled in.Frees memory allocated in VixMntapi_GetVolumeInfo().
■ info [in] Volume info to be freed.