CA-40134: when looking up a domid, always look up the domain by uuid rather than relying on the value in the master's database (which could be out of sync).
CA-40134: when looking up a domid, always look up the domain by uuid rather than relying on the value in the master's database (which could be out of sync).

In particular if the master is suddenly powercycled then recent domid updates might be lost. This results in VMs which are impossible to shutdown.

Looking up the domain by uuid should be strictly better than using the master's version: both are moving targets (eg over migrate) and so we already rely on the per-VM lock to protect (most) accesses.

The only problem is the code is slightly inefficient: it still has to contact the master to look up the VM's uuid and then has to list all domains on the host to build up a table of uuid -> domid. This can be improved later.

Signed-off-by: David Scott <63c9eb0ea83039690fefa11afe17873ba8278a56@eu.citrix.com>

ravippandey/xen-api,thomassa/xen-api,robertbreker/xen-api,agimofcarmen/xen-api,cheng-z/xen-api,euanh/xen-api,Frezzle/xen-api,cheng--zhang/xen-api,Frezzle/xen-api,vasilenkomike/xen-api,Frezzle/xen-api,guard163/xen-api,robertbreker/xen-api,cheng-z/xen-api,robertbreker/xen-api,djs55/xen-api,huizh/xen-api,huizh/xen-api,anoobs/xen-api,simonjbeaumont/xen-api,cheng--zhang/xen-api,robertbreker/xen-api,vasilenkomike/xen-api,cheng--zhang/xen-api,ravippandey/xen-api,srowe/xen-api,agimofcarmen/xen-api,agimofcarmen/xen-api,salvocambria/xen-api,cheng-z/xen-api,euanh/xen-api,simonjbeaumont/xen-api,jjd27/xen-api,srowe/xen-api,salvocambria/xen-api,euanh/xen-api,rafalmiel/xen-api,robertbreker/xen-api,anoobs/xen-api,rafalmiel/xen-api,thomassa/xen-api,guard163/xen-api,ravippandey/xen-api,guard163/xen-api,agimofcarmen/xen-api,cheng-z/xen-api,thomassa/xen-api,cheng--zhang/xen-api,anoobs/xen-api,djs55/xen-api,koushikcgit/xen-api,rafalmiel/xen-api,rafalmiel/xen-api,cheng--zhang/xen-api,rafalmiel/xen-api,thomassa/xen-api,koushikcgit/xen-api,jjd27/xen-api,salvocambria/xen-api,huizh/xen-api,thomassa/xen-api,huizh/xen-api,thomassa/xen-api,euanh/xen-api,srowe/xen-api,anoobs/xen-api,vasilenkomike/xen-api,djs55/xen-api,simonjbeaumont/xen-api,koushikcgit/xen-api,Frezzle/xen-api,cheng-z/xen-api,salvocambria/xen-api,ravippandey/xen-api,Frezzle/xen-api,guard163/xen-api,jjd27/xen-api,cheng--zhang/xen-api,salvocambria/xen-api,agimofcarmen/xen-api,ravippandey/xen-api,koushikcgit/xen-api,huizh/xen-api,jjd27/xen-api,cheng--zhang/xen-api,koushikcgit/xen-api,anoobs/xen-api,guard163/xen-api,cheng-z/xen-api,djs55/xen-api,srowe/xen-api,djs55/xen-api,robertbreker/xen-api,simonjbeaumont/xen-api,jjd27/xen-api,anoobs/xen-api,agimofcarmen/xen-api,rafalmiel/xen-api,ravippandey/xen-api,euanh/xen-api,srowe/xen-api,simonjbeaumont/xen-api,guard163/xen-api,euanh/xen-api,huizh/xen-api,vasilenkomike/xen-api,vasilenkomike/xen-api,koushikcgit/xen-api,jjd27/xen-api,vasilenkomike/xen-api,cheng-z/xen-api,salvocambria/xen-api,simonjbeaumont/xen-api,djs55/xen-api