Skip to content

Commit 2e6757a

Browse files
bdrungConan-Kudo
authored andcommitted
test(run-qemu): check if /dev/kvm is readable and writable
In case `/dev/kvm` is not readable or writable, enabling KVM will fail: ``` run-qemu: timeout --foreground 600 /usr/bin/qemu-system-aarch64 -enable-kvm -cpu host [...] qemu-system-aarch64: Could not access KVM kernel module: Permission denied qemu-system-aarch64: failed to initialize kvm: Permission denied ```
1 parent ca3f51b commit 2e6757a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test/run-qemu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ set_vmlinux_env() {
129129
[[ -x /usr/bin/qemu ]] && BIN=/usr/bin/qemu && ARGS=(-cpu "$QEMU_CPU")
130130
(lsmod | grep -q '^kqemu ') && BIN=/usr/bin/qemu && ARGS=(-kernel-kqemu -cpu host)
131131
[[ -x "/usr/bin/qemu-system-${ARCH}" ]] && BIN="/usr/bin/qemu-system-${ARCH}" && ARGS=(-cpu "$QEMU_CPU")
132-
if [[ -z ${NO_KVM-} && -c /dev/kvm ]]; then
132+
if [[ -z ${NO_KVM-} && -c /dev/kvm && -r /dev/kvm && -w /dev/kvm ]]; then
133133
[[ -x /usr/bin/kvm ]] && BIN=/usr/bin/kvm && ARGS=(-cpu host)
134134
[[ -x /usr/bin/qemu-kvm ]] && BIN=/usr/bin/qemu-kvm && ARGS=(-cpu host)
135135
[[ -x /usr/libexec/qemu-kvm ]] && BIN=/usr/libexec/qemu-kvm && ARGS=(-cpu host)

0 commit comments

Comments
 (0)