Skip to content

Commit

Permalink
feat(desktop): Add option to enable virtualization and vfio
Browse files Browse the repository at this point in the history
  • Loading branch information
HikariKnight committed Oct 2, 2023
1 parent cf7dd21 commit d9f7aaf
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions system_files/desktop/shared/usr/share/ublue-os/just/60-custom.just
Expand Up @@ -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

0 comments on commit d9f7aaf

Please sign in to comment.