mirror of
https://github.com/ublue-os/bazzite.git
synced 2025-01-26 18:35:30 +00:00
Enable virtualization (#406)
* fix: remove accidental $ in awk command * fix: make enable-vfio fail if VENDOR_KARG is unset
This commit is contained in:
parent
67f62bf3fa
commit
af88e82be5
@ -279,29 +279,34 @@ enable-virtualization:
|
||||
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
|
||||
VIRT_TEST=$(rpm-ostree kargs)
|
||||
CPU_VENDOR=$(grep "vendor_id" "/proc/cpuinfo" | uniq | awk -F": " '{ print $2 }')
|
||||
VENDOR_KARG="unset"
|
||||
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"
|
||||
if [[ ${CPU_VENDOR} == "AuthenticAMD" ]]; then
|
||||
VENDOR_KARG="amd_iommu=on"
|
||||
elif [[ ${CPU_VENDOR} == "GenuineIntel" ]]; then
|
||||
VENDOR_KARG="intel_iommu=on"
|
||||
fi
|
||||
if [[ ${VENDOR_KARG} == "unset" ]]; then
|
||||
echo "Failed to get CPU vendor, exiting..."
|
||||
exit 1
|
||||
else
|
||||
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!"
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user