Skip to content

Commit

Permalink
fix: make function ignore_msrs_always work
Browse files Browse the repository at this point in the history
With the previous version the file was never written if it not existed before, logic bug.

Make the code simpler to read by preventing unnessesary "else" clause nesting
  • Loading branch information
Gitsarry authored and wodry committed Aug 13, 2024
1 parent a13d554 commit 9357328
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions quickemu
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ fi

function ignore_msrs_always() {
# Make sure the host has /etc/modprobe.d
if [ -d /etc/modprobe.d ]; then
# Skip if ignore_msrs is already enabled, assumes initramfs has been rebuilt
if grep -lq 'ignore_msrs=Y' /etc/modprobe.d/kvm-quickemu.conf >/dev/null 2>&1; then
echo "options kvm ignore_msrs=Y" | sudo tee /etc/modprobe.d/kvm-quickemu.conf
sudo update-initramfs -k all -u
fi
else
if [ ! -d /etc/modprobe.d ]; then
echo "ERROR! /etc/modprobe.d was not found, I don't know how to configure this system."
exit 1
fi

# Skip if ignore_msrs is already enabled, assumes initramfs has been rebuilt
grep -lq 'ignore_msrs=Y' /etc/modprobe.d/kvm-quickemu.conf >/dev/null 2>&1 && return

echo "options kvm ignore_msrs=Y" | sudo tee /etc/modprobe.d/kvm-quickemu.conf
sudo update-initramfs -k all -u
}

function ignore_msrs_alert() {
Expand Down

0 comments on commit 9357328

Please sign in to comment.