Name

VMClone

Description

($err, $cloneHandle) = VMClone($vmHandle,
                               $snapshotHandle,
                               $cloneType,
                               $destConfigPathName,
                               $options,
                               $propertyListHandle);

Creates a copy of the virtual machine specified by the 'vmHandle' parameter.

Parameters

vmHandle
Identifies a virtual machine, which is referred to as the clone's parent. Call VMOpen() to create a virtual machine handle.
snapshotHandle
Optional. A snapshot belonging to the virtual machine specified by the 'vmHandle' parameter. If you pass VIX_INVALID_HANDLE, the clone will be based off the current state of the virtual machine. If you pass a valid snapshot handle, the clone will be a copy of the state of the virtual machine at the time the snapshot was taken.
cloneType
Must be either VIX_CLONETYPE_FULL or VIX_CLONETYPE_LINKED.
destConfigPathName
The path name of the virtual machine configuration file that will be created for the virtual machine clone produced by this operation. This should be a full absolute path name, with directory names delineated according to host system convention: \ for Windows and / for Linux.
options
Must be 0.
propertyListHandle
Must be VIX_INVALID_HANDLE.

Return Value

$err. The error code returned by the operation. For returned values, see Topics > Error Codes.

$cloneHandle. A handle to the new cloned virtual machine.

Remarks

Side Effects

If the 'cloneType' parameter is VIX_CLONETYPE_LINKED and the 'snapshotHandle' parameter is VIX_INVALID_HANDLE, then the function will create a snapshot of the current virtual machine state and use that to created the linked clone.

Requirements

use VMware::Vix::Simple;
use VMware::Vix::API::Constants;
since VMware Workstation 6.5 (not supported on VMware Server)

Example

my $err = VIX_OK;
my $hostHandle = VIX_INVALID_HANDLE;
my $vmHandle = VIX_INVALID_HANDLE;

($err, $hostHandle) = HostConnect(VIX_API_VERSION,
                                  VIX_SERVICEPROVIDER_VMWARE_WORKSTATION,
                                  undef, # hostName
                                  0, # hostPort
                                  undef, # userName
                                  undef, # password
                                  0, # options
                                  VIX_INVALID_HANDLE); # propertyListHandle

die "HostConnect() failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;

($err, $vmHandle) = VMOpen($hostHandle, "C:\\Virtual Machines\\WinXP\\WinXP.vmx");

die "VMOpen() failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;

($err, $cloneHandle) = VMClone($vmHandle,
                               VIX_INVALID_HANDLE,
                               VIX_CLONETYPE_FULL,
                               "C:\\Virtual Machines\\WinXP2\\WinXP2.vmx",
                               0, # options
                               VIX_INVALID_HANDLE); # propertyListHandle

die "VMClone() failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;

HostDisconnect($hostHandle);

Copyright (C) 2007-2017 VMware, Inc. All rights reserved.