From d9f7aafe07494e92e104849705177be46fcfb6a5 Mon Sep 17 00:00:00 2001 From: HikariKnight <2557889+HikariKnight@users.noreply.github.com> Date: Mon, 2 Oct 2023 08:00:27 +0200 Subject: [PATCH] feat(desktop): Add option to enable virtualization and vfio --- .../usr/share/ublue-os/just/60-custom.just | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/system_files/desktop/shared/usr/share/ublue-os/just/60-custom.just b/system_files/desktop/shared/usr/share/ublue-os/just/60-custom.just index e22d46ec14..d5ec0f5016 100644 --- a/system_files/desktop/shared/usr/share/ublue-os/just/60-custom.just +++ b/system_files/desktop/shared/usr/share/ublue-os/just/60-custom.just @@ -266,3 +266,42 @@ add-user-to-input-group: sudo bash -c 'grep "input" /lib/group >> /etc/group' fi sudo usermod -a -G input $USER + +# Enable Virtualization and add workaround for a specific windows VM crash +enable-virtualization: + echo "Installing QEMU and virt-manager..." + rpm-ostree install virt-manager edk2-ovmf qemu + rpm-ostree kargs \ + --append-if-missing="kvm.ignore_msrs=1" \ + --append-if-missing="kvm.report_ignored_msrs=0" + +# Enable VFIO on the system if virtualization is enabled +enable-vfio: + #!/usr/bin/env bash + echo "Enabling VFIO..." + virt_test=$(rpm-ostree kargs) + cpu_vendor=$(grep "vendor_id" "/proc/cpuinfo" | uniq | awk -F": " '{ $print $2 }') + vendor_karg="amd_iommu=on" + if [[ ${virt_test} == *kvm.report_ignored_msrs* ]]; then + rpm-ostree initramfs \ + --enable \ + --arg="--add-drivers" \ + --arg="vfio vfio_iommu_type1 vfio-pci" + if [[ ${cpu_vendor} == "AuthenticAMD" ]]; then + vendor_karg="amd_iommu=on" + elif [[ ${cpu_vendor} == "GenuineIntel" ]]; then + vendor_karg="intel_iommu=on" + fi + rpm-ostree kargs \ + --append-if-missing="${vendor_karg}" \ + --append-if-missing="iommu=pt" \ + --append-if-missing="rd.driver.pre=vfio_pci" \ + --append-if-missing="vfio.pci.disable_vga=1" + echo "VFIO enabled, make sure you enable IOMMU, VT-d or AMD-v in your BIOS!" + echo "Please understand that since this is such a niche use case, support will be very limited!" + echo "To add your unused/second GPU device ids to the vfio driver by running" + echo 'rpm-ostree kargs --append-if-missing="vfio-pci.ids=xxxx:yyyy,xxxx:yyzz"' + echo "NOTE: Your second GPU will not be usable by the host after you do this!" + else + echo "Enable virtualization with just enable-virtualization before running just enable-vfio." + fi