mirror of
https://github.com/ublue-os/bazzite.git
synced 2025-03-14 01:18:40 +00:00
chore(ujust): Improve setup-virtualization user experience (#1237)
* chore(ujust): Improve virt-manager detection at setup-virtualization * refactor(ujust): isolate temporary var in a subshell * chore(ujust): Move libvirtd,service enablement logic to service * Add bazzite-libvirtd-setup.service * fix(ujust): Replace faulty bazzite-libvirtd-setup.service triggering condition * chore(ujust): reduce grep usage in setup-virtualization * chore(ujust): add missing sudo call * chore(ujust): remove unnecessary check in disable-virtualization rpm-ostree should remove virtualization related packages/kernel args regardless of virt-manager being installed. rpm-ostree will not generate a commit if no effective change is applied. * chore(ujust): Disable setup service at disable-virtualization --------- Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
This commit is contained in:
parent
ae31f7779e
commit
b739cd9e69
@ -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
|
@ -41,29 +41,34 @@ setup-virtualization ACTION="":
|
||||
)
|
||||
fi
|
||||
if [[ "${OPTION,,}" =~ (^enable[[:space:]]virtualization|virt-on) ]]; then
|
||||
virt_test=$(rpm-ostree status | grep -A 4 "●" | grep "virt-manager")
|
||||
if [[ -z ${virt_test} ]]; then
|
||||
echo "Installing QEMU and virt-manager..."
|
||||
rpm-ostree install -y virt-manager edk2-ovmf qemu
|
||||
rpm-ostree kargs \
|
||||
--append-if-missing="kvm.ignore_msrs=1" \
|
||||
--append-if-missing="kvm.report_ignored_msrs=0"
|
||||
echo 'Please re-run "ujust setup-virtualization" after the reboot to enable libvirtd service'
|
||||
fi
|
||||
elif [[ "${OPTION,,}" =~ (^disable[[:space:]]virtualization|virt-off) ]]; then
|
||||
virt_test=$(rpm-ostree status | grep -A 4 "●" | grep "virt-manager")
|
||||
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
|
||||
(
|
||||
virt_test=$(rpm-ostree status -v --jsonpath '.deployments[0].packages')
|
||||
if [[ ${virt_test} == *virt-manager* ]]; then
|
||||
echo "Installing QEMU and virt-manager..."
|
||||
rpm-ostree install -y virt-manager edk2-ovmf qemu
|
||||
rpm-ostree kargs \
|
||||
--append-if-missing="kvm.ignore_msrs=1" \
|
||||
--append-if-missing="kvm.report_ignored_msrs=0"
|
||||
sudo systemctl enable bazzite-libvirtd-setup.service \
|
||||
&& echo "libvirtd will be enabled at next reboot"
|
||||
echo 'Please reboot to apply changes'
|
||||
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 re-run "ujust enable-virtualization" after the reboot to finish setup'
|
||||
)
|
||||
elif [[ "${OPTION,,}" =~ (^disable[[:space:]]virtualization|virt-off) ]]; 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
|
||||
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
|
||||
# Check if we are running on a Steam Deck
|
||||
if /usr/libexec/hwsupport/valve-hardware; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user