From da0941bdefaa8cfff38609dd4b4fc8275692912e Mon Sep 17 00:00:00 2001 From: Fritz Grimpen Date: Sat, 4 Jan 2025 03:36:17 +0100 Subject: [PATCH] s6 bhyve fuckstack schlimmer gemacht --- host_vars/emma.ccchb.de.yml | 2 + roles/bhyve-s6/tasks/main.yml | 2 +- roles/bhyve-s6/templates/bhyve/env/DISKS.j2 | 2 +- roles/bhyve-s6/templates/bhyve/run.j2 | 42 +++++++++------------ 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/host_vars/emma.ccchb.de.yml b/host_vars/emma.ccchb.de.yml index 320672d..a1f7b0c 100644 --- a/host_vars/emma.ccchb.de.yml +++ b/host_vars/emma.ccchb.de.yml @@ -241,6 +241,8 @@ bhyve_guests: - DISKS disks: - name: disk + virtio: true + virtio_slot: 8 properties: volsize: 128g volblocksize: 64k diff --git a/roles/bhyve-s6/tasks/main.yml b/roles/bhyve-s6/tasks/main.yml index 1e75949..622ff0b 100644 --- a/roles/bhyve-s6/tasks/main.yml +++ b/roles/bhyve-s6/tasks/main.yml @@ -25,7 +25,7 @@ label: 'bhyve-{{ item.0.name }}{{ item.1.name }}' with_nested: - '{{ bhyve_guests }}' - - '{{ bhyve_templates }}' + - '{{ bhyve_templates }}' notify: - Reload s6-rc diff --git a/roles/bhyve-s6/templates/bhyve/env/DISKS.j2 b/roles/bhyve-s6/templates/bhyve/env/DISKS.j2 index 1abddda..70e4086 100644 --- a/roles/bhyve-s6/templates/bhyve/env/DISKS.j2 +++ b/roles/bhyve-s6/templates/bhyve/env/DISKS.j2 @@ -1,5 +1,5 @@ {% set disks = [] %} -{% for disk in item.0.disks %} +{% for disk in item.0.disks if not disk.virtio|default(False) %} {{- disks.append("hd:/dev/zvol/"+bhyve_pool+"/bhyve/guests/"+item.0.name+"/"+disk.name) -}} {% endfor %} {{ disks | join(",") }} diff --git a/roles/bhyve-s6/templates/bhyve/run.j2 b/roles/bhyve-s6/templates/bhyve/run.j2 index ebe1c38..d71c6dd 100644 --- a/roles/bhyve-s6/templates/bhyve/run.j2 +++ b/roles/bhyve-s6/templates/bhyve/run.j2 @@ -1,9 +1,9 @@ #!/usr/local/bin/execlineb -P -# {{ ansible_managed }} +# {{ ansible_managed }} s6-envdir ./env multisubstitute { - importas -i -u NAME NAME + importas -i -u NAME NAME importas -i -u -s ORDER ORDER importas -i -u RAM RAM importas -i -u ROM ROM @@ -15,7 +15,7 @@ multisubstitute { } backtick -n AHCI { - forx X { $ORDER } + forx X { $ORDER } importas X X importas Y $X echo -n ,$Y @@ -29,25 +29,17 @@ foreground { fdmove -c 1 2 echo "bhyve-${NAME}: Starting VM ${NAME} with ${CPUS} s6-notifyoncheck -d -w 100 -n 70 fdmove -c 2 1 -# Use a static password to make VNC clients happy -ifelse { test -n "$PASS" } { - bhyve -c "${CPUS}" -m "${RAM}" -w -A -P -H - -s "0,amd_hostbridge" - -s "2:0,ahci${AHCI}" - -s "3,virtio-net,${NIC}" - -s "4,virtio-rnd" - -s "29,fbuf,tcp=[::1]:${PORT},w=800,h=600,password=${PASS}" - -s "31,lpc" - -l "com1,/dev/${COM}" - -l "bootrom,${ROM}" - "${NAME}" -} - bhyve -c "${CPUS}" -m "${RAM}" -w -A -P -H - -s "0,amd_hostbridge" - -s "2:0,ahci${AHCI}" - -s "3,virtio-net,${NIC}" - -s "4,virtio-rnd" - -s "31,lpc" - -l "com1,/dev/${COM}" - -l "bootrom,${ROM}" - "${NAME}" +bhyve -c "{{ item.0.cpus }}" -m "{{ item.0.ram }}" -w -A -P -h + -s "0,amd_hostbridge" + -s "2:0,ahci${AHCI}" + -s "3,virtio-net,${NIC}" + -s "4,virtio-rnd" + {% for disk in item.0.disks if disk.virtio|default(False) -%} + -s "{{ disk.virtio_slot }},virtio,/dev/zvol/{{ bhyve_pool }}/bhyve/guests/{{ item.0.name }}/{{ disk.name }}" + {% endfor -%} + {% if item.0.password is defined -%} + -s "29,fbuf,tcp=[::1]:${PORT},w=800,h=600,password=${PASS}" + {% endif -%} + -s "31,lpc" + -l "com1,/dev/${COM}" + -l "bootrom,${ROM}"