Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Unified Diff: client/bin/site_utils.py

Issue 5303005: Add support for saving VM state after test failure (Closed) Base URL: http://git.chromium.org/git/autotest.git@master
Patch Set: Move save VM state code to be site specific Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/bin/site_job.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/bin/site_utils.py
diff --git a/client/bin/site_utils.py b/client/bin/site_utils.py
index d03ad8e6b10cb35470bb708265827a6cfe46e7e1..8b2678bf581cec3f29b71dfd9af5551e6e5c1de3 100644
--- a/client/bin/site_utils.py
+++ b/client/bin/site_utils.py
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import time
+import logging, os, platform, time
from autotest_lib.client.common_lib import error
@@ -38,3 +38,26 @@ def poll_for_condition(
raise TimeoutError, desc
time.sleep(sleep_interval)
+
+
+def save_vm_state(checkpoint):
+ """Saves the current state of the virtual machine.
+
+ This function is a NOOP if the test is not running under a virtual machine
+ with the USB serial port redirected.
+
+ Arguments:
+ checkpoint - Name used to identify this state
+
+ Returns:
+ None
+ """
+ # The QEMU monitor has been redirected to the guest serial port located at
+ # /dev/ttyUSB0. To save the state of the VM, we just send the 'savevm'
+ # command to the serial port.
+ proc = platform.processor()
+ if proc.find('QEMU') >= 0 and os.path.exists('/dev/ttyUSB0'):
petkov 2010/12/01 00:12:43 I think if 'QEMU' in proc and... is the preferre
+ logging.info('Saving VM state "%s"' % checkpoint)
+ serial = open('/dev/ttyUSB0', 'w')
+ serial.write("savevm %s\r\n" % checkpoint)
+ logging.info('Done saving VM state "%s"' % checkpoint)
« no previous file with comments | « client/bin/site_job.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698