Cloning a Virtual Disk
Compute Space Needed for Clone
This function computes the space required (in bytes) to clone a virtual disk, after possible format conversion.
vixError = VixDiskLib_SpaceNeededForClone(child.Handle(), VIXDISKLIB_DISK_VMFS_FLAT, &spaceReq);
VixDiskLib_SpaceNeededForClone() might not give accurate results, or could return VIX_E_INVALID_ARG, when used with thin provisioned disk type VIXDISKLIB_DISK_VMFS_THIN.
Clone a Disk by Copying Data
This function copies data from one virtual disk to another, converting (disk type, size, hardware) as specified.
vixError = VixDiskLib_Clone(appGlobals.connection, appGlobals.diskPath, srcConnection, appGlobals.srcPath, &createParams, CloneProgressFunc, NULL, TRUE);
vSphere security
Due to a vSphere 6.5 security enhancement, VixDiskLib_Clone can no longer clone local disks to remote disks that do not belong to any VM. Previous releases allowed use of a retained username and password, but now enhanced security verification is required. The procedure for VixDiskLib_Clone to make a remote connection is first to get an NFC ticket from the ESXi host based on the MoRef of the VM that manages the cloned-to disks. Then build an authenticated NFC connection to the host using that ticket. The MoRef of the VM must be specified in vmxSpec of the remote connection parameter passed to VixDiskLib_Clone. The VM must be powered off, and the target disks must already exist before cloning, not necessarily with the same names. Afterwards the VM may be removed from the inventory with UnregisterVM, but it must remain on the datastore with its cloned virtual disks.