Add missing impl of virNetworkListAllPorts
[libvirt-python/ericb.git] / libvirt-qemu-override.py
blob265a252025d71f51f04ad4d59cd93791dffb33d7
1 # Manually written part of python bindings for libvirt-qemu
3 def _dispatchQemuMonitorEventCallback(conn, dom, event, seconds, micros, details, cbData):
4 """Dispatches events to python user qemu monitor event callbacks
5 """
6 cb = cbData["cb"]
7 opaque = cbData["opaque"]
9 cb(conn, libvirt.virDomain(conn, _obj=dom), event, seconds, micros, details, opaque)
10 return 0
12 def qemuMonitorEventDeregister(conn, callbackID):
13 """Removes a qemu monitor event callback. De-registering for a callback
14 will disable delivery of this event type"""
15 try:
16 ret = libvirtmod_qemu.virConnectDomainQemuMonitorEventDeregister(conn._o, callbackID)
17 if ret == -1: raise libvirt.libvirtError ('virConnectDomainQemuMonitorEventDeregister() failed')
18 del conn.qemuMonitorEventCallbackID[callbackID]
19 except AttributeError:
20 pass
22 def qemuMonitorEventRegister(conn, dom, event, cb, opaque, flags=0):
23 """Adds a qemu monitor event callback. Registering for a monitor
24 callback will enable delivery of the events"""
25 if not hasattr(conn, 'qemuMonitorEventCallbackID'):
26 conn.qemuMonitorEventCallbackID = {}
27 cbData = { "cb": cb, "conn": conn, "opaque": opaque }
28 if dom is None:
29 ret = libvirtmod_qemu.virConnectDomainQemuMonitorEventRegister(conn._o, None, event, cbData, flags)
30 else:
31 ret = libvirtmod_qemu.virConnectDomainQemuMonitorEventRegister(conn._o, dom._o, event, cbData, flags)
32 if ret == -1:
33 raise libvirt.libvirtError ('virConnectDomainQemuMonitorEventRegister() failed')
34 conn.qemuMonitorEventCallbackID[ret] = opaque
35 return ret