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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 nographics="-nographic -serial none" | 63 nographics="-nographic -serial none" |
64 fi | 64 fi |
65 if [ -n "${FLAGS_vnc}" ]; then | 65 if [ -n "${FLAGS_vnc}" ]; then |
66 nographics="-vnc ${FLAGS_vnc}" | 66 nographics="-vnc ${FLAGS_vnc}" |
67 fi | 67 fi |
68 | 68 |
69 if [ ${FLAGS_snapshot} -eq ${FLAGS_TRUE} ]; then | 69 if [ ${FLAGS_snapshot} -eq ${FLAGS_TRUE} ]; then |
70 snapshot="-snapshot" | 70 snapshot="-snapshot" |
71 fi | 71 fi |
72 | 72 |
| 73 local net_option="-net nic,model=virtio" |
| 74 if [ -f "$(dirname $1)/.use_e1000" ]; then |
| 75 info "Detected older image, using e1000 instead of virtio." |
| 76 net_option="-net nic,model=e1000" |
| 77 fi |
| 78 |
73 sudo kvm -m 1024 \ | 79 sudo kvm -m 1024 \ |
74 -vga std \ | 80 -vga std \ |
75 -pidfile "${KVM_PID_FILE}" \ | 81 -pidfile "${KVM_PID_FILE}" \ |
76 -daemonize \ | 82 -daemonize \ |
77 -net nic,model=virtio \ | 83 ${net_option} \ |
78 ${nographics} \ | 84 ${nographics} \ |
79 ${snapshot} \ | 85 ${snapshot} \ |
80 -net user,hostfwd=tcp::${FLAGS_ssh_port}-:22 \ | 86 -net user,hostfwd=tcp::${FLAGS_ssh_port}-:22 \ |
81 -hda "${1}" | 87 -hda "${1}" |
82 | 88 |
83 LIVE_VM_IMAGE="${1}" | 89 LIVE_VM_IMAGE="${1}" |
84 fi | 90 fi |
85 } | 91 } |
86 | 92 |
87 # Checks to see if we can access the target virtual machine with ssh. | 93 # Checks to see if we can access the target virtual machine with ssh. |
(...skipping 30 matching lines...) Expand all Loading... |
118 if [ -n "${pid}" ]; then | 124 if [ -n "${pid}" ]; then |
119 echo "Killing ${pid}" >&2 | 125 echo "Killing ${pid}" >&2 |
120 blocking_kill ${pid} 1 16 || blocking_kill 9 1 | 126 blocking_kill ${pid} 1 16 || blocking_kill 9 1 |
121 sudo rm "${KVM_PID_FILE}" | 127 sudo rm "${KVM_PID_FILE}" |
122 else | 128 else |
123 echo "No kvm pid found to stop." >&2 | 129 echo "No kvm pid found to stop." >&2 |
124 return 1 | 130 return 1 |
125 fi | 131 fi |
126 fi | 132 fi |
127 } | 133 } |
OLD | NEW |