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.
<strong>Virtual</strong> <strong>Disk</strong> <strong>API</strong> Sample Code<br />
The sample program’s -single option, which opens a single link instead of the entire disk chain, is supported<br />
for (local) hosted disk, but not for (remote) managed disk.<br />
To connect to an ESXi host with the sample program, you must specify the options -host, -user, -password,<br />
and provide a diskPath on the ESXi host’s datastore. For example:<br />
vix-diskLib-sample -info -host esx5 -user root -password secret "[datastore1] /.vmdk"<br />
To connect to vCenter Server, you must also specify the options -libdir and -vm. Programs need libdir so<br />
the <strong>Disk</strong>LibPlugin can connect with vCenter Server, which must locate the VM. For example:<br />
vix-diskLib-sample -info -host vc5 -user Administrator -password secret<br />
-libdir -vm vmPath= "[] /.vmdk"<br />
The vmPath is formulated in vSphere Client by starting at vCenter and inserting /vm/ before the VM name.<br />
The diskPath is ascertained by clicking Edit Settings > Hard <strong>Disk</strong> and copying the <strong>Disk</strong> File name.<br />
vix-disklib-sample -info -host vc5 -user Administrator -password secret<br />
-libdir /usr/lib/vmware-vix-disklib/lib32 -vm vmPath=Datacenter/vm/RHEL5<br />
"[datastore1] RHEL5/RHEL5.vmdk"<br />
To connect using an advanced transport, for example to virtual machine disk on SAN storage, you must also<br />
specify the options -mode and -ssmoref. The transport mode and managed object reference (of a snapshot)<br />
are required for Vix<strong>Disk</strong>Lib_ConnectEx(). To find the ssmoref, log in to the managed object browser for the<br />
vCenter Server, and click content > rootFolder > Datacenter > datastore > vm > snapshot. A snapshot must<br />
exist, because it is a bad idea to open the base disk of a powered‐on VM.<br />
vix-disklib-sample -info -host vc5 -user Administrator -password secret -mode san<br />
-libdir /usr/lib/vmware-vix-disklib/lib32 -vm vmPath=Datacenter/vm/RHEL5<br />
-ssmoref snapshot-72 "[datastore1] RHEL5/RHEL5.vmdk"<br />
On 64‐bit Linux, would end in /lib64 not /lib32. On Windows, the VDDK package installs<br />
diskLibPlugin.dll in the \bin folder, not the \lib folder, so change accordingly.<br />
Walk-Through of Sample Program<br />
The sample program is the same for Windows as for Linux, with #ifdef blocks for Win32.<br />
Include Files<br />
Windows dynamic link library (DLL) declarations are in process.h, while Linux shared object (.so)<br />
declarations are in dlfcn.h. Windows offers the tchar.h extension for Unicode generic text mappings, not<br />
readily available in Linux.<br />
Definitions and Structures<br />
The sample program uses twelve bitwise shift operations (1