libxl: Fix domain shutdown
libxl: Fix domain shutdown

Commit fa30ee04a2 caused a regression in normal domain shutown.
Initiating a shutdown from within the domain or via 'virsh shutdown'
does cause the guest OS running in the domain to shutdown, but libvirt
never reaps the domain so it is always shown in a running state until
calling 'virsh destroy'.

The shutdown thread is also an internal user of the driver shutdown
machinery and eventually calls libxlDomainDestroyInternal where
the ignoreDeathEvent inhibitor is set, but running in a thread
introduces the possibility of racing with the death event from
libxl. This can be prevented by setting ignoreDeathEvent before
running the shutdown thread.

An additional improvement is to handle the destroy event synchronously
instead of spawning a thread. The time consuming aspects of destroying
a domain have been completed when the destroy event is delivered.

Signed-off-by: Jim Fehlig <39929b5b86d72d51fceac59b52303e3fe8a3083e@suse.com>
Reviewed-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>

libvirt/libvirt,crobinso/libvirt,zippy2/libvirt,libvirt/libvirt,crobinso/libvirt,jfehlig/libvirt,olafhering/libvirt,nertpinx/libvirt,zippy2/libvirt,zippy2/libvirt,olafhering/libvirt,libvirt/libvirt,crobinso/libvirt,jfehlig/libvirt,olafhering/libvirt,crobinso/libvirt,olafhering/libvirt,zippy2/libvirt,nertpinx/libvirt,jfehlig/libvirt,libvirt/libvirt,nertpinx/libvirt,nertpinx/libvirt,jfehlig/libvirt,nertpinx/libvirt