run: Only enable KVM if /dev/kvm is r/w for the current user

This commit is contained in:
Andreas Kling 2019-11-04 13:03:33 +01:00
parent 50d937152a
commit e4c80961d9
Notes: sideshowbarker 2024-07-19 11:23:55 +09:00

View file

@ -1,5 +1,7 @@
#!/bin/sh
[ -e /dev/kvm -a -r /dev/kvm -a -w /dev/kvm ] && SERENITY_KVM_ARG="-enable-kvm"
[ -z "$SERENITY_QEMU_BIN" ] && SERENITY_QEMU_BIN="qemu-system-i386"
[ -z "$SERENITY_KERNEL_CMDLINE" ] && SERENITY_KERNEL_CMDLINE="hello"
@ -33,7 +35,7 @@ elif [ "$1" = "qtap" ]; then
# ./run qtap: qemu with tap
sudo $SERENITY_QEMU_BIN \
$SERENITY_COMMON_QEMU_ARGS \
-enable-kvm \
$SERENITY_KVM_ARG \
-object filter-dump,id=hue,netdev=br0,file=e1000.pcap \
-netdev tap,ifname=tap0,id=br0 \
-device e1000,netdev=br0 \
@ -43,7 +45,7 @@ elif [ "$1" = "qgrub" ]; then
# ./run qgrub: qemu with grub
$SERENITY_QEMU_BIN \
$SERENITY_COMMON_QEMU_ARGS \
-enable-kvm \
$SERENITY_KVM_ARG \
-object filter-dump,id=hue,netdev=breh,file=e1000.pcap \
-netdev user,id=breh,hostfwd=tcp:127.0.0.1:8888-10.0.2.15:8888,hostfwd=tcp:127.0.0.1:8823-10.0.2.15:23 \
-device e1000,netdev=breh
@ -58,10 +60,10 @@ else
# ./run: qemu with user networking
$SERENITY_QEMU_BIN \
$SERENITY_COMMON_QEMU_ARGS \
-enable-kvm \
$SERENITY_KVM_ARG \
-object filter-dump,id=hue,netdev=breh,file=e1000.pcap \
-netdev user,id=breh,hostfwd=tcp:127.0.0.1:8888-10.0.2.15:8888,hostfwd=tcp:127.0.0.1:8823-10.0.2.15:23 \
-device e1000,netdev=breh \
-kernel kernel \
-append "${SERENITY_KERNEL_CMDLINE}"
fi
fi