[libvirt] [PATCH] Added python binding for the new network events API

Eric Blake eblake at redhat.com
Mon Dec 2 19:08:04 UTC 2013


On 11/29/2013 08:27 AM, Cédric Bosdonnat wrote:
> This patch was extracted from the network events feature patch to fit the
> new libvirt-python repository.

Thanks for remembering this.  In the future, if you will do a one-time:

 git config format.subjectprefix "python PATCH"

then it will be more obvious which repo your patch applies to.


> +
> +    def networkEventDeregisterAny(self, callbackID):
> +        """Removes a Network Event Callback. De-registering for a
> +           network callback will disable delivery of this event type """

Trailing space inside the doc text looks odd

> +libvirt_virConnectNetworkEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
> +                                               virNetworkPtr net,
> +                                               int event,
> +                                               void *opaque)
> +{
> +    PyObject *pyobj_cbData = (PyObject*)opaque;
> +    PyObject *pyobj_net;
> +    PyObject *pyobj_ret;
> +    PyObject *pyobj_conn;
> +    PyObject *dictKey;
> +    int ret = -1;
> +
> +    LIBVIRT_ENSURE_THREAD_STATE;
> +
> +    /* Create a python instance of this virNetworkPtr */
> +    virNetworkRef(net);
> +    pyobj_net = libvirt_virNetworkPtrWrap(net);
> +    Py_INCREF(pyobj_cbData);
> +
> +    dictKey = libvirt_constcharPtrWrap("conn");
> +    pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);

Copy and paste, but can't dictKey be NULL if libvirt_constcharPtrWrap()
hit an OOM error, in which case PyDict_GetItem() will crash?


> +static PyObject *
> +libvirt_virConnectNetworkEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self,
> +                                         PyObject * args)

Style: We put the * flush with the variable name, and usually place
attributes after rather than before:

(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131202/ba563e81/attachment-0001.sig>


More information about the libvir-list mailing list