Skip to content

boot-qemu.py: Simplify can_use_kvm()#84

Merged
nathanchance merged 1 commit into
ClangBuiltLinux:mainfrom
nathanchance:update-can-use-kvm
Dec 13, 2022
Merged

boot-qemu.py: Simplify can_use_kvm()#84
nathanchance merged 1 commit into
ClangBuiltLinux:mainfrom
nathanchance:update-can-use-kvm

Conversation

@nathanchance

Copy link
Copy Markdown
Member

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.

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>
@nathanchance nathanchance merged commit 6b17f8f into ClangBuiltLinux:main Dec 13, 2022
@nathanchance nathanchance deleted the update-can-use-kvm branch December 13, 2022 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants