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

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>Programming</strong> <strong>Guide</strong><br />

<strong>Programming</strong> with VixMntapi<br />

At the top of your program, include vixMntapi.h along with any other header files you need. Structures and<br />

type definitions are declared in the include file, so you do not need to create them or allocate memory for them.<br />

Call VixMntapi_Init() to initialize the library in your application. This function takes major and minor<br />

version number to account for future extensions. You can provide your own logging, warning, or panic<br />

functions to substitute for the default VixMntapi handlers, and custom library and temporary directories.<br />

Call VixMntapi_Open<strong>Disk</strong>Set() to open a set of virtual disks for mounting. Pass a set of disk handles<br />

obtained from the Vix<strong>Disk</strong>Lib_Open() call. The VixMntapi_Open<strong>Disk</strong>Set() function also expects number<br />

of disks to open, an optional open mode, and a parameter to pass back the resulting disk‐set handle.<br />

File System Support<br />

Windows file systems (FAT, FAT32, and NTFS) are supported. The vixMntapi library depends on the operating<br />

system for file system attributes such as compression, encryption, hidden, ACL, and alternate streams. If a<br />

vixMntapi‐linked application runs on a virtual machine that supports these attributes, it supports them. The<br />

following volume types are supported: Simple, Spanned, Striped (RAID 0), and Mirrored (RAID 1). RAID 5<br />

(parity striped) is not supported.<br />

You must open a disk set read/write to obtain the OS information for dynamic volume types including LDM<br />

and LVM. If you cannot open a base disk read/write, create a child disk in front, and open it read/write. In a<br />

multi‐boot setup, only the first entry #0 is opened.<br />

The order of mounting is important. For instance, mount top‐level directories before subdirectories, and drives<br />

with dependencies after drives that they depend on. Mount points are not enumerated, nor are they restored.<br />

When you mount one volume, the other volumes are not implicitly mounted also.<br />

Read-Only Mount on Linux<br />

The VixMntapi library can emulate mounting disks read‐only, as in the Linux procedure below. A similar<br />

procedure, with different temporary filename, could be used on Windows.<br />

To mount disks read-only<br />

1 Open the base disk with Vix<strong>Disk</strong>Lib_Open(), passing the flag VIXDISKLIB_FLAG_OPEN_READ_ONLY.<br />

2 Call Vix<strong>Disk</strong>Lib_CreateChild() to create a child of the base disk. <strong>VMware</strong> recommends creating a file<br />

such as /tmp/ using mkstemp() to formulate a unique name for the redo log.<br />

3 Call Vix<strong>Disk</strong>Lib_Close() to close the base disk, which is no longer needed.<br />

4 Now use VixMntapi_Open<strong>Disk</strong>s() as you normally would with diskSet[0] = /tmp/<br />

and openFlags = 0 (meaning read/write).<br />

This allows writing to the redo log (for journal reply and so forth) without affecting the base disk.<br />

Software developers should inform customers that the mounted disk set seems writable, although the effect<br />

of changing files and altering directories is only temporary. The base disk is read‐only.<br />

To unmount read-only disks<br />

1 Call VixMntapi_Close<strong>Disk</strong>Set() to close the disk set.<br />

2 Call Vix<strong>Disk</strong>Lib_Unlink() to remove the redo log, /tmp/.<br />

<strong>VMware</strong> Product Platforms<br />

Applications written using this release of VixMntapi can manipulate virtual disks created with ESX and ESXi,<br />

<strong>VMware</strong> Server, <strong>VMware</strong> Fusion, <strong>VMware</strong> Player, <strong>VMware</strong> Workstation, and GSX Server.<br />

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

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

Saved successfully!

Ooh no, something went wrong!