[CentOS] How to prevent virtual machines running twice on the disk images?

Fri May 11 16:06:37 UTC 2012
Paul Heinlein <heinlein at madboa.com>

On Fri, 11 May 2012, Theo Band wrote:

> I use KVM on two identical centos5 hosts. [....]
> My question is, how can I prevent host A from starting a "shut off" 
> VM that actually has been migrated to host B? The VM could actually 
> be running on any another host. It could also have been crashed. The 
> most simple solution would be some sort of lock file placed next to 
> the disk image location, so seen by all hosts. But perhaps there is 
> another way of working with virt-manager that I am not aware of?

My way of dealing with that is to undefine the domain on host A after 
it's been moved to host B, e.g.,

   virsh migrate --live myvm remote://host-b
   virsh undefine myvm

The CentOS 6 version of virsh allows those operations to be combined:

   virsh migrate --live --persistent --undefinesource myvm ...

Paul Heinlein
heinlein at madboa.com
45°38' N, 122°6' W