Backport qemu console fix from 4.0