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

Unified Diff: lib/cros_vm_lib.sh

Issue 5174009: Add support for saving VM state when a test fails. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Fix nit 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 | « lib/cros_vm_constants.sh ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/cros_vm_lib.sh
diff --git a/lib/cros_vm_lib.sh b/lib/cros_vm_lib.sh
index 7a99cbebe25774791d68a0892780977a8a402f22..0ed87891bb10395d4bbdbd83e998f3f510baccfd 100644
--- a/lib/cros_vm_lib.sh
+++ b/lib/cros_vm_lib.sh
@@ -14,6 +14,7 @@ DEFINE_string vnc "" "VNC Server to display to instead of SDL."
KVM_PID_FILE=/tmp/kvm.$$.pid
LIVE_VM_IMAGE=
+KVM_MONITOR_SOCKET=
function get_pid() {
sudo cat "${KVM_PID_FILE}"
@@ -40,6 +41,7 @@ function start_kvm() {
echo "Starting a KVM instance" >&2
local nographics=""
local usesnapshot=""
+ local save_vm_state=""
if [ ${FLAGS_no_graphics} -eq ${FLAGS_TRUE} ]; then
nographics="-nographic -serial none"
fi
@@ -51,6 +53,14 @@ function start_kvm() {
snapshot="-snapshot"
fi
+ if [ ${FLAGS_save_vm_state} -eq ${FLAGS_TRUE} ]; then
+ # Redirect the QEMU monitor to the guest usb serial port so tests
+ # can trigger a "savevm" command from inside the guest.
+ KVM_MONITOR_SOCKET=/tmp/kvm.mon.socket.$$
+ save_vm_state="-monitor unix:${KVM_MONITOR_SOCKET},server,nowait
+ -usbdevice serial::unix:${KVM_MONITOR_SOCKET}"
+ fi
+
sudo kvm -m 1024 \
-vga std \
-pidfile "${KVM_PID_FILE}" \
@@ -58,6 +68,7 @@ function start_kvm() {
-net nic,model=e1000 \
${nographics} \
${snapshot} \
+ ${save_vm_state} \
-net user,hostfwd=tcp::${FLAGS_ssh_port}-:22 \
-hda "${1}"
@@ -100,6 +111,9 @@ function stop_kvm() {
echo "Killing ${pid}" >&2
sudo kill ${pid}
sudo rm "${KVM_PID_FILE}"
+ if [ -n "${KVM_MONITOR_SOCKET}" ]; then
+ sudo rm "${KVM_MONITOR_SOCKET}"
+ fi
else
echo "No kvm pid found to stop." >&2
return 1
« no previous file with comments | « lib/cros_vm_constants.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698