Changeset View
Standalone View
share/examples/bhyve/vmrun.sh
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
errmsg() { | errmsg() { | ||||
echo "*** $1" | echo "*** $1" | ||||
} | } | ||||
usage() { | usage() { | ||||
local msg=$1 | local msg=$1 | ||||
echo "Usage: vmrun.sh [-aAEhiTv] [-c <CPUs>] [-C <console>]" \ | echo "Usage: vmrun.sh [-aAEhiTvx] [-c <CPUs>] [-C <console>]" \ | ||||
"[-d <disk file>]" | "[-d <disk file>]" | ||||
echo " [-e <name=value>] [-f <path of firmware>]" \ | echo " [-e <name=value>] [-f <path of firmware>]" \ | ||||
"[-F <size>]" | "[-F <size>]" | ||||
echo " [-g <gdbport> ] [-H <directory>]" | echo " [-g <gdbport> ] [-H <directory>]" | ||||
echo " [-I <location of installation iso>] [-l <loader>]" | echo " [-I <location of installation iso>] [-l <loader>]" | ||||
echo " [-L <VNC IP for UEFI framebuffer>]" | echo " [-L <VNC IP for UEFI framebuffer>]" | ||||
echo " [-m <memsize>]" \ | echo " [-m <memsize>]" \ | ||||
"[-n <network adapter emulation type>]" | "[-n <network adapter emulation type>]" | ||||
Show All 24 Lines | usage() { | ||||
echo " -p: pass-through a host PCI device at bus/slot/func" \ | echo " -p: pass-through a host PCI device at bus/slot/func" \ | ||||
"(e.g. 10/0/0)" | "(e.g. 10/0/0)" | ||||
echo " -P: UEFI GOP VNC port (default: ${DEFAULT_VNCPORT})" | echo " -P: UEFI GOP VNC port (default: ${DEFAULT_VNCPORT})" | ||||
echo " -t: tap device for virtio-net (default: $DEFAULT_TAPDEV)" | echo " -t: tap device for virtio-net (default: $DEFAULT_TAPDEV)" | ||||
echo " -T: Enable tablet device (for UEFI GOP)" | echo " -T: Enable tablet device (for UEFI GOP)" | ||||
echo " -u: RTC keeps UTC time" | echo " -u: RTC keeps UTC time" | ||||
echo " -v: Wait for VNC client connection before booting VM" | echo " -v: Wait for VNC client connection before booting VM" | ||||
echo " -w: ignore unimplemented MSRs" | echo " -w: ignore unimplemented MSRs" | ||||
echo " -x: exit when bhyve exits, passing up the exit code" | |||||
rgrimes: Per emails with Paul Vixie we have come up with this:
-x Exit reboot loop even if bhyve exits… | |||||
jhbUnsubmitted Not Done Inline ActionsHow about just "disable auto-reboot" jhb: How about just "disable auto-reboot" | |||||
echo "" | echo "" | ||||
[ -n "$msg" ] && errmsg "$msg" | [ -n "$msg" ] && errmsg "$msg" | ||||
exit 1 | exit 1 | ||||
} | } | ||||
if [ `id -u` -ne 0 ]; then | if [ `id -u` -ne 0 ]; then | ||||
errmsg "This script must be executed with superuser privileges" | errmsg "This script must be executed with superuser privileges" | ||||
exit 1 | exit 1 | ||||
Show All 13 Lines | |||||
nic=${DEFAULT_NIC} | nic=${DEFAULT_NIC} | ||||
tap_total=0 | tap_total=0 | ||||
disk_total=0 | disk_total=0 | ||||
disk_emulation=${DEFAULT_DISK} | disk_emulation=${DEFAULT_DISK} | ||||
gdbport=0 | gdbport=0 | ||||
loader_opt="" | loader_opt="" | ||||
bhyverun_opt="-H -A -P" | bhyverun_opt="-H -A -P" | ||||
pass_total=0 | pass_total=0 | ||||
exit_passthrough=0 | |||||
rgrimesAuthorUnsubmitted Not Done Inline ActionsWe should probably call this exit_rebootloop, passthrough has a great deal of other context in bhyve. rgrimes: We should probably call this exit_rebootloop, passthrough has a great deal of other context in… | |||||
rgrimesAuthorUnsubmitted Not Done Inline Actionsplease do make this exit_rebootloop, no doubts in my mind now as to what is going on here, and that this should not be called passthrough due to confusion factor. rgrimes: please do make this exit_rebootloop, no doubts in my mind now as to what is going on here, and… | |||||
# EFI-specific options | # EFI-specific options | ||||
efi_mode=0 | efi_mode=0 | ||||
efi_firmware="/usr/local/share/uefi-firmware/BHYVE_UEFI.fd" | efi_firmware="/usr/local/share/uefi-firmware/BHYVE_UEFI.fd" | ||||
vncwait="" | vncwait="" | ||||
vnchost=${DEFAULT_VNCHOST} | vnchost=${DEFAULT_VNCHOST} | ||||
vncport=${DEFAULT_VNCPORT} | vncport=${DEFAULT_VNCPORT} | ||||
vncsize=${DEFAULT_VNCSIZE} | vncsize=${DEFAULT_VNCSIZE} | ||||
tablet="" | tablet="" | ||||
while getopts aAc:C:d:e:Ef:F:g:hH:iI:l:L:m:n:p:P:t:Tuvw c ; do | while getopts aAc:C:d:e:Ef:F:g:hH:iI:l:L:m:n:p:P:t:Tuvwx c ; do | ||||
case $c in | case $c in | ||||
a) | a) | ||||
bhyverun_opt="${bhyverun_opt} -a" | bhyverun_opt="${bhyverun_opt} -a" | ||||
;; | ;; | ||||
A) | A) | ||||
disk_emulation="ahci-hd" | disk_emulation="ahci-hd" | ||||
;; | ;; | ||||
c) | c) | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | u) | ||||
bhyverun_opt="${bhyverun_opt} -u" | bhyverun_opt="${bhyverun_opt} -u" | ||||
;; | ;; | ||||
v) | v) | ||||
vncwait=",wait" | vncwait=",wait" | ||||
;; | ;; | ||||
w) | w) | ||||
bhyverun_opt="${bhyverun_opt} -w" | bhyverun_opt="${bhyverun_opt} -w" | ||||
;; | ;; | ||||
x) | |||||
exit_passthrough=1 | |||||
;; | |||||
*) | *) | ||||
usage | usage | ||||
;; | ;; | ||||
esac | esac | ||||
done | done | ||||
if [ $tap_total -eq 0 ] ; then | if [ $tap_total -eq 0 ] ; then | ||||
tap_total=1 | tap_total=1 | ||||
▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | ${FBSDRUN} -c ${cpus} -m ${memsize} ${bhyverun_opt} \ | ||||
${efiargs} \ | ${efiargs} \ | ||||
${devargs} \ | ${devargs} \ | ||||
-l com1,${console} \ | -l com1,${console} \ | ||||
${installer_opt} \ | ${installer_opt} \ | ||||
${vmname} | ${vmname} | ||||
bhyve_exit=$? | bhyve_exit=$? | ||||
# bhyve returns the following status codes: | # bhyve returns the following status codes: | ||||
# 0 - VM has been reset | # 0 - VM has been reset | ||||
rgrimesAuthorUnsubmitted Not Done Inline ActionsMan pages sayes this is reboot, not sure what the differences are yet. I believe it is actually reset, and you have to do the reboot externally by re running the bhyve(8) command. rgrimes: Man pages sayes this is reboot, not sure what the differences are yet. I believe it is… | |||||
rgrimesAuthorUnsubmitted Not Done Inline ActionsAbove statement is correct, we should probably fix up the man page to more clearly explain the exit code 0 rgrimes: Above statement is correct, we should probably fix up the man page to more clearly explain the… | |||||
# 1 - VM has been powered off | # 1 - VM has been powered off | ||||
# 2 - VM has been halted | # 2 - VM has been halted | ||||
# 3 - VM generated a triple fault | # 3 - VM generated a triple fault | ||||
rgrimesAuthorUnsubmitted Not Done Inline ActionsThere are now exit code of 4, "exited due to an error" rgrimes: There are now exit code of 4, "exited due to an error" | |||||
jhbUnsubmitted Not Done Inline Actions4 already falls into the "all other" comment jhb: 4 already falls into the "all other" comment | |||||
# all other non-zero status codes are errors | # all other non-zero status codes are errors | ||||
# | # | ||||
if [ $bhyve_exit -ne 0 ]; then | if [ $exit_passthrough -ne 0 -o $bhyve_exit -ne 0 ]; then | ||||
rgrimesAuthorUnsubmitted Not Done Inline ActionsThe only case that this new code would trigger on would be if the bhyve exit code is 0, and -x was specified. How does that add any exit information? Furthermore that would break the reboot while [ 1 ] loop, is that what your trying to achive? rgrimes: The only case that this new code would trigger on would be if the bhyve exit code is 0, and -x… | |||||
rgrimesAuthorUnsubmitted Not Done Inline ActionsAdding a note, to above, yes this is trying to break the reboot while [1] loop, ie you want to manage reboots in a loop outside bhyve(8). rgrimes: Adding a note, to above, yes this is trying to break the reboot while [1] loop, ie you want to… | |||||
jhbUnsubmitted Not Done Inline ActionsAnd, since the script uses 'exit $bhyve_exit' it does pass through a different exit value to the caller when -x is used (the caller would never see 0 otherwise). jhb: And, since the script uses 'exit $bhyve_exit' it does pass through a different exit value to… | |||||
break | break | ||||
fi | fi | ||||
done | done | ||||
case $bhyve_exit in | case $bhyve_exit in | ||||
0|1|2) | 0|1|2) | ||||
# Cleanup /dev/vmm entry when bhyve did not exit | # Cleanup /dev/vmm entry when bhyve did not exit | ||||
# due to an error. | # due to an error. | ||||
${BHYVECTL} --vm=${vmname} --destroy > /dev/null 2>&1 | ${BHYVECTL} --vm=${vmname} --destroy > /dev/null 2>&1 | ||||
;; | ;; | ||||
esac | esac | ||||
exit $bhyve_exit | exit $bhyve_exit |
Per emails with Paul Vixie we have come up with this:
-x Exit reboot loop even if bhyve exits with reboot code
Allan, can you update the diff please