[libvirt] How to differentiate creation from migration?

Hi, I work on a project that makes use of libvirt (called libvirt-cim) and we created an algorithm to detect when a new machine is created. However, I need to filter the ones created by the migration operation. Does libvirt provides a way to distinguish a machine created by 'migrate' command from a machine created by the 'define' command (virDomainDefineXML API call)? Thanks in advance, Richard Maciel

On Wed, Mar 10, 2010 at 11:40:44AM -0300, Richard Maciel wrote:
Hi,
I work on a project that makes use of libvirt (called libvirt-cim) and we created an algorithm to detect when a new machine is created. However, I need to filter the ones created by the migration operation.
Does libvirt provides a way to distinguish a machine created by 'migrate' command from a machine created by the 'define' command (virDomainDefineXML API call)?
I think that if you register for domain lifetime events then you will get this informations as part of the details, but asynchronously http://libvirt.org/html/libvirt-libvirt.html#virConnectDomainEventRegister Also see Dan Berrange post from last week about event extensions. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Wed, Mar 10, 2010 at 04:11:30PM +0100, Daniel Veillard wrote:
On Wed, Mar 10, 2010 at 11:40:44AM -0300, Richard Maciel wrote:
Hi,
I work on a project that makes use of libvirt (called libvirt-cim) and we created an algorithm to detect when a new machine is created. However, I need to filter the ones created by the migration operation.
Does libvirt provides a way to distinguish a machine created by 'migrate' command from a machine created by the 'define' command (virDomainDefineXML API call)?
I think that if you register for domain lifetime events then you will get this informations as part of the details, but asynchronously
http://libvirt.org/html/libvirt-libvirt.html#virConnectDomainEventRegister
Yes, this will give you an event VIR_DOMAIN_EVENT_STARTED with a detail field containing one of the following VIR_DOMAIN_EVENT_STARTED_BOOTED = 0, /* Normal startup from boot */ VIR_DOMAIN_EVENT_STARTED_MIGRATED = 1, /* Incoming migration from another host */ VIR_DOMAIN_EVENT_STARTED_RESTORED = 2, /* Restored from a state file */ NB, we do not require that all drivers support the detail field. At this time, only KVM/QEMU driver will fill in the detail field. Others (Xen, etc) will always set VIR_DOMAIN_EVENT_STARTED_BOOTED Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Richard Maciel