[libvirt] [v3 26/32] Added Network events API and virNetworkEventLifecycle.

Daniel P. Berrange berrange at redhat.com
Tue Dec 10 13:30:03 UTC 2013


On Mon, Dec 02, 2013 at 05:39:44PM +0100, Cédric Bosdonnat wrote:
> Put all network-events related code in src/conf/network_event.[ch]
> ---
>  include/libvirt/libvirt.h.in |  77 ++++++++++++++++++++++
>  src/Makefile.am              |   5 ++
>  src/conf/network_event.c     | 152 +++++++++++++++++++++++++++++++++++++++++++
>  src/conf/network_event.h     |  50 ++++++++++++++
>  src/conf/object_event.c      |   6 ++
>  src/conf/object_event.h      |   1 +
>  src/driver.h                 |  14 ++++
>  src/libvirt.c                | 125 +++++++++++++++++++++++++++++++++++
>  src/libvirt_private.syms     |   2 +
>  src/libvirt_public.syms      |   7 ++
>  10 files changed, 439 insertions(+)
>  create mode 100644 src/conf/network_event.c
>  create mode 100644 src/conf/network_event.h
> 

> diff --git a/src/conf/network_event.c b/src/conf/network_event.c
> new file mode 100644
> index 0000000..fb17837
> --- /dev/null
> +++ b/src/conf/network_event.c

> +/**
> + * virNetworkEventStateRegisterID:
> + * @conn: connection to associate with callback
> + * @state: object event state
> + * @net: network to filter on or NULL for all networks
> + * @eventID: ID of the event type to register for
> + * @cb: function to add to event
> + * @opaque: data blob to pass to callback
> + * @freecb: callback to free @opaque
> + * @callbackID: filled with callback ID
> + *
> + * Register the function @callbackID with connection @conn,
> + * from @state, for events of type @eventID.
> + *
> + * Returns: the number of callbacks now registered, or -1 on error
> + */
> +int
> +virNetworkEventStateRegisterID(virConnectPtr conn,
> +                              virObjectEventStatePtr state,
> +                              virNetworkPtr net,
> +                              int eventID,
> +                              virConnectObjectEventGenericCallback cb,
> +                              void *opaque,
> +                              virFreeCallback freecb,
> +                              int *callbackID)
> +{
> +    if (net)
> +        return virObjectEventStateRegisterID(conn, state,
> +                                             net->uuid, net->name, 0, eventID,
> +                                             cb, opaque, freecb, callbackID);
> +    else
> +        return virObjectEventStateRegisterID(conn, state,
> +                                             NULL, NULL, 0, eventID,
> +                                             cb, opaque, freecb, callbackID);
> +}

Why not just have this method add in VIR_EVENT_NAMESPACE_NETWORK
to eventID, then no other code in libvirt would ever need to know
anything about the namespace values.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list