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

Side by Side Diff: lib/cros_vm_lib.sh

Issue 6240018: This starts to fix the scripts so that they load from /usr/lib/crosutils (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: fixing bad merge Created 9 years, 10 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 | « kernel_fetcher.sh ('k') | make_developer_script_runner.sh » ('j') | 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 fi 62 fi
63 if [ -n "${FLAGS_vnc}" ]; then 63 if [ -n "${FLAGS_vnc}" ]; then
64 nographics="-vnc ${FLAGS_vnc}" 64 nographics="-vnc ${FLAGS_vnc}"
65 fi 65 fi
66 66
67 if [ ${FLAGS_snapshot} -eq ${FLAGS_TRUE} ]; then 67 if [ ${FLAGS_snapshot} -eq ${FLAGS_TRUE} ]; then
68 snapshot="-snapshot" 68 snapshot="-snapshot"
69 fi 69 fi
70 70
71 local net_option="-net nic,model=virtio" 71 local net_option="-net nic,model=virtio"
72 if [ -f "$(dirname $1)/.use_e1000" ]; then 72 if [ -f "$(dirname "$1")/.use_e1000" ]; then
73 info "Detected older image, using e1000 instead of virtio." 73 info "Detected older image, using e1000 instead of virtio."
74 net_option="-net nic,model=e1000" 74 net_option="-net nic,model=e1000"
75 fi 75 fi
76 76
77 sudo kvm -m 1024 \ 77 sudo kvm -m 1024 \
78 -vga std \ 78 -vga std \
79 -pidfile "${KVM_PID_FILE}" \ 79 -pidfile "${KVM_PID_FILE}" \
80 -daemonize \ 80 -daemonize \
81 ${net_option} \ 81 ${net_option} \
82 ${nographics} \ 82 ${nographics} \
83 ${snapshot} \ 83 ${snapshot} \
84 -net user,hostfwd=tcp::${FLAGS_ssh_port}-:22 \ 84 -net user,hostfwd=tcp::${FLAGS_ssh_port}-:22 \
85 -hda "${1}" 85 -hda "${1}"
86 86
87 info "KVM started with pid stored in ${KVM_PID_FILE}" 87 info "KVM started with pid stored in ${KVM_PID_FILE}"
88 LIVE_VM_IMAGE="${1}" 88 LIVE_VM_IMAGE="${1}"
89 fi 89 fi
90 } 90 }
91 91
92 # Checks to see if we can access the target virtual machine with ssh. 92 # Checks to see if we can access the target virtual machine with ssh.
93 function ssh_ping() { 93 function ssh_ping() {
94 "$(dirname $0)"/../ssh_test.sh \ 94 "${SCRIPT_ROOT}/ssh_test.sh" \
95 --ssh_port=${FLAGS_ssh_port} \ 95 --ssh_port=${FLAGS_ssh_port} \
96 --remote=127.0.0.1 >&2 96 --remote=127.0.0.1 >&2
97 } 97 }
98 98
99 # Tries to ssh into live image $1 times. After first failure, a try involves 99 # Tries to ssh into live image $1 times. After first failure, a try involves
100 # shutting down and restarting kvm. 100 # shutting down and restarting kvm.
101 function retry_until_ssh() { 101 function retry_until_ssh() {
102 local can_ssh_into=1 102 local can_ssh_into=1
103 local retries=0 103 local retries=0
104 ssh_ping && can_ssh_into=0 104 ssh_ping && can_ssh_into=0
(...skipping 18 matching lines...) Expand all
123 if [ -n "${pid}" ]; then 123 if [ -n "${pid}" ]; then
124 echo "Killing ${pid}" >&2 124 echo "Killing ${pid}" >&2
125 blocking_kill ${pid} 1 16 || blocking_kill 9 1 125 blocking_kill ${pid} 1 16 || blocking_kill 9 1
126 sudo rm "${KVM_PID_FILE}" 126 sudo rm "${KVM_PID_FILE}"
127 else 127 else
128 echo "No kvm pid found to stop." >&2 128 echo "No kvm pid found to stop." >&2
129 return 1 129 return 1
130 fi 130 fi
131 fi 131 fi
132 } 132 }
OLDNEW
« no previous file with comments | « kernel_fetcher.sh ('k') | make_developer_script_runner.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698