The following testcase worked for me with a preseeded install, giving me
the following results:

myDomainEventLifecycleCallback EVENT: Domain desktop(12) Shutdown
Finished

myDomainEventLifecycleCallback EVENT: Domain desktop(12) Stopped
Shutdown

myDomainEventLifecycleCallback EVENT: Domain desktop(13) Started Booted

Test script is as follows, borrowing some boilerplate from libvirt-
python/examples/event-test.py:

#!/usr/bin/env python

import sys
import getopt
import os
import libvirt
import select
import errno
import time
import threading

eventLoopThread = None

def virEventLoopNativeRun():
    while True:
        libvirt.virEventRunDefaultImpl()

def virEventLoopNativeStart():
    global eventLoopThread
    libvirt.virEventRegisterDefaultImpl()
    eventLoopThread = threading.Thread(target=virEventLoopNativeRun, 
name="libvirtEventLoop")
    eventLoopThread.setDaemon(True)
    eventLoopThread.start()

def domEventToString(event):
    domEventStrings = ( "Defined",
                     "Undefined",
                     "Started",
                     "Suspended",
                     "Resumed",
                     "Stopped",
                     "Shutdown",
                     "PMSuspended",
                     "Crashed",
    )
    return domEventStrings[event]
def myDomainEventLifecycleCallback (conn, dom, event, detail, opaque):
    print("myDomainEventLifecycleCallback EVENT: Domain %s(%s) %s %s\n" % 
(dom.name(), dom.ID(),
         domEventToString(event),
         domDetailToString(event, detail)))

def domDetailToString(event, detail):
    domEventStrings = (
        ( "Added", "Updated" ),
        ( "Removed", ),
        ( "Booted", "Migrated", "Restored", "Snapshot", "Wakeup" ),
        ( "Paused", "Migrated", "IOError", "Watchdog", "Restored", "Snapshot", 
"API error" ),
        ( "Unpaused", "Migrated", "Snapshot" ),
        ( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", 
"Snapshot"),
        ( "Finished", ),
        ( "Memory", "Disk" ),
        ( "Panicked", ),
        )
    return domEventStrings[event][detail]

def myDomainEventRebootCallback (conn, dom, event, detail, opaque):
    print("myDomainEventRebootCallback EVENT: Domain %s(%s) %s %s\n" % 
(dom.name(), dom.ID(),
         domEventToString(event),
         domDetailToString(event, detail)))

def myDomainEventCallback2 (conn, dom, event, detail, opaque):
    print("myDomainEventCallback2 EVENT: Domain %s(%s) %s %s\n" % (dom.name(), 
dom.ID(),
         domEventToString(event),
         domDetailToString(event, detail)))

run = True

def main():
    virEventLoopNativeStart()
    lv = libvirt.open("qemu:///system")
    lv.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_REBOOT, 
myDomainEventRebootCallback, None)
    lv.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_LIFECYCLE, 
myDomainEventLifecycleCallback, None)
    while run:
        time.sleep(1)
    print("done sleeping")


if __name__ == '__main__':
    exit(main())

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1329254

Title:
  VMs do not become inactive during the reboot on saucy  and later hosts

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1329254/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to