From c23a99bd412a2c7dd160a9d9ad1de44cce9e7f3d Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 7 Dec 2025 10:32:56 -0500 Subject: [PATCH] Add support for multiple 9p directories. --- ansible/roles/bhyve/files/bhyverc.bash | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ansible/roles/bhyve/files/bhyverc.bash b/ansible/roles/bhyve/files/bhyverc.bash index e76ffe8..e8ac4fd 100644 --- a/ansible/roles/bhyve/files/bhyverc.bash +++ b/ansible/roles/bhyve/files/bhyverc.bash @@ -284,7 +284,9 @@ function start_body { protect -d -i -p "$$" fi + local entry parsed_item local additional_args=() + local next_pcie_slot=10 if [ "$NETWORK" = "NAT" ]; then assert_bridge "$host_interface_name" "$bridge_name" "$ip_range" @@ -307,7 +309,17 @@ function start_body { fi if [ -n "$BIND9P" ]; then - additional_args+=("-s" "28,virtio-9p,bind9p=${BIND9P}") + if [[ "$BIND9P" = *":"* ]]; then + IFS=':' read -ra entry <<<"$BIND9P" + for item in "${entry[@]}"; do + IFS='=' read -ra parsed_item <<<"$item" + additional_args+=("-s" "${next_pcie_slot},virtio-9p,${parsed_item[0]}=${parsed_item[1]}") + next_pcie_slot=$((next_pcie_slot+1)) + done + else + additional_args+=("-s" "${next_pcie_slot},virtio-9p,bind9p=${BIND9P}") + next_pcie_slot=$((next_pcie_slot+1)) + fi fi @@ -321,7 +333,8 @@ function start_body { additional_args+=("-s" "5,ahci-cd,$mount_cd") fi if [ "$VNC_ENABLE" = "YES" ]; then - additional_args+=("-s" "29,fbuf,tcp=$VNC_LISTEN,w=$VNC_WIDTH,h=$VNC_HEIGHT") + additional_args+=("-s" "${next_pcie_slot},fbuf,tcp=$VNC_LISTEN,w=$VNC_WIDTH,h=$VNC_HEIGHT") + next_pcie_slot=$((next_pcie_slot+1)) fi vms+=("$name") while true; do @@ -340,8 +353,8 @@ function start_body { -o 'rtc.use_localtime=false' -s "0,hostbridge" -s "4,nvme,/dev/zvol/${zfs_path}/disk0" - -s "30,xhci,tablet" - -s "31,lpc" -l "com1,stdio" + -s "${next_pcie_slot},xhci,tablet" + -s "$((next_pcie_slot+1)),lpc" -l "com1,stdio" -l "bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd,${mount_path}/BHYVE_UEFI_VARS.fd" "${additional_args[@]}" "$name"