Command Functions

The print-usage message appears next, with output partially shown in Usage Message.
Next comes the
main()
function, which sets defaults and parses command-line arguments to determine the operation and possibly set options to change defaults. Dynamic loading occurs, if defined. Notice the all-zero initialization of the
VixDiskLibConnectParams
declared structure:
VixDiskLibConnectParams cnxParams = {0};
For connections to an ESXi host, credentials including user name and password must be correctly supplied in the
-user
and
-password
command-line arguments. Both the
-host
name of the ESXi host and its
-vm
inventory path (
vmxSpec
) must be supplied. When set, these values populate the
cnxParams
structure. Initialize all parameters, especially
vmxSpec
, or else the connection might behave unexpectedly.
A call to
VixDiskLib_Init()
initializes the library. In a production application, you can supply appropriate
log
,
warn
, and
panic
functions as parameters, in place of NULL.
A call to
VixDiskLib_Connect()
creates a connection to disk. If host
cnxParams.serverName
is null, as it is without the
-host
argument, a connection is made to hosted disk on the local host. Otherwise a connection is made to managed disk on the remote host. With
-ssmoref
argument, advanced transport is used.
Next, an appropriate function is called for the requested operation, followed by error information if applicable. Finally, the
main()
function closes the library connection to disk and exits.