Download Virtual Disk API Programming Guide

Transcript
Virtual Disk API Programming Guide
APIs to Select Transport Methods
This section summarizes the new APIs for selecting transport method.
Initialize Virtual Disk API
VixDiskLib_InitEx() initializes new releases of the library, replacing VixDiskLib_Init(). Parameters are similar, except you should specify an actual libDir, and the new configFile parameter. For multithreaded programming, you should write your own logFunc, because the default logging function is not thread‐safe.
VixError vixError = VixDiskLib_InitEx(1, 1, &logFunc, &warnFunc, &panicFunc, *libDir,
*configFile);
On Windows *libDir could be C:\Program Files\VMware\VMware Virtual Disk Development Kit. On Linux *libDir is probably /usr/lib/vmware-vix-disklib.
Logged messages appear in C:\Documents and Settings\<user>\Local Settings\Temp\vmware-<user> on Windows and in /var/log on Linux, for this and many other VMware products. The currently supported entries you may specify in the configFile are:

tmpDirectory = "<TempDirectoryForLogging>"

vixDiskLib.transport.LogLevel = "<logLevel>" (the default <logLevel> is 6)

vixDiskLib.nfc.RequestTimeoutMs = "<NfcRequestTimeoutInMilliseconds>"

vixDiskLib.nfc.ReadTimeoutMs = "<NfcReadTimeoutInMilliseconds>"

vixDiskLib.nfc.WriteTimeoutMs = "<NfcWriteTimeoutInMilliseconds>"
List Available Transport Methods
The VixDiskLib_ListTransportModes() function returns the currently supported transport methods as a colon‐separated string value, currently “file:san:hotadd:nbd” where nbd indicates LAN transport. When available, SSL encrypted NBD transport is shown as nbdssl.
printf("Transport methods: %s\n", VixDiskLib_ListTransportModes());
The default transport priority over the network is san:hotadd:nbdssl:nbd assuming all are available.
Connect to VMware vSphere
VixDiskLib_ConnectEx() connects the library to managed disk on a remote ESX/ESXi host or through VMware vCenter Server. For hosted disk on the local system, it works the same as VixDiskLib_Connect(). VixDiskLib_ConnectEx() takes three additional parameters:

Boolean indicating TRUE for read‐only access, often faster, or FALSE for read/write access. If connecting read‐only, later calls to VixDiskLib_Open() are always read‐only regardless of the openFlags setting.

Managed object reference (MoRef) of the snapshot to access with this connection. This is required for SAN and HotAdd transport methods, and to access a powered‐on virtual machine. You must also specify the associated vmxSpec property in connectParams. When connecting directly to an ESX/ESXi host, provide the ESX/ESXi MoRef. When connecting through vCenter Server, pass the vSphere MoRef, which differs.

Preferred transport method, or NULL to accept defaults. If you specify SAN as the only transport, and SAN is not available, VixDiskLib_ConnectEx() does not fail, but the first VixDiskLib_Open() call will fail.
VixDiskLibConnectParams cnxParams = {0};
if (appGlobals.isRemote) {
cnxParams.vmName = vmxSpec;
cnxParams.serverName = hostName;
cnxParams.credType = VIXDISKLIB_CRED_UID;
cnxParams.creds.uid.userName = userName;
cnxParams.creds.uid.password = password;
cnxParams.port = port;
}
VixError vixError = VixDiskLib_ConnectEx(&cnxParams, TRUE, "snapshot-47", NULL, &connection);
40
VMware, Inc.