'Receives lifecycle events from libvirt.
NB: this method is executing in a native thread, not
an eventlet coroutine. It can only invoke other libvirt
APIs, or use self._queue_event(). Any use of logging APIs
in particular is forbidden.'

@staticmethod
def _event_lifecycle_callback(conn, dom, event, detail, opaque):

    self = opaque
    uuid = dom.UUIDString()
    transition = None
    if (event == libvirt.VIR_DOMAIN_EVENT_STOPPED):
        transition = virtevent.EVENT_LIFECYCLE_STOPPED
    elif (event == libvirt.VIR_DOMAIN_EVENT_STARTED):
        transition = virtevent.EVENT_LIFECYCLE_STARTED
    elif (event == libvirt.VIR_DOMAIN_EVENT_SUSPENDED):
        transition = virtevent.EVENT_LIFECYCLE_PAUSED
    elif (event == libvirt.VIR_DOMAIN_EVENT_RESUMED):
        transition = virtevent.EVENT_LIFECYCLE_RESUMED
    if (transition is not None):
        self._queue_event(virtevent.LifecycleEvent(uuid, transition))
