OLD | NEW |
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 sudo kvm -m 1024 \ | 79 sudo kvm -m 1024 \ |
80 -vga std \ | 80 -vga std \ |
81 -pidfile "${KVM_PID_FILE}" \ | 81 -pidfile "${KVM_PID_FILE}" \ |
82 -daemonize \ | 82 -daemonize \ |
83 ${net_option} \ | 83 ${net_option} \ |
84 ${nographics} \ | 84 ${nographics} \ |
85 ${snapshot} \ | 85 ${snapshot} \ |
86 -net user,hostfwd=tcp::${FLAGS_ssh_port}-:22 \ | 86 -net user,hostfwd=tcp::${FLAGS_ssh_port}-:22 \ |
87 -hda "${1}" | 87 -hda "${1}" |
88 | 88 |
| 89 info "KVM started with pid stored in ${KVM_PID_FILE}" |
89 LIVE_VM_IMAGE="${1}" | 90 LIVE_VM_IMAGE="${1}" |
90 fi | 91 fi |
91 } | 92 } |
92 | 93 |
93 # Checks to see if we can access the target virtual machine with ssh. | 94 # Checks to see if we can access the target virtual machine with ssh. |
94 function ssh_ping() { | 95 function ssh_ping() { |
95 "$(dirname $0)"/../ssh_test.sh \ | 96 "$(dirname $0)"/../ssh_test.sh \ |
96 --ssh_port=${FLAGS_ssh_port} \ | 97 --ssh_port=${FLAGS_ssh_port} \ |
97 --remote=127.0.0.1 >&2 | 98 --remote=127.0.0.1 >&2 |
98 } | 99 } |
(...skipping 25 matching lines...) Expand all Loading... |
124 if [ -n "${pid}" ]; then | 125 if [ -n "${pid}" ]; then |
125 echo "Killing ${pid}" >&2 | 126 echo "Killing ${pid}" >&2 |
126 blocking_kill ${pid} 1 16 || blocking_kill 9 1 | 127 blocking_kill ${pid} 1 16 || blocking_kill 9 1 |
127 sudo rm "${KVM_PID_FILE}" | 128 sudo rm "${KVM_PID_FILE}" |
128 else | 129 else |
129 echo "No kvm pid found to stop." >&2 | 130 echo "No kvm pid found to stop." >&2 |
130 return 1 | 131 return 1 |
131 fi | 132 fi |
132 fi | 133 fi |
133 } | 134 } |
OLD | NEW |