Name

RevertToSnapshot

Description

HRESULT
RevertToSnapshot([in] ISnapshot* snapshot,
                 [in] LONG options,
                 [in] IVixHandle* propertyList,
                 [in] ICallback* jobDoneCallback,
                 [out,retval] IJob** revertJob);

Restores the virtual machine to the state when the specified snapshot was created.

Parameters

snapshot
An ISnapshot object representing the snapshot to remove. A virtual machine's snapshots can be accessed through VM::GetRootSnapshot()
options
Any applicable VixVMPowerOpOptions. If the virtual machine was powered on when the snapshot was created, then this will determine how the virtual machine is powered back on. To prevent the virtual machine from being powered on regardless of the power state when the snapshot was created, use the VIX_VMPOWEROP_SUPPRESS_SNAPSHOT_POWERON flag. VIX_VMPOWEROP_SUPPRESS_SNAPSHOT_POWERON is mutually exclusive to all other VixVMPowerOpOptions.
propertyListHandle
Must be NULL (C++), null (C#), or Nothing (VB).
jobDoneCallback
An ICallback instance that will be called when the operation is complete.
revertJob
Returns an IJob object that describes the state of this asynchronous operation.

Return Value

HRESULT

Remarks

Side Effects

None.

Requirements

VixCOM.h, since VMware Workstation 6.0

Example

This example reverts to the root snapshot belonging to a virtual machine.
Dim lib
Dim host
Dim vm
Dim job
Dim err
Dim results
Dim snapshot

results = Nothing

Set lib = CreateObject("VixCOM.VixLib")

Set job = lib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION, Empty, 0, Empty, Empty, 0, Nothing, Nothing)
err = job.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT), result)
If lib.ErrorIndicatesFailure(err) Then
   ' Handle error...
End If

Set host = results(0)

Set job = host.OpenVM("c:\Virtual Machines\vm1\win2000.vmx", Nothing)
err = job.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT), result)
If lib.ErrorIndicatesFailure(err) Then
   ' Handle error...
End If

Set vm = results(0)

err = vm.GetRootSnapshot(0, snapshot)
If lib.ErrorIndicatesFailure(err) Then
   ' Handle error...
End If
   
Set job = vm.RevertToSnapshot(snapshot, 0, Nothing, Nothing)
err = job.WaitWithoutResults()

Set snapshot = Nothing
Set results = Nothing
Set job = Nothing
Set vm = Nothing

host.Disconnect()

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