Skip to content

Commit d9f7aaf

Browse files
committed
feat(desktop): Add option to enable virtualization and vfio
1 parent cf7dd21 commit d9f7aaf

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

system_files/desktop/shared/usr/share/ublue-os/just/60-custom.just

+39
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,42 @@ add-user-to-input-group:
266266
sudo bash -c 'grep "input" /lib/group >> /etc/group'
267267
fi
268268
sudo usermod -a -G input $USER
269+
270+
# Enable Virtualization and add workaround for a specific windows VM crash
271+
enable-virtualization:
272+
echo "Installing QEMU and virt-manager..."
273+
rpm-ostree install virt-manager edk2-ovmf qemu
274+
rpm-ostree kargs \
275+
--append-if-missing="kvm.ignore_msrs=1" \
276+
--append-if-missing="kvm.report_ignored_msrs=0"
277+
278+
# Enable VFIO on the system if virtualization is enabled
279+
enable-vfio:
280+
#!/usr/bin/env bash
281+
echo "Enabling VFIO..."
282+
virt_test=$(rpm-ostree kargs)
283+
cpu_vendor=$(grep "vendor_id" "/proc/cpuinfo" | uniq | awk -F": " '{ $print $2 }')
284+
vendor_karg="amd_iommu=on"
285+
if [[ ${virt_test} == *kvm.report_ignored_msrs* ]]; then
286+
rpm-ostree initramfs \
287+
--enable \
288+
--arg="--add-drivers" \
289+
--arg="vfio vfio_iommu_type1 vfio-pci"
290+
if [[ ${cpu_vendor} == "AuthenticAMD" ]]; then
291+
vendor_karg="amd_iommu=on"
292+
elif [[ ${cpu_vendor} == "GenuineIntel" ]]; then
293+
vendor_karg="intel_iommu=on"
294+
fi
295+
rpm-ostree kargs \
296+
--append-if-missing="${vendor_karg}" \
297+
--append-if-missing="iommu=pt" \
298+
--append-if-missing="rd.driver.pre=vfio_pci" \
299+
--append-if-missing="vfio.pci.disable_vga=1"
300+
echo "VFIO enabled, make sure you enable IOMMU, VT-d or AMD-v in your BIOS!"
301+
echo "Please understand that since this is such a niche use case, support will be very limited!"
302+
echo "To add your unused/second GPU device ids to the vfio driver by running"
303+
echo 'rpm-ostree kargs --append-if-missing="vfio-pci.ids=xxxx:yyyy,xxxx:yyzz"'
304+
echo "NOTE: Your second GPU will not be usable by the host after you do this!"
305+
else
306+
echo "Enable virtualization with just enable-virtualization before running just enable-vfio."
307+
fi

0 commit comments

Comments
 (0)