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
7 opaque
= cbData
["opaque"]
9 cb(conn
, libvirt
.virDomain(conn
, _obj
=dom
), event
, seconds
, micros
, details
, opaque
)
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"""
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:
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
}
29 ret
= libvirtmod_qemu
.virConnectDomainQemuMonitorEventRegister(conn
._o
, None, event
, cbData
, flags
)
31 ret
= libvirtmod_qemu
.virConnectDomainQemuMonitorEventRegister(conn
._o
, dom
._o
, event
, cbData
, flags
)
33 raise libvirt
.libvirtError ('virConnectDomainQemuMonitorEventRegister() failed')
34 conn
.qemuMonitorEventCallbackID
[ret
] = opaque