Merge pull request #1 from ublue-os/main

chore(ujust): Improve setup-virtualization user experience (#1237)
This commit is contained in:
Brother Michael 2024-06-24 09:57:07 +00:00 committed by GitHub
commit e6d229169a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 21 deletions

View File

@ -0,0 +1,12 @@
[Unit]
Description=Enable libvirtd service after reboot
After=local-fs.target
ConditionPathExists=/usr/lib/systemd/system/libvirtd.service
[Service]
Type=oneshot
# TODO: Rewrite this whenever systemd allows to queue ephemeral commands for next boot without modifying kernel args
ExecStart=/usr/bin/bash -c "systemctl enable --now libvirtd; systemctl disable %n"
[Install]
WantedBy=multi-user.target

View File

@ -41,29 +41,34 @@ setup-virtualization ACTION="":
) )
fi fi
if [[ "${OPTION,,}" =~ (^enable[[:space:]]virtualization|virt-on) ]]; then if [[ "${OPTION,,}" =~ (^enable[[:space:]]virtualization|virt-on) ]]; then
virt_test=$(rpm-ostree status | grep -A 4 "●" | grep "virt-manager") (
if [[ -z ${virt_test} ]]; then virt_test=$(rpm-ostree status -v --jsonpath '.deployments[0].packages')
echo "Installing QEMU and virt-manager..." if [[ ${virt_test} == *virt-manager* ]]; then
rpm-ostree install -y virt-manager edk2-ovmf qemu echo "Installing QEMU and virt-manager..."
rpm-ostree kargs \ rpm-ostree install -y virt-manager edk2-ovmf qemu
--append-if-missing="kvm.ignore_msrs=1" \ rpm-ostree kargs \
--append-if-missing="kvm.report_ignored_msrs=0" --append-if-missing="kvm.ignore_msrs=1" \
echo 'Please re-run "ujust setup-virtualization" after the reboot to enable libvirtd service' --append-if-missing="kvm.report_ignored_msrs=0"
fi sudo systemctl enable bazzite-libvirtd-setup.service \
elif [[ "${OPTION,,}" =~ (^disable[[:space:]]virtualization|virt-off) ]]; then && echo "libvirtd will be enabled at next reboot"
virt_test=$(rpm-ostree status | grep -A 4 "●" | grep "virt-manager") echo 'Please reboot to apply changes'
if [[ ${virt_test} ]]; then
if [ "$(systemctl is-enabled libvirtd.service)" == "enabled" ]; then
echo "${red}Disabling${n} libvirtd before removal"
sudo systemctl disable --now libvirtd 2> /dev/null
fi fi
echo "Removing QEMU and virt-manager..." )
rpm-ostree remove -y virt-manager edk2-ovmf qemu elif [[ "${OPTION,,}" =~ (^disable[[:space:]]virtualization|virt-off) ]]; then
rpm-ostree kargs \ if [ "$(systemctl is-enabled libvirtd.service)" == "enabled" ]; then
--delete-if-present="kvm.ignore_msrs=1" \ echo "${red}Disabling${n} libvirtd before removal"
--delete-if-present="kvm.report_ignored_msrs=0" sudo systemctl disable --now libvirtd 2> /dev/null
echo 'Please re-run "ujust enable-virtualization" after the reboot to finish setup'
fi fi
if [ "$(systemctl is-enabled bazzite-libvirtd-setup.service)" == "enabled" ]; then
echo "${red}Disabling${n} bazzite-libvirtd-setup"
sudo systemctl disable --now bazzite-libvirtd-setup.service 2> /dev/null
fi
echo "Removing QEMU and virt-manager..."
rpm-ostree remove -y virt-manager edk2-ovmf qemu
rpm-ostree kargs \
--delete-if-present="kvm.ignore_msrs=1" \
--delete-if-present="kvm.report_ignored_msrs=0"
echo 'Please reboot to apply changes'
elif [[ "${OPTION,,}" =~ (^enable[[:space:]]vfio|vfio-on) ]]; then elif [[ "${OPTION,,}" =~ (^enable[[:space:]]vfio|vfio-on) ]]; then
# Check if we are running on a Steam Deck # Check if we are running on a Steam Deck
if /usr/libexec/hwsupport/valve-hardware; then if /usr/libexec/hwsupport/valve-hardware; then