Start Up
The VixDiskLib_Init() and VixDiskLib_Connect() functions must appear in all virtual disk programs.
VixDiskLib_Init() has been superseded by VixDiskLib_InitEx().
Initialize the Library
VixDiskLib_Init() initializes the old virtual disk library. The arguments majorVersion and minorVersion represent the VDDK library’s release number and dot-release number. The third, fourth, and fifth arguments specify log, warning, and panic handlers. DLLs and shared objects are located in libDir.
VixError vixError = VixDiskLib_Init(majorVer, minorVer, &logFunc, &warnFunc, &panicFunc, libDir);
You should call VixDiskLib_Init() only once per process because of internationalization restrictions, at the beginning of your program. You should call VixDiskLib_Exit() at the end of your program for cleanup. For multithreaded programs you should write your own logFunc because the default function is not thread safe.
In most cases you should replace VixDiskLib_Init() with VixDiskLib_InitEx(), which allows you to specify a configuration file. For information about InitEx, see Initialize Virtual Disk API.
Connect to a Workstation or Server
VixDiskLib_Connect() connects the library to either a local VMware host or a remote server. For hosted disk on the local system, provide null values for most connection parameters. For managed disk on an ESX/ESXi host, specify virtual machine name, ESX/ESXi host name, user name, password, and possibly port.
vixError = VixDiskLib_Connect(&cnxParams, &srcConnection)
You can opt to use the VixDiskLibSSPICreds connection parameter to enable Security Support Provider Interface (SSPI) authentication. SSPI provides the advantage of not storing passwords in configuration files in plain text or in the registry. In order to be able to use SSPI, the following conditions must be met:
If your setup meets all these conditions, you can enable SSPI authentication by setting USERNAME to __sspi__. For SSPI, the password must be set, but it is ignored. It can be set to "" (null).
Always call VixDiskLib_Disconnect() before the end of your program.
VMX Specification
On VMware platform products, .vmx is a text file (usually located in the same directory as virtual disk files) specifying virtual machine configuration. The Virtual Machine eXecutable (VMX) process is the user-space component (or “world”) of a virtual machine. The virtual disk library connects to virtual machine storage through the VMX process.
When specifying connection parameters (see Data Structures in Virtual Disk API) the preferred syntax for vmxSpec is as follows:
moRef=<moref-of-vm>
The moRef of a virtual machine or disk snapshot on an ESX/ESXi host is likely different than the moRef of the same virtual machine or disk snapshot as managed by vCenter Server. Here are two example moRef specifications, one for ESXi and one for vCenter Server, both referring to the same snapshot:
moref=153
moref=271