Groundwork for supporting multiple TCG contexts. Backports commit 44ded3d04821bec57407cc26a8b4db620da2be04 from qemu