Improve shutdown detection
Improve shutdown detection

Detecting when a guest has independently shutdown via libvirt calls turns
out to be a little dicey.  During testing we have seen a variety of exceptions
depending on when exactly in the guest teardown process the libvirt call is
made.  This patch changes the approach from checking against a growing
whitelist of exceptions to waiting until teardown/destroy is complete and
a single known good exception is thrown.  That is, a libvirt exception where:

e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN

We have been testing with a slightly different version of this patch in the
Aeolus project.  This has proven rock solid over about a month of testing.

This patch simply checks more frequently for the "correct" exception while
allowing up to 10 seconds for it to occur (instead of 5).

clalancette: I've cleaned up the patch a bit and made some
minor changes to it.  The basic idea is still Ian's.

Signed-off-by: Chris Lalancette <281cd07d7578d97c83271fbbf2faddb83ab3791c@gmail.com>

nullr0ute/oz,NeilBryant/oz,moofrank/oz,mgagne/oz,mgagne/oz,clalancette/oz,cernops/oz,ndonegan/oz,nullr0ute/oz,imcleod/oz,cernops/oz,ndonegan/oz,imcleod/oz,NeilBryant/oz,clalancette/oz,moofrank/oz