| 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 22 matching lines...) Expand all Loading... |
| 33 # Let's be safe in case they specified a file that isn't a pid file. | 33 # Let's be safe in case they specified a file that isn't a pid file. |
| 34 echo "File ${KVM_PID_FILE} exists but specified pid doesn't." >&2 | 34 echo "File ${KVM_PID_FILE} exists but specified pid doesn't." >&2 |
| 35 exit 1 | 35 exit 1 |
| 36 fi | 36 fi |
| 37 else | 37 else |
| 38 # No pid specified by PID file. Let's create a VM instance in this case. | 38 # No pid specified by PID file. Let's create a VM instance in this case. |
| 39 echo "Starting a KVM instance" >&2 | 39 echo "Starting a KVM instance" >&2 |
| 40 local nographics="" | 40 local nographics="" |
| 41 local usesnapshot="" | 41 local usesnapshot="" |
| 42 if [ ${FLAGS_no_graphics} -eq ${FLAGS_TRUE} ]; then | 42 if [ ${FLAGS_no_graphics} -eq ${FLAGS_TRUE} ]; then |
| 43 nographics="-nographic" | 43 nographics="-nographic -serial none" |
| 44 fi | 44 fi |
| 45 | 45 |
| 46 if [ ${FLAGS_snapshot} -eq ${FLAGS_TRUE} ]; then | 46 if [ ${FLAGS_snapshot} -eq ${FLAGS_TRUE} ]; then |
| 47 snapshot="-snapshot" | 47 snapshot="-snapshot" |
| 48 fi | 48 fi |
| 49 | 49 |
| 50 sudo kvm -m 1024 \ | 50 sudo kvm -m 1024 \ |
| 51 -vga std \ | 51 -vga std \ |
| 52 -pidfile "${KVM_PID_FILE}" \ | 52 -pidfile "${KVM_PID_FILE}" \ |
| 53 -daemonize \ | 53 -daemonize \ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 if [ -n "${pid}" ]; then | 95 if [ -n "${pid}" ]; then |
| 96 echo "Killing ${pid}" >&2 | 96 echo "Killing ${pid}" >&2 |
| 97 sudo kill ${pid} | 97 sudo kill ${pid} |
| 98 sudo rm "${KVM_PID_FILE}" | 98 sudo rm "${KVM_PID_FILE}" |
| 99 else | 99 else |
| 100 echo "No kvm pid found to stop." >&2 | 100 echo "No kvm pid found to stop." >&2 |
| 101 return 1 | 101 return 1 |
| 102 fi | 102 fi |
| 103 fi | 103 fi |
| 104 } | 104 } |
| OLD | NEW |