summaryrefslogtreecommitdiff
path: root/hosts/iroha/libvirt/hooks/qemu.d/arcade/prepare
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2024-11-12 22:26:02 -0500
committerAndrew Opalach <andrew@akon.city> 2024-11-12 22:36:49 -0500
commit53a0a5473f45d37027af9663638adbf56667e4ca (patch)
tree05c6c39678a9005f95c00e0fdf31193657bd4d3d /hosts/iroha/libvirt/hooks/qemu.d/arcade/prepare
downloaddotfiles-53a0a5473f45d37027af9663638adbf56667e4ca.tar.gz
dotfiles-53a0a5473f45d37027af9663638adbf56667e4ca.tar.bz2
dotfiles-53a0a5473f45d37027af9663638adbf56667e4ca.zip
Hopefully no leaks
Diffstat (limited to 'hosts/iroha/libvirt/hooks/qemu.d/arcade/prepare')
-rwxr-xr-xhosts/iroha/libvirt/hooks/qemu.d/arcade/prepare/begin/bind_vfio.sh20
l---------hosts/iroha/libvirt/hooks/qemu.d/arcade/prepare/begin/cpuset_prepare_common.sh1
-rwxr-xr-xhosts/iroha/libvirt/hooks/qemu.d/arcade/prepare/begin/port_forward.sh14
3 files changed, 35 insertions, 0 deletions
diff --git a/hosts/iroha/libvirt/hooks/qemu.d/arcade/prepare/begin/bind_vfio.sh b/hosts/iroha/libvirt/hooks/qemu.d/arcade/prepare/begin/bind_vfio.sh
new file mode 100755
index 0000000..f89b61a
--- /dev/null
+++ b/hosts/iroha/libvirt/hooks/qemu.d/arcade/prepare/begin/bind_vfio.sh
@@ -0,0 +1,20 @@
+#! /usr/bin/env bash
+
+source "/etc/libvirt/hooks/arcade.conf"
+
+echo 0 > /sys/class/vtconsole/vtcon0/bind
+echo 0 > /sys/class/vtconsole/vtcon1/bind
+
+modprobe -r nvidia-drm
+modprobe -r nvidia-modeset
+modprobe -r nvidia-uvm
+modprobe -r nvidia
+
+modprobe vfio
+modprobe vfio_iommu_type1
+modprobe vfio_pci
+
+virsh nodedev-detach $VIRSH_GPU_VIDEO
+virsh nodedev-detach $VIRSH_GPU_AUDIO
+virsh nodedev-detach $VIRSH_NVME
+virsh nodedev-detach $VIRSH_USB
diff --git a/hosts/iroha/libvirt/hooks/qemu.d/arcade/prepare/begin/cpuset_prepare_common.sh b/hosts/iroha/libvirt/hooks/qemu.d/arcade/prepare/begin/cpuset_prepare_common.sh
new file mode 120000
index 0000000..fb5a2ab
--- /dev/null
+++ b/hosts/iroha/libvirt/hooks/qemu.d/arcade/prepare/begin/cpuset_prepare_common.sh
@@ -0,0 +1 @@
+../../../../cpuset_prepare_common.sh \ No newline at end of file
diff --git a/hosts/iroha/libvirt/hooks/qemu.d/arcade/prepare/begin/port_forward.sh b/hosts/iroha/libvirt/hooks/qemu.d/arcade/prepare/begin/port_forward.sh
new file mode 100755
index 0000000..7d5d484
--- /dev/null
+++ b/hosts/iroha/libvirt/hooks/qemu.d/arcade/prepare/begin/port_forward.sh
@@ -0,0 +1,14 @@
+#! /usr/bin/env bash
+
+# kdeconnect
+iptables -t nat -C PREROUTING -p tcp -s 192.168.1.0/24 --dport 1714:1764 \
+ -j DNAT --to-destination 192.168.122.40:1714-1764 || \
+iptables -t nat -A PREROUTING -p tcp -s 192.168.1.0/24 --dport 1714:1764 \
+ -j DNAT --to-destination 192.168.122.40:1714-1764
+iptables -t nat -C PREROUTING -p udp -s 192.168.1.0/24 --dport 1714:1764 \
+ -j DNAT --to-destination 192.168.122.40:1714-1764 || \
+iptables -t nat -A PREROUTING -p udp -s 192.168.1.0/24 --dport 1714:1764 \
+ -j DNAT --to-destination 192.168.122.40:1714-1764
+
+iptables -C FORWARD -m state -d 192.168.122.0/24 --state NEW,RELATED,ESTABLISHED -j ACCEPT || \
+iptables -I FORWARD -m state -d 192.168.122.0/24 --state NEW,RELATED,ESTABLISHED -j ACCEPT