Example #1
0
        /// <summary>
        /// Starts a snapshot of a virtual machine
        /// </summary>
        /// <param name=”snapshot_name”>The name of the snapshot to start</param>
        /// <returns>true if succeeded, otherwise false</returns>
        public bool RevertToLastSnapshot()
        {
            ISnapshot snapshot = null;

            m_vixError = m_vmHandle.GetRootSnapshot(0, out snapshot);

            if (m_vixError == VixCOM.Constants.VIX_OK)
            {
                IJob jobHandle = m_vmHandle.RevertToSnapshot(snapshot, 0, null, null);

                m_vixError = jobHandle.WaitWithoutResults();
            }

            return(m_vixError == VixCOM.Constants.VIX_OK);
        }
Example #2
0
        public void RevertToSnapshot(string snapshotName)
        {
            VixCOM.ISnapshot snapshot;
            _virtualMachine.GetNamedSnapshot(snapshotName, out snapshot);

            VixCOM.IJob job = _virtualMachine.RevertToSnapshot(snapshot, 0, null, null);
            UInt64      err = job.WaitWithoutResults();

            if (lib.ErrorIndicatesFailure(err))
            {
                short  errCode = lib.ErrorCode(err);
                string errMsg;
                errMsg = lib.GetErrorText(err, null);

                throw new Exception("RevertToSnapshot: " + errMsg);
            }

            WaitForToolsInGuest();
        }