You first create a snapshot, and then create the linked virtual machine from the snapshot.

Procedure

  1. To create the snapshot, call the CreateSnapshot_Task method for the virtual machine. The virtual machine can be in any power state. The following pseudo code creates a snapshot named snap1. The code does not include a memory dump. VMware Tools is used to quiesce the file system in the virtual machine if the virtual machine is powered on.
    myVm.CreateSnapshot("snap1", "snapshot for creating linked virtual machines", False, True)
  2. To create the linked virtual machine, specify the snapshot you created and use a VirtualMachineRelocateDiskMoveOptions.diskMoveType of createNewDeltaDiskBacking, as illustrated in Creating a Linked Virtual Machine from a Snapshot. Creating linked virtual machines from a snapshot works with virtual machines in any power state.

Example: Creating a Linked Virtual Machine from a Snapshot

relSpec = new VirtualMachineRelocateSpec()
relSpec.diskMoveType = VirtualMachineRelocateDiskMoveOptions.createNewChildDiskBacking

cloneSpec = new VirtualMachineCloneSpec()
cloneSpec.powerOn = False
cloneSpec.template = False
cloneSpec.location = relSpec
cloneSpec.snapshot = myVm.snapshot.currentSnapshot

myVm.Clone(myVm.parent, myVm.name + "-clone", cloneSpec)

The result is a virtual machine with the same base disk as the original, but a new delta disk backing.

Figure 1. Creating a Linked Virtual Machine from a Snapshot
Shows snapshot of a running virtual machine with empty delta disk.