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 />

Rename an Existing <strong>Disk</strong><br />

Vix<strong>Disk</strong>Lib_Rename() changes the name of a virtual disk. Use this function only when the virtual machine<br />

is powered off.<br />

vixError = Vix<strong>Disk</strong>Lib_Rename(oldGlobals.diskPath, newGlobals.diskPath);<br />

Grow an Existing Local <strong>Disk</strong><br />

Vix<strong>Disk</strong>Lib_Grow() extends an existing virtual disk by adding sectors. This function supports hosted disk,<br />

but not managed disk.<br />

vixError =<br />

Vix<strong>Disk</strong>Lib_Grow(appGlobals.connection, appGlobals.diskPath, size, FALSE, GrowProgressFunc, NULL);<br />

Defragment an Existing <strong>Disk</strong><br />

Vix<strong>Disk</strong>Lib_Defragment() defragments an existing virtual disk. Defragmentation is effective with SPARSE<br />

type files, but might not do anything with FLAT type. In either case, the function returns VIX_OK. This function<br />

supports hosted disk, but not managed disk.<br />

vixError = Vix<strong>Disk</strong>Lib_Defragment(disk.Handle(), DefragProgressFunc, NULL);<br />

Defragment consolidates data in the 2GB extents, moving data to lower‐numbered extents, and is independent<br />

of defragmentation tools in the guest OS, such as <strong>Disk</strong> > Properties > Tools > Defragmentation in Windows,<br />

or the defrag command for the Linux Ext2 file system.<br />

<strong>VMware</strong> recommends defragmentation from the inside out: first within the virtual machine, then using this<br />

function or a <strong>VMware</strong> defragmentation tool, and finally within the host operating system.<br />

Shrink an Existing Local <strong>Disk</strong><br />

Vix<strong>Disk</strong>Lib_Shrink() reclaims unused space in an existing virtual disk, unused space being recognized as<br />

blocks of zeroes. This is more effective (gains more space) with SPARSE type files than with pre‐allocated FLAT<br />

type, although FLAT files might shrink by a small amount. In either case, the function returns VIX_OK. This<br />

function supports hosted disk, but not managed disk.<br />

vixError = Vix<strong>Disk</strong>Lib_Shrink(disk.Handle(), ShrinkProgressFunc, NULL);<br />

In <strong>VMware</strong> system utilities, “prepare” zeros out unused blocks in the VMDK so “shrink” can reclaim them. In<br />

the <strong>API</strong>, use Vix<strong>Disk</strong>Lib_Write() to zero out unused blocks, and Vix<strong>Disk</strong>Lib_Shrink() to reclaim space.<br />

Shrink does not change the virtual disk capacity, but it makes more space available.<br />

Unlink Extents to Remove <strong>Disk</strong><br />

Vix<strong>Disk</strong>Lib_Unlink() deletes all extents of the specified virtual disk, which unlinks (removes) the disk data.<br />

This is similar to the remove or erase command in a command tool.<br />

vixError = Vix<strong>Disk</strong>Lib_Unlink(appGlobals.connection, appGlobals.diskPath);<br />

Combine Links for a <strong>Disk</strong><br />

Vix<strong>Disk</strong>Lib_Combine()combines links for the disk specified by diskHandle. The combining process begins<br />

with the last link in the chain specified by the linkOffsetFromBottom and continues for the number of links<br />

specified by numLinksToCombine. If the function succeeds, the function returns VIX_OK. Otherwise, the<br />

appropriate VIX error code is returned. This function supports hosted disk, but not managed disk.<br />

vixError = Vix<strong>Disk</strong>Lib_Combine(Vix<strong>Disk</strong>LibHandle diskHandle, uint32 linkOffsetFromBottom, uint32<br />

numLinksToCombine, Vix<strong>Disk</strong>LibProgressFunc progressFunc, void *progressCallbackData);<br />

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

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

Saved successfully!

Ooh no, something went wrong!