Backports commit 080c4eadcbbaf95a6fcc4668cf16e4580f2bfe11 from qemu
Backports commit f97b454e9e7f5d018d34b5ea85a66cff016bd3b7 from qemu