Handle the networking.
This commit is contained in:
parent
977c8a74e8
commit
b0d8800b52
33
scripts/launch_bhyve.bash
Normal file → Executable file
33
scripts/launch_bhyve.bash
Normal file → Executable file
@ -4,6 +4,22 @@ set -euo pipefail
|
|||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
function cleanup {
|
||||||
|
for dev in "${devices[@]}"; do
|
||||||
|
echo "Deleting $dev"
|
||||||
|
ifconfig "$dev" destroy
|
||||||
|
done
|
||||||
|
}
|
||||||
|
devices=()
|
||||||
|
for sig in EXIT INT QUIT HUP TERM; do
|
||||||
|
trap "set +e; cleanup" "$sig"
|
||||||
|
done
|
||||||
|
|
||||||
|
ifconfig tap1 create
|
||||||
|
devices+=("tap1")
|
||||||
|
ifconfig tap1 up
|
||||||
|
ifconfig bridge0 addm tap1
|
||||||
|
|
||||||
# 1 core
|
# 1 core
|
||||||
# 1GB ram
|
# 1GB ram
|
||||||
# -H yield the virtual CPU when HLT instruction is detected, otherwise bhyve eats the entire core
|
# -H yield the virtual CPU when HLT instruction is detected, otherwise bhyve eats the entire core
|
||||||
@ -12,11 +28,14 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||||||
# -U for specifying uuid, going to omit and see if the generated one works
|
# -U for specifying uuid, going to omit and see if the generated one works
|
||||||
# -u RTC is in UTC
|
# -u RTC is in UTC
|
||||||
# -s virtual PCI slots
|
# -s virtual PCI slots
|
||||||
|
# -P force guest CPU to exit when PAUSE instruction detected
|
||||||
|
set +e
|
||||||
bhyve \
|
bhyve \
|
||||||
-c 1 \
|
-c 1 \
|
||||||
-m 1024M \
|
-m 1024M \
|
||||||
-H \
|
-H \
|
||||||
-w \
|
-w \
|
||||||
|
-P \
|
||||||
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
|
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
|
||||||
-u \
|
-u \
|
||||||
-s 0,hostbridge \
|
-s 0,hostbridge \
|
||||||
@ -29,3 +48,17 @@ bhyve \
|
|||||||
-s 3:0,ahci-cd,/vm/.config/null.iso \
|
-s 3:0,ahci-cd,/vm/.config/null.iso \
|
||||||
-l com1,/dev/nmdm-docker.1A \
|
-l com1,/dev/nmdm-docker.1A \
|
||||||
docker
|
docker
|
||||||
|
bhyve_status=$?
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$bhyve_status" == "0" ]; then
|
||||||
|
echo "rebooted"
|
||||||
|
elif [ "$bhyve_status" == "1" ]; then
|
||||||
|
echo "powered off"
|
||||||
|
elif [ "$bhyve_status" == "2" ]; then
|
||||||
|
echo "halted"
|
||||||
|
elif [ "$bhyve_status" == "3" ]; then
|
||||||
|
echo "triple fault"
|
||||||
|
elif [ "$bhyve_status" == "4" ]; then
|
||||||
|
echo "exited due to an error"
|
||||||
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user