boot-qemu.py: Simplify can_use_kvm()#84
Merged
nathanchance merged 1 commit intoDec 13, 2022
Merged
Conversation
The existing check for '/dev/kvm' is not strong enough, as it is possible that '/dev/kvm' exists but the user does not have sufficient permissions to access it, which will result in QEMU immediately refusing to start. This can be quite frustrating when doing a sequence of builds non-interactively, as the results will be tainted due to the initial startup failure. Switch to os.access(), which allows us to make sure '/dev/kvm' is writeable with the current permissions. At the same time, clean up this function. If '/dev/kvm' is accessible, it implies hardware virtualization support, so we can ditch the '/proc/cpuinfo' check for x86. Refactor the 32-bit EL1 check for aarch64 to its own function, which allows us to compact the aarch64 section signficantly. Signed-off-by: Nathan Chancellor <nathan@kernel.org>
msfjarvis
approved these changes
Dec 9, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The existing check for
/dev/kvmis not strong enough, as it ispossible that
/dev/kvmexists but the user does not have sufficientpermissions to access it, which will result in QEMU immediately refusing
to start. This can be quite frustrating when doing a sequence of builds
non-interactively, as the results will be tainted due to the initial
startup failure.
Switch to
os.access(), which allows us to make sure/dev/kvmiswriteable with the current permissions.
At the same time, clean up this function. If
/dev/kvmis accessible,it implies hardware virtualization support, so we can ditch the
/proc/cpuinfocheck for x86. Refactor the 32-bit EL1 check for aarch64to its own function, which allows us to compact the aarch64 section
signficantly.