From 49e7d0475ea0c362035c32dfded38e0f55c0b560 Mon Sep 17 00:00:00 2001 From: HikariKnight <2557889+HikariKnight@users.noreply.github.com> Date: Sun, 28 Apr 2024 19:38:06 +0200 Subject: [PATCH] feat: add kvmfr module (looking-glass) and vfio support (#1226) Co-authored-by: m2 <69128853+m2Giles@users.noreply.github.com> --- Containerfile | 6 +- build_files/dx/build-dx.sh | 1 + build_files/dx/copr-repos-dx.sh | 5 +- build_files/dx/install-akmods-dx.sh | 9 ++ just/bluefin-system.just | 94 +++++++++++++++ .../dx/usr/libexec/bluefin-dx-kvmfr-setup | 108 ++++++++++++++++++ 6 files changed, 221 insertions(+), 2 deletions(-) create mode 100644 build_files/dx/install-akmods-dx.sh create mode 100755 system_files/dx/usr/libexec/bluefin-dx-kvmfr-setup diff --git a/Containerfile b/Containerfile index a3cc1ec50c5..05631c5b3a7 100644 --- a/Containerfile +++ b/Containerfile @@ -45,6 +45,7 @@ ARG IMAGE_NAME="${IMAGE_NAME}" ARG IMAGE_VENDOR="${IMAGE_VENDOR}" ARG BASE_IMAGE_NAME="${BASE_IMAGE_NAME}" ARG IMAGE_FLAVOR="${IMAGE_FLAVOR}" +ARG AKMODS_FLAVOR="${AKMODS_FLAVOR}" ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION}" # dx specific files come from the dx directory in this repo @@ -52,10 +53,13 @@ COPY build_files/dx build_files/shared /tmp/build/ COPY system_files/dx / COPY packages.json /tmp/packages.json +# Copy akmods-extra from ublue +COPY --from=ghcr.io/ublue-os/akmods-extra:${AKMODS_FLAVOR}-${FEDORA_MAJOR_VERSION} /rpms /tmp/akmods-rpms + # Build, Clean-up, Commit RUN bash -c ". /tmp/build/build-dx.sh" && \ fc-cache --system-only --really-force --verbose && \ rm -rf /tmp/* /var/* && \ mkdir -p /var/tmp && \ chmod -R 1777 /var/tmp && \ - ostree container commit \ No newline at end of file + ostree container commit diff --git a/build_files/dx/build-dx.sh b/build_files/dx/build-dx.sh index 40c21e23e50..c6e43823a87 100644 --- a/build_files/dx/build-dx.sh +++ b/build_files/dx/build-dx.sh @@ -7,6 +7,7 @@ set -ouex pipefail sysctl -p . /tmp/build/copr-repos-dx.sh +. /tmp/build/install-akmods-dx.sh . /tmp/build/packages-dx.sh . /tmp/build/image-info.sh . /tmp/build/fetch-install-dx.sh diff --git a/build_files/dx/copr-repos-dx.sh b/build_files/dx/copr-repos-dx.sh index 27b32cc86d2..b64dcac11c2 100644 --- a/build_files/dx/copr-repos-dx.sh +++ b/build_files/dx/copr-repos-dx.sh @@ -12,4 +12,7 @@ wget https://copr.fedorainfracloud.org/coprs/ublue-os/staging/repo/fedora-"${FED wget https://copr.fedorainfracloud.org/coprs/karmab/kcli/repo/fedora-"${FEDORA_MAJOR_VERSION}"/karmab-kcli-fedora-"${FEDORA_MAJOR_VERSION}".repo -O /etc/yum.repos.d/karmab-kcli-fedora-"${FEDORA_MAJOR_VERSION}".repo # Fonts -wget https://copr.fedorainfracloud.org/coprs/atim/ubuntu-fonts/repo/fedora-"${FEDORA_MAJOR_VERSION}"/atim-ubuntu-fonts-fedora-"${FEDORA_MAJOR_VERSION}".repo -O /etc/yum.repos.d/atim-ubuntu-fonts-fedora-"${FEDORA_MAJOR_VERSION}".repo \ No newline at end of file +wget https://copr.fedorainfracloud.org/coprs/atim/ubuntu-fonts/repo/fedora-"${FEDORA_MAJOR_VERSION}"/atim-ubuntu-fonts-fedora-"${FEDORA_MAJOR_VERSION}".repo -O /etc/yum.repos.d/atim-ubuntu-fonts-fedora-"${FEDORA_MAJOR_VERSION}".repo + +# Kvmfr module +wget https://copr.fedorainfracloud.org/coprs/hikariknight/looking-glass-kvmfr/repo/fedora-"${FEDORA_MAJOR_VERSION}"/hikariknight-looking-glass-kvmfr-fedora-"${FEDORA_MAJOR_VERSION}".repo -O /etc/yum.repos.d/hikariknight-looking-glass-kvmfr-fedora-"${FEDORA_MAJOR_VERSION}".repo diff --git a/build_files/dx/install-akmods-dx.sh b/build_files/dx/install-akmods-dx.sh new file mode 100644 index 00000000000..3949c139759 --- /dev/null +++ b/build_files/dx/install-akmods-dx.sh @@ -0,0 +1,9 @@ +#!/usr/bin/bash + +set -ouex pipefail + +sed -i 's@enabled=0@enabled=1@g' /etc/yum.repos.d/_copr_ublue-os-akmods.repo +if [[ "${FEDORA_MAJOR_VERSION}" -ge "39" ]]; then + rpm-ostree install \ + /tmp/akmods-rpms/kmods/*kvmfr*.rpm +fi diff --git a/just/bluefin-system.just b/just/bluefin-system.just index 981f13d6909..9041836fa78 100644 --- a/just/bluefin-system.just +++ b/just/bluefin-system.just @@ -161,6 +161,100 @@ dx-group: sudo usermod -aG libvirt $USER @echo "Logout to use docker, incus-admin, lxd, libvirt" +# Configure system to use vfio and kvmfr +configure-vfio ACTION="": + #!/usr/bin/bash + source /usr/lib/ujust/ujust.sh + CURRENT_IMAGE=$(rpm-ostree status -b --json | jq -r '.deployments[0]."container-image-reference"') + if grep -q "dx" <<< $CURRENT_IMAGE + then + DEVMODE="enabled" + else + DEVMODE="disabled" + fi + if [ "$DEVMODE" == "disabled" ]; then + echo 'Please run "ujust devmode" first' + exit 0 + fi + OPTION={{ ACTION }} + if [ "$OPTION" == "help" ]; then + echo "Usage: ujust configure-vfio