mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-09-29 17:20:03 +00:00
Passing accel=kvm:tcg causes it to try KVM first if available with a fallback to TCG (emulated/JIT mode) if it is not available. With this the boot logs gain: +Hypervisor detected: KVM and also -Booting paravirtualized kernel on bare hardware +Booting paravirtualized kernel on KVM Among various other noise. If I rename my host /dev/kvm then this is reversed, although with the following message: Could not access KVM kernel module: No such file or directory failed to initialize KVM: No such file or directory Back to tcg accelerator. Q35 is a more modern emulated platform based on the ICH9 host chipset rather than the default "pc" I440FX (Pentium Pro / Pentium II era) emulation. See http://wiki.qemu-project.org/Features/Q35 for more info. Switching to Q35 is not a requirement for enabling KVM but seemed like a reasonable change. Signed-off-by: Ian Campbell <ian.campbell@docker.com>
48 lines
1.1 KiB
Bash
Executable File
48 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
cd /tmp
|
|
|
|
# extract. BSD tar auto recognises compression, unlike GNU tar
|
|
# only if stdin is a tty, if so need files volume mounted...
|
|
[ -t 0 ] || bsdtar xzf -
|
|
|
|
TGZ="$(find . -name '*.tgz' -or -name '*.tar.gz')"
|
|
[ -n "$TGZ" ] && bsdtar xzf "$TGZ"
|
|
|
|
ISO="$(find . -name '*.iso')"
|
|
RAW="$(find . -name '*.raw')"
|
|
INITRD="$(find . -name '*.img')"
|
|
KERNEL="$(find . -name vmlinuz64 -or -name '*bzImage')"
|
|
|
|
if [ -n "$ISO" ]
|
|
then
|
|
ARGS="-cdrom $ISO -drive file=systemdisk.img,format=raw"
|
|
elif [ -n "$RAW" ]
|
|
then
|
|
# should test with more drives
|
|
ARGS="-drive file=$RAW,format=raw"
|
|
elif [ -n "KERNEL" ]
|
|
then
|
|
ARGS="-kernel $KERNEL"
|
|
if [ -n "$INITRD" ]
|
|
then
|
|
ARGS="$ARGS -initrd $INITRD"
|
|
fi
|
|
ARGS="$ARGS -drive file=systemdisk.img,format=raw"
|
|
else
|
|
echo "no recognised boot media" >2
|
|
exit 1
|
|
fi
|
|
|
|
echo "$ARGS" | grep -q systemdisk && qemu-img create -f raw systemdisk.img 256M
|
|
|
|
CMDLINE="$*"
|
|
if [ -z "${CMDLINE}" ]
|
|
then
|
|
CMDLINE="console=ttyS0"
|
|
fi
|
|
|
|
qemu-system-x86_64 -machine q35,accel=kvm:tcg -device virtio-rng-pci -serial stdio -vnc none -m 1024 -append "${CMDLINE}" $ARGS
|