Working Ubuntu 18.04 host / guest setup
I cannot reproduce with the following setup:
wget http://releases.ubuntu.com/xenial/ubuntu-18.04-desktop-amd64.iso
qemu-img create -f qcow2 ubuntu-18.04-desktop-amd64.img.qcow2 16G
qemu-system-x86_64 \
-cdrom ubuntu-18.04-desktop-amd64.iso \
-drive file=ubuntu-18.04-desktop-amd64.qcow2,format=qcow2 \
-enable-kvm \
-m 2G \
-smp 2 \
-vga virtio \
;
Then on the GUI:
- Install Ubuntu
- continue, continue, continue...
- wait a few minutes
- at the end "Restart now"
- now you can close the QEMU window
After the install is complete, I recommend using a disk snapshot in case you ever want to go back to the pristine install (a common use case for testing software):
qemu-img create -f qcow2 -b ubuntu-18.04-desktop-amd64.qcow2 \
ubuntu-18.04-desktop-amd64.snapshot.qcow2
and then restart the system from the snapshot disk:
qemu-system-x86_64 \
-drive file=ubuntu-18.04-desktop-amd64.snapshot.qcow2,format=qcow2 \
-enable-kvm \
-m 2G \
-smp 2 \
-vga virtio \
;
Then anytime you want to go back to the pristine install, just re-run:
qemu-img create -f qcow2 -b ubuntu-18.04-desktop-amd64.qcow2 \
ubuntu-18.04-desktop-amd64.snapshot.qcow2
The snapshot only stores the diffs between the original image, and so it does not take a lot of disk space.
Tested on an Ubuntu 18.04 host, QEMU 1:2.11+dfsg-1ubuntu7.3, nvidia-384 version 390.48-0ubuntu3, Lenovo ThinkPad P51, NVIDIA Corporation GM107GLM [Quadro M1200 Mobile] GPU.

Notes:
-vga virtio option is to be able to get higher resolutions: https://superuser.com/questions/132322/how-to-increase-the-visualized-screen-resolution-on-qemu-kvm/1331924#1331924 Toggle full screen with:
Ctrl + Alt + F
of start QEMU with -full-screen.
-soundhw hda enables sound. Why does not QEMU enable it by default beats me.
Once inside the VM, reduce the GRUB menu wait time and show some boot messages for next boot with:
printf 'GRUB_TIMEOUT=1\nGRUB_CMDLINE_LINUX_DEFAULT=""\n' | sudo tee -a /etc/default/grub
sudo update-grub
TODO clipboard sharing:
Tried -spice port=5930,disable-ticketing + remote-viewer spice://127.0.0.1:5930, and spice-vdagent is pre-installed on guest, but no success.
The root cause of the mess is that QEMU devs seem more focused on non-interactive usage, rather than implementing things like this reliably and therefore killing VirtualBox once and for all: https://bugs.launchpad.net/qemu/+bug/614958
TODO: host 3D acceleration. Still with SPICE and QXL, glxgears gives 1k FPS, and the exact same with regular SDL. But on host __GL_SYNC_TO_VBLANK=0 vblank_mode=0 glxgears gives 20k FPS, so I'm guessing graphics were not accelerated?
Related: How to install Ubuntu 13.10 Desktop in QEMU?
Prebuilt bootable images
If you want an image that boots without the need for any interaction on the installer, see: https://askubuntu.com/questions/281763/is-there-any-prebuilt-qemu-ubuntu-image32bit-online