qemu: Set up EMULATOR thread and cpuset.mems before exec()-ing qemu
qemu: Set up EMULATOR thread and cpuset.mems before exec()-ing qemu

It's funny how this went unnoticed for such a long time. Long
story short, if a domain is configured with
VIR_DOMAIN_NUMATUNE_MEM_STRICT libvirt doesn't really honour
that. This is because of 7e72ac787848 after which libvirt allowed
qemu to allocate memory just anywhere and only after that it used
some magic involving cpuset.memory_migrate and cpuset.mems to
move the memory to desired NUMA nodes. This was done in order to
work around some KVM bug where KVM would fail if there wasn't a
DMA zone available on the NUMA node. Well, while the work around
might stopped libvirt tickling the KVM bug it also caused a bug
on libvirt side: if there is not enough memory on configured NUMA
node(s) then any attempt to start a domain must fail. Because of
the way we play with guest memory domains can start just happily.

The solution is to move the child we've just forked into emulator
cgroup, set up cpuset.mems and exec() qemu only after that.

This basically reverts 7e72ac787848b7434c9 which was a workaround
for kernel bug. This bug was apparently fixed because I've tested
this successfully with recent kernel.

Signed-off-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>
Reviewed-by: Martin Kletzander <e82f23e74d43760279ebcc505dac4ae70d5627d0@redhat.com>

jardasgit/libvirt,nertpinx/libvirt,eskultety/libvirt,fabianfreyer/libvirt,andreabolognani/libvirt,fabianfreyer/libvirt,zippy2/libvirt,jfehlig/libvirt,nertpinx/libvirt,jfehlig/libvirt,olafhering/libvirt,libvirt/libvirt,zippy2/libvirt,jardasgit/libvirt,andreabolognani/libvirt,jardasgit/libvirt,crobinso/libvirt,olafhering/libvirt,olafhering/libvirt,nertpinx/libvirt,jfehlig/libvirt,zippy2/libvirt,andreabolognani/libvirt,zippy2/libvirt,libvirt/libvirt,jardasgit/libvirt,nertpinx/libvirt,eskultety/libvirt,andreabolognani/libvirt,nertpinx/libvirt,jardasgit/libvirt,fabianfreyer/libvirt,eskultety/libvirt,olafhering/libvirt,eskultety/libvirt,eskultety/libvirt,fabianfreyer/libvirt,libvirt/libvirt,jfehlig/libvirt,libvirt/libvirt,fabianfreyer/libvirt,crobinso/libvirt,andreabolognani/libvirt,crobinso/libvirt,crobinso/libvirt