18.08.2013 Views

Virtual Disk API Programming Guide - Documentation - VMware

Virtual Disk API Programming Guide - Documentation - VMware

Virtual Disk API Programming Guide - Documentation - VMware

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Initialize the Library<br />

<strong>Virtual</strong> <strong>Disk</strong> <strong>API</strong> Functions<br />

Vix<strong>Disk</strong>Lib_Init() initializes the old virtual disk library. The arguments majorVersion and minorVersion<br />

represent the VDDK library’s release number and dot‐release number. The third, fourth, and fifth arguments<br />

specify log, warning, and panic handlers. DLLs and shared objects are located in libDir.<br />

VixError vixError = Vix<strong>Disk</strong>Lib_Init(majorVer, minorVer, &logFunc, &warnFunc, &panicFunc, libDir);<br />

You should call Vix<strong>Disk</strong>Lib_Init() only once per process because of internationalization restrictions, at the<br />

beginning of your program. You should call Vix<strong>Disk</strong>Lib_Exit() at the end of your program for cleanup. For<br />

multithreaded programs you should write your own logFunc because the default function is not thread safe.<br />

In most cases you should replace Vix<strong>Disk</strong>Lib_Init() with Vix<strong>Disk</strong>Lib_InitEx(), which allows you to<br />

specify a configuration file. For information about InitEx, see “Initialize <strong>Virtual</strong> <strong>Disk</strong> <strong>API</strong>” on page 35.<br />

Connect to a Workstation or Server<br />

Vix<strong>Disk</strong>Lib_Connect() connects the library to either a local <strong>VMware</strong> host or a remote server. For hosted disk<br />

on the local system, provide null values for most connection parameters. For managed disk on an ESX/ESXi<br />

host, specify virtual machine name, ESX/ESXi host name, user name, password, and possibly port.<br />

vixError = Vix<strong>Disk</strong>Lib_Connect(&cnxParams, &srcConnection)<br />

You can opt to use the Vix<strong>Disk</strong>LibSSPICreds connection parameter to enable Security Support Provider<br />

Interface (SSPI) authentication. SSPI provides the advantage of not storing passwords in configuration files in<br />

plain text or in the registry. In order to be able to use SSPI, the following conditions must be met:<br />

Connections must be made directly to a vSphere Server or a <strong>Virtual</strong>Center Server version 2.5 or later.<br />

Applications and their connections must employ one of two user account arrangements. The connection<br />

must be established either:<br />

Using the same user context with the same user name and password credentials on both the proxy<br />

and the vSphere Server or<br />

Using a domain user. Attempts by applications to establish connections using the Local System<br />

account context will fail.<br />

User contexts must have administrator privileges on the proxy and have the VCB Backup User role<br />

assigned in vSphere or <strong>Virtual</strong>Center.<br />

If your setup meets all these conditions, you can enable SSPI authentication by setting USERNAME to __sspi__.<br />

For SSPI, the password must be set, but it is ignored. It can be set to "" (null).<br />

Always call Vix<strong>Disk</strong>Lib_Disconnect() before the end of your program.<br />

VMX Specification<br />

On <strong>VMware</strong> platform products, .vmx is a text file (usually located in the same directory as virtual disk files)<br />

specifying virtual machine configuration. The <strong>Virtual</strong> Machine eXecutable (VMX) process is the user‐space<br />

component (or “world”) of a virtual machine. The virtual disk library connects to virtual machine storage<br />

through the VMX process.<br />

When specifying connection parameters (see “Data Structures in <strong>Virtual</strong> <strong>Disk</strong> <strong>API</strong>” on page 21) the preferred<br />

syntax for vmxSpec is as follows:<br />

Managed object reference of the virtual machine, an opaque object that you obtain programmatically<br />

using the PropertyCollector managed object:<br />

moRef=<br />

The moRef of a virtual machine or disk snapshot on an ESX/ESXi host is likely different than the moRef of<br />

the same virtual machine or disk snapshot as managed by vCenter Server. Here are two example moRef<br />

specifications, one for ESXi and one for vCenter Server, both referring to the same snapshot:<br />

moref=153<br />

moref=271<br />

<strong>VMware</strong>, Inc. 29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!