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

Side by Side Diff: lib/cros_vm_lib.sh

Issue 6877015: Add combine_stdout_stderr as well as make success less verbose. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Cleanup Created 9 years, 8 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/cros_build_lib.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 # 4 #
5 # Common vm functions for use in crosutils. 5 # Common vm functions for use in crosutils.
6 6
7 DEFINE_string kvm_pid "" \ 7 DEFINE_string kvm_pid "" \
8 "Use this pid file. If it exists and is set, use the vm specified by pid." 8 "Use this pid file. If it exists and is set, use the vm specified by pid."
9 DEFINE_boolean no_graphics ${FLAGS_FALSE} "Runs the KVM instance silently." 9 DEFINE_boolean no_graphics ${FLAGS_FALSE} "Runs the KVM instance silently."
10 DEFINE_boolean persist "${FLAGS_FALSE}" "Persist vm." 10 DEFINE_boolean persist "${FLAGS_FALSE}" "Persist vm."
(...skipping 13 matching lines...) Expand all
24 # die up to a given timeout. It exponentially backs off it's timeout starting 24 # die up to a given timeout. It exponentially backs off it's timeout starting
25 # at 1 second. 25 # at 1 second.
26 # $1 the process id. 26 # $1 the process id.
27 # $2 signal to send (-#). 27 # $2 signal to send (-#).
28 # $3 max timeout in seconds. 28 # $3 max timeout in seconds.
29 # Returns 0 on success. 29 # Returns 0 on success.
30 function blocking_kill() { 30 function blocking_kill() {
31 local timeout=1 31 local timeout=1
32 sudo kill -$2 $1 32 sudo kill -$2 $1
33 while ps -p $1 > /dev/null && [ ${timeout} -le $3 ]; do 33 while ps -p $1 > /dev/null && [ ${timeout} -le $3 ]; do
34 warn "Process still running, sleeping for ${timeout}"
35 sleep ${timeout} 34 sleep ${timeout}
36 timeout=$((timeout*2)) 35 timeout=$((timeout*2))
37 done 36 done
38 ! ps -p ${1} > /dev/null 37 ! ps -p ${1} > /dev/null
39 } 38 }
40 39
41 # $1: Path to the virtual image to start. 40 # $1: Path to the virtual image to start.
42 function start_kvm() { 41 function start_kvm() {
43 # Override default pid file. 42 # Override default pid file.
44 [ -n "${FLAGS_kvm_pid}" ] && KVM_PID_FILE=${FLAGS_kvm_pid} 43 [ -n "${FLAGS_kvm_pid}" ] && KVM_PID_FILE=${FLAGS_kvm_pid}
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 121 }
123 122
124 function stop_kvm() { 123 function stop_kvm() {
125 if [ "${FLAGS_persist}" -eq "${FLAGS_TRUE}" ]; then 124 if [ "${FLAGS_persist}" -eq "${FLAGS_TRUE}" ]; then
126 echo "Persist requested. Use --ssh_port ${FLAGS_ssh_port} " \ 125 echo "Persist requested. Use --ssh_port ${FLAGS_ssh_port} " \
127 "--kvm_pid ${KVM_PID_FILE} to re-connect to it." >&2 126 "--kvm_pid ${KVM_PID_FILE} to re-connect to it." >&2
128 else 127 else
129 echo "Stopping the KVM instance" >&2 128 echo "Stopping the KVM instance" >&2
130 local pid=$(get_pid) 129 local pid=$(get_pid)
131 if [ -n "${pid}" ]; then 130 if [ -n "${pid}" ]; then
132 echo "Killing ${pid}" >&2
133 blocking_kill ${pid} 1 16 || blocking_kill 9 1 131 blocking_kill ${pid} 1 16 || blocking_kill 9 1
134 sudo rm "${KVM_PID_FILE}" 132 sudo rm "${KVM_PID_FILE}"
135 else 133 else
136 echo "No kvm pid found to stop." >&2 134 echo "No kvm pid found to stop." >&2
137 return 1 135 return 1
138 fi 136 fi
139 fi 137 fi
140 } 138 }
OLDNEW
« no previous file with comments | « lib/cros_build_lib.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698