diff --git a/misc/build.func b/misc/build.func index e48e17b6..9f63fea5 100644 --- a/misc/build.func +++ b/misc/build.func @@ -2290,11 +2290,60 @@ EOF fi fi + gpu_inside_setup() { + local CTID="$1" + + # VAAPI inside (Debian/Ubuntu) + if [[ "${ENABLE_VAAPI:-0}" -eq 1 ]]; then + msg_info "Installing VAAPI userland inside CT ${CTID}" + pct exec "$CTID" -- bash -lc ' + set -e + . /etc/os-release || true + if [[ "${VERSION_CODENAME:-}" == "trixie" ]]; then + cat >/etc/apt/sources.list.d/non-free.sources </etc/apk/repositories diff --git a/misc/passthrough.func b/misc/passthrough.func index 9c19cdbe..6eab5f0b 100644 --- a/misc/passthrough.func +++ b/misc/passthrough.func @@ -97,8 +97,9 @@ usb_handle_passthrough() { local CT_ID="$1" CT_TYPE="$2" local LXC_CONFIG="/etc/pve/lxc/${CT_ID}.conf" - [[ "$CT_TYPE" != "0" ]] && return 0 # USB passthrough only for privileged CTs - + if [[ "$CT_TYPE" != "0" ]]; then + return 0 # USB passthrough only for privileged CTs + fi cat <>"$LXC_CONFIG" # USB passthrough lxc.cgroup2.devices.allow: a @@ -221,11 +222,13 @@ vaapi_select_and_apply() { done # Fallback only for privileged CTs - [[ "$CT_TYPE" == "0" ]] && cat <<'EOF' >>"$LXC_CONFIG" + if [[ "$CT_TYPE" == "0" ]]; then + cat <<'EOF' >>"$LXC_CONFIG" # VAAPI fallback lxc.mount.entry: /dev/dri /dev/dri none bind,optional,create=dir lxc.cgroup2.devices.allow: c 226:* rwm EOF + fi } # ----------------------------- NVIDIA ----------------------------------------- @@ -248,7 +251,9 @@ nvidia_passthrough_to_lxc() { return } - [[ -d /dev/dri && "$CT_TYPE" == "0" ]] && echo "lxc.mount.entry: /dev/dri /dev/dri none bind,optional,create=dir" >>"$LXC_CONFIG" + if [[ -d /dev/dri && "$CT_TYPE" == "0" ]]; then + echo "lxc.mount.entry: /dev/dri /dev/dri none bind,optional,create=dir" >>"$LXC_CONFIG" + fi msg_ok "NVIDIA devices mapped to CT ${CT_ID}" }