mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-12-15 08:23:48 +03:00
event: Add bindings for agent lifecycle event
Also add the example.
This commit is contained in:
@@ -6566,6 +6566,61 @@ libvirt_virConnectDomainEventTunableCallback(virConnectPtr conn ATTRIBUTE_UNUSED
|
||||
}
|
||||
#endif /* LIBVIR_CHECK_VERSION(1, 2, 9) */
|
||||
|
||||
#if LIBVIR_CHECK_VERSION(1, 2, 11)
|
||||
static int
|
||||
libvirt_virConnectDomainEventAgentLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
virDomainPtr dom,
|
||||
int state,
|
||||
int reason,
|
||||
void *opaque)
|
||||
{
|
||||
PyObject *pyobj_cbData = (PyObject*)opaque;
|
||||
PyObject *pyobj_dom;
|
||||
PyObject *pyobj_ret = NULL;
|
||||
PyObject *pyobj_conn;
|
||||
PyObject *dictKey;
|
||||
int ret = -1;
|
||||
|
||||
LIBVIRT_ENSURE_THREAD_STATE;
|
||||
|
||||
if (!(dictKey = libvirt_constcharPtrWrap("conn")))
|
||||
goto cleanup;
|
||||
pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
|
||||
Py_DECREF(dictKey);
|
||||
|
||||
/* Create a python instance of this virDomainPtr */
|
||||
virDomainRef(dom);
|
||||
if (!(pyobj_dom = libvirt_virDomainPtrWrap(dom))) {
|
||||
virDomainFree(dom);
|
||||
goto cleanup;
|
||||
}
|
||||
Py_INCREF(pyobj_cbData);
|
||||
|
||||
/* Call the Callback Dispatcher */
|
||||
pyobj_ret = PyObject_CallMethod(pyobj_conn,
|
||||
(char*)"_dispatchDomainEventAgentLifecycleCallback",
|
||||
(char*)"OiiO",
|
||||
pyobj_dom, state, reason, pyobj_cbData);
|
||||
|
||||
Py_DECREF(pyobj_cbData);
|
||||
Py_DECREF(pyobj_dom);
|
||||
|
||||
cleanup:
|
||||
if (!pyobj_ret) {
|
||||
DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
|
||||
PyErr_Print();
|
||||
} else {
|
||||
Py_DECREF(pyobj_ret);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
LIBVIRT_RELEASE_THREAD_STATE;
|
||||
return ret;
|
||||
|
||||
}
|
||||
#endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
|
||||
|
||||
|
||||
static PyObject *
|
||||
libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject *self,
|
||||
PyObject *args)
|
||||
@@ -6658,6 +6713,11 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject *self,
|
||||
cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTunableCallback);
|
||||
break;
|
||||
#endif /* LIBVIR_CHECK_VERSION(1, 2, 9) */
|
||||
#if LIBVIR_CHECK_VERSION(1, 2, 11)
|
||||
case VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE:
|
||||
cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventAgentLifecycleCallback);
|
||||
break;
|
||||
#endif /* LIBVIR_CHECK_VERSION(1, 2, 11) */
|
||||
case VIR_DOMAIN_EVENT_ID_LAST:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user