Virtual Disk API Programming Guide - Documentation - VMware
Virtual Disk API Programming Guide - Documentation - VMware
Virtual Disk API Programming Guide - Documentation - VMware
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Sample VixMntapi Code<br />
<strong>Virtual</strong> <strong>Disk</strong> Mount <strong>API</strong><br />
You call the VixMntapi functions after initializing Vix<strong>Disk</strong>Lib, connecting to a virtual machine, and opening a<br />
disk handle. Here is sample code for Windows showing correct order of function calls.<br />
MountTest() {<br />
vixError = VIX_ERR_CODE(Vix<strong>Disk</strong>Lib_Init() );<br />
vixError = VIX_ERR_CODE(VixMntapi_Init() );<br />
Vix<strong>Disk</strong>Lib_ConnectEx(&connectParams, TRUE, NULL, NULL, &connection));<br />
diskHandles = GetMy<strong>Disk</strong>Handles(diskPaths, connection, &connectParams, flags, &numberOf<strong>Disk</strong>s);<br />
vixError = VIX_ERR_CODE(VixMntapi_Open<strong>Disk</strong>Set(diskHandles, numberOf<strong>Disk</strong>s, flags, &diskSet));<br />
GetOsInfo(diskSet);<br />
vixError = VIX_ERR_CODE(VixMntapi_GetVolumeHandles(diskSet, &numberOfVolumes,<br />
&volumeHandles));<br />
for(size_t i = 0; i < numberOfVolumes; i++) {<br />
VixVolumeHandle volumeHandle = volumeHandles[i];<br />
VixVolumeInfo *volumeInfo;<br />
vixError = VIX_ERR_CODE( VixMntapi_MountVolume(volumeHandle, TRUE) );<br />
vixError = VIX_ERR_CODE( VixMntapi_GetVolumeInfo(volumeHandle, &volumeInfo) );<br />
VixMntapi_FreeVolumeInfo(volumeInfo);<br />
VerifyMountedVolume();<br />
CleanUpMountedVolume(volumeHandle, volumeInfo);<br />
}<br />
VixMntapi_FreeVolumeHandles(volumeHandles);<br />
vixError = VIX_ERR_CODE( VixMntapi_Close<strong>Disk</strong>Set(diskSet) );<br />
FreeMy<strong>Disk</strong>Handles(diskHandles, numberOf<strong>Disk</strong>s);<br />
VixMntapi_Exit();<br />
Vix<strong>Disk</strong>Lib_Exit();<br />
}<br />
Restrictions on <strong>Virtual</strong> <strong>Disk</strong> Mount<br />
The following limitations apply when mounting virtual disks:<br />
You cannot mount virtual disks that are in use by a running or suspended virtual machine. You can mount<br />
disks from a powered off virtual machine, disks not associated with a virtual machine, or base disks when<br />
a Windows virtual machine is running off a snapshot (read‐only).<br />
On Windows virtual machines you can mount previous snapshots read‐only. On Linux virtual machines<br />
you cannot mount previous snapshots.<br />
If you specify a virtual disk with snapshots on a powered off virtual machine, VixMntapi locates and<br />
mounts the last snapshot in the disk chain. While a disk is mounted, do not revert to a previous snapshot<br />
using another <strong>VMware</strong> interface – this would make it impossible to unmount the partition.<br />
You cannot mount virtual disk if any of its .vmdk files are encrypted, compressed, or read‐only. However<br />
you can change these attributes and then mount the virtual disk.<br />
With Windows, you must mount virtual disks on drive D: or greater, and choose a drive letter not in use.<br />
With Linux, kernel version 2.6 or higher is required to run the FUSE (file system in user space) module.<br />
You cannot mount Linux swap or extended partitions. Logical Volume Manager (LVM) is not supported.<br />
You can mount Windows virtual disks on Windows hosts (with an NTFS volume) or Linux virtual disks<br />
on Linux hosts. Cross‐mounting is restricted but may be allowed for cross‐formatted file systems.<br />
<strong>VMware</strong>, Inc. 93