With SAN transport mode, you must create a snapshot of the virtual machine before virtual disk restore.
See Creating a Snapshot. If at restore time the virtual machine had a pre-existing snapshot, you must
delete it, otherwise SAN mode restore will fail. For other transport modes, the restore snapshot is
optional.
With a VVol datastore, the restore snapshot is forbidden when restoring to the parent (backing disk). A
null MoRef is allowed as of vSphere 6.0 to minimize code changes when applications restore to a VVol
datastore. To get the unique ID of a VVol object in the MOB (managed object browser) click
VirtualMachine > Config > Hardware > Device (VirtualDisk) > Backing.
Table 7‑4 summarizes the snapshot requirements.
Table 7‑4. Summary of restore snapshot requirements
NBDSSL HotAdd SAN
Non-VVol datastore A snapshot is optional. If a snapshot is used,
writing to either the leaf disk or the parent disk is
supported. If writing to the parent disk, the
snapshot must be reverted and then deleted.
A snapshot is required. Writing to the leaf disk is
not supported, and writes must only go to the
base disk. The snapshot must be reverted and
then deleted.
VVol datastore A snapshot is optional. If a snapshot is used,
writing must be to the leaf disk only.
Not applicable, because SAN transport is not
supported on VVol datastores.
In this phase you use VixDiskLib to reload contents of the Virtual Disk, so the following code is C++ not
Java:
// At this point we assume that you already have a VixDiskLib connection to the server machine.
uint8 mybuffer[some_multiple_of_512];
int mylocalfile = open("localfile", openflags); // Contains backup copy of virtual disk.
read(mylocalfile, mybuffer, sizeof mybuffer);
vixError = VixDiskLib_Open(srcConnection, path, flags, &diskHandle);
VixDiskLib_Write(diskHandle, startsector, (sizeof mybuffer) / 512, mybuffer);
With SAN transport mode, you must revert-to and delete the snapshot. If you forget the snapshot revert,
snapshot delete will fail due to CID mismatch, so the virtual machine cannot be powered on. If you forget
the snapshot delete, the extraneous snapshot will cause restore problems for subsequent backups.
Creating a Virtual Machine
This section shows how to create a VirtualMachine object, which is complicated but necessary so you can
restore data into it. Before creating this object, you must create a VirtualMachineConfigSpec
describing the virtual machine and all of its supporting virtual devices. Almost all the required information
is available from the virtual machine property config.hardware.device, which is a table containing the
device configuration information. The relationships between devices are described by the value key,
which is a unique identifier for the device. In turn, each device has a controllerKey, which is the key
identifier of the controller where the device is connected. Use negative integers as temporary key values
Virtual Disk Development Kit Programming Guide
VMware, Inc. 105