Name
VMPowerOn
Description
$err = VMPowerOn($vmHandle,
$powerOnOptions,
$propertyListHandle);
Powers on a virtual machine.
Parameters
- vmHandle
-
Identifies a virtual machine. Call VMOpen() to create a
virtual machine handle.
- powerOnOptions
-
VIX_VMPOWEROP_NORMAL or VIX_VMPOWEROP_LAUNCH_GUI.
- propertyListHandle
-
Must be VIX_INVALID_HANDLE.
Return Value
$err. The error code returned by the operation. For returned values, see Topics > Error Codes.
Remarks
- This function powers on a virtual machine.
- This operation completes when the virtual machine has started to boot.
If the VMware Tools have been installed on this guest operating system,
you can call VMWaitForToolsInGuest() to determine when the guest has finished booting.
- In Server 1.0, when you power on a virtual machine, the virtual machine is powered on
independent of a console window. If a console window is open, it remains open.
Otherwise, the virtual machine is powered on without a console window.
- To display a virtual machine with a Workstation user interface,
powerOnOptions must have the VIX_VMPOWEROP_LAUNCH_GUI flag. If there is an
existing instance of the Workstation user interface, the virtual machine will
power on in a new tab within that instance. Otherwise, a new instance of
Workstation will open, and the virtual machine will power on there.
- This function can also be used to resume execution of a suspended virtual
machine.
Side Effects
None.
Requirements
use VMware::Vix::Simple;
use VMware::Vix::API::Constants;
since VMware Server 1.0
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\\vm1\\win2000.vmx");
die "VMOpen() failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;
$err = VMPowerOn($vmHandle,
VIX_VMPOWEROP_LAUNCH_GUI, # powerOnOptions
VIX_INVALID_HANDLE); # propertyListHandle
die "VMPowerOn() failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;