VirtualBox

Ignore:
Timestamp:
Mar 19, 2018 7:31:49 PM (7 years ago)
Author:
vboxsync
Message:

ValidationKit: bugref:8345 add a helper for saving VM state

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testdriver/vboxwrappers.py

    r71365 r71378  
    25062506        return self.waitForTask(30 * 1000);                            # fudge
    25072507
     2508    def saveState(self, fPause = True):
     2509        """
     2510        Saves state of the VM.
     2511
     2512        Returns True on success.
     2513        Returns False on IConsole::saveState() failure.
     2514        Returns None if the progress object returns Failure.
     2515        """
     2516
     2517        if     fPause is True \
     2518           and self.oVM.state is vboxcon.MachineState_Running:
     2519            self.o.console.pause();
     2520        if self.oVM.state is not vboxcon.MachineState_Paused:
     2521            vbox.reportError(oProgress, 'pause for "%s" failed' % (self.sName));
     2522        # Try saving state.
     2523        try:
     2524            if self.fpApiVer >= 5.0:
     2525                oProgress = self.o.machine.saveState()
     2526            else:
     2527                oProgress = self.o.console.saveState();
     2528        except:
     2529            reporter.logXcpt('IMachine::saveState failed on %s' % (self.sName));
     2530            return False;
     2531
     2532        # Wait for saving state operation to complete.
     2533        rc = self.oTstDrv.waitOnProgress(oProgress);
     2534        if rc < 0:
     2535            self.close();
     2536            return None;
     2537
     2538        # Wait for the VM to really terminate or we'll fail to open a new session to it.
     2539        self.oTstDrv.waitOnDirectSessionClose(self.oVM, 5000);         # fudge
     2540        return self.waitForTask(30 * 1000);                            # fudge
     2541
    25082542    def restoreSnapshot(self, oSnapshot, fFudgeOnFailure = True):
    25092543        """
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette