Back-ported fixes for qemu build failures

A bunch of bugfixes to prevent qemu build failures with newer toolchains, as seen on latest Ubuntu 13.04 and Debian unstable. These are taken from upstream qemu git.