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

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: Fix code review feedbacks 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 | « no previous file | client/common_lib/test.py » ('j') | client/common_lib/test.py » ('J')
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..37db37683ab30db3508c49bed35be6f9dd404864 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 os, logging, platform, time
petkov 2010/11/24 20:36:53 sort
thieule 2010/11/30 23:05:08 Done.
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
petkov 2010/11/24 20:36:53 period
thieule 2010/11/30 23:05:08 Done.
+
+ 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/11/24 20:36:53 'QEMU' in proc?
thieule 2010/11/30 23:05:08 I was a bit surprised myself as well to find pytho
+ 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 | « no previous file | client/common_lib/test.py » ('j') | client/common_lib/test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698