Moved to a different repo

This commit is contained in:
Anthony Rose 2022-09-07 07:55:22 +01:00
parent 6d8346dab4
commit 26ed692c3e

View file

@ -1,87 +0,0 @@
#!/bin/sh
# The number of the VM, from 0 to 9. This will be used for the VNC port, TAP
# interface name, and serial console number.
vmnumber=0
# Copyright 2022 Anthony Perkins
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Copy this script to $vmpath. The filename should be the VM name. To ease
# snapshotting, each VM should be in its own directory, and should be a separate
# ZFS dataset. For example:
#
# /virt/vm0 <-- ZFS dataset and $vmpath.
# /virt/vm0/vm0 <-- This script.
# /virt/vm0/vm0_disk0.img <-- Hard disk image.
# /virt/vm0/cdrom.iso <-- Operating System install ISO.
# The VM will have one virtual CPU socket with this number of cores. Windows
# will only see up to two sockets, but up to 256 cores per socket. So cores are
# preferred.
cpucores=1
# RAM size in KiB (K), MiB (M), or GiB (G).
ram=1G
# Host that VNC will listen on. Note that "0.0.0.0" and "[::]" will be
# accessible over the network. "127.0.0.1", and "[::1]" will only be accessible
# from this host (or via SSH tunnels).
vnchost="[::1]"
# Uncomment to use stdio for the serial console.
#comoutput=stdio
# Comment the next line out for no CD-ROM.
#cdrom="-s 3,ahci-cd,$vmpath/cdrom.iso"
################################################################################
# Check for firmware.
if ! [ -e /usr/local/share/uefi-firmware/BHYVE_UEFI.fd ]; then
echo "Firmware not found. Try \`pkg install bhyve-firmware\`." >&2
exit 1
fi
# The VM will be named after the vmnumber, unless you change the
# vmname variable here.
vmname=vm$vmnumber
vmpath=$(dirname $0)
# Calculate the VNC port number (5900 + $vmnumber).
vncport=$(echo "5900 + $vmnumber" | bc)
# Finally, run the bhyve command with all of these variables. Note that there
# are a few limitations with UEFI or Windows:
#
# - ahci-* devices must be in slots 3, 4, 5, or 6.
# - lpc must be in slot 31.
# - Some Windows versions require a CD-ROM device to be present. This can be
# an empty file, created with 'touch cdrom.iso'.
/usr/sbin/bhyve \
-c sockets=1,cores=$cpucores,threads=1 \
-m $ram \
-w \
-H \
-s 0,hostbridge \
-s 1,virtio-blk,$vmpath/${vmname}_disk0.img \
-s 2,virtio-net,tap$vmnumber \
$cdrom \
-s 29,fbuf,tcp=$vnc:$vncport,w=800,h=600 \
-s 30,xhci,tablet \
-s 31,lpc \
-l com1,${comoutput:-/dev/nmdm${vmnumber}A} \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
$vmname
/usr/sbin/bhyvectl --destroy --vm=$vmname