Commands that just work
To make absolutely sure that it will work, we can make Buildroot build QEMU for us, and use the exact QEMU CLI provided by Buildroot at: https://github.com/buildroot/buildroot/blob/2019.05/board/qemu/x86_64/readme.txt
git clone https://github.com/buildroot/buildroot
git checkout 2019.05
' >> .config
time make BR2_JLEVEL="$(nproc)" HOST_QEMU_OPTS='--enable-sdl --with-sdlabi=2.0'
-M pc \
-kernel output/images/bzImage \
-drive file=output/images/rootfs.ext2,if=virtio,format=raw \
-append "rootwait root=/dev/vda" \
-net nic,model=virtio \
-net user \
You are now left on a shell and you can login with username
root (no password).
Note however that the default Buildroot build does not have an interesting GUI like X11 by default, as that is not the most common use case for this project. I have covered that at: How to install X11 on my own Linux Buildroot system?
But because Buildroot does not focus enough on the run part to my needs (more automation, more boot types, GDB step debug), I extended it with some extra scripts on this project: https://github.com/cirosantilli/linux-kernel-module-cheat
Other ISAs mentioned at: https://cirosantilli.com/linux-kernel-module-cheat/#buildroot-hello-world
Buildroot 2019.08 QEMU build failed because QEMU 3.1.1 release has a broken x86_64 build... QEMU 3.1.1 failed to build
Tested in Ubuntu 19.04.