[libvirt] [PATCH 1/5] storage: adding a skeleton for libvirt volume events.

Peter Krempa pkrempa at redhat.com
Mon May 28 07:30:46 UTC 2018


On Sun, May 27, 2018 at 16:25:35 -0300, Julio Faracco wrote:
> This commit adds some basic structures to support events for volumes as
> libvirt does with pools, networks, domains, secrets, etc. This commit
> add only lifecycle event to be included at create and delete actions.
> 
> Signed-off-by: Julio Faracco <jcfaracco at gmail.com>
> ---
>  include/libvirt/libvirt-storage.h |  86 ++++++++++++++++++++
>  src/libvirt-storage.c             | 125 ++++++++++++++++++++++++++++++
>  src/libvirt_public.syms           |   6 ++
>  3 files changed, 217 insertions(+)
> 
> diff --git a/include/libvirt/libvirt-storage.h b/include/libvirt/libvirt-storage.h
> index 413d9f6c4c..291742e5ef 100644
> --- a/include/libvirt/libvirt-storage.h
> +++ b/include/libvirt/libvirt-storage.h

[...]

> +/**
> + * virStorageVolEventLifecycleType:
> + *
> + * a virStorageVolEventLifecycleType is emitted during storage vol
> + * lifecycle events
> + */
> +typedef enum {
> +    VIR_STORAGE_VOL_EVENT_CREATED = 0,
> +    VIR_STORAGE_VOL_EVENT_DELETED = 1,

How do you plan to handle the case of a storage pool refresh for the
filesystem (directory?) pool. Currently if you refresh it libvirt
removes all volume metadata and re-detects everything. If a image file
was manually deleted from the directory it will vanish after the
refresh. This means that if you want to properly emit these you'll need
to add a diffing mechanism so that you can regenerate all the events.

> +
> +# ifdef VIR_ENUM_SENTINELS
> +    VIR_STORAGE_VOL_EVENT_LAST
> +# endif
> +} virStorageVolEventLifecycleType;
> +
> +/**
> + * virConnectStorageVolEventLifecycleCallback:
> + * @conn: connection object
> + * @vol: vol on which the event occurred
> + * @event: The specific virStorageVolEventLifeCycleType which occurred
> + * @detail: contains some details on the reason of the event.
> + * @opaque: application specified data
> + *
> + * This callback is called when a vol lifecycle action is performed, like start
> + * or stop.

There are no such actions for a volume.

> + *
> + * The callback signature to use when registering for an event of type
> + * VIR_STORAGE_VOL_EVENT_ID_LIFECYCLE with
> + * virConnectStorageVolEventRegisterAny()
> + */
> +typedef void (*virConnectStorageVolEventLifecycleCallback)(virConnectPtr conn,
> +                                                           virStorageVolPtr vol,
> +                                                           int event,
> +                                                           int detail,
> +                                                           void *opaque);
> +
>  #endif /* __VIR_LIBVIRT_STORAGE_H__ */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180528/c23ee955/attachment-0001.sig>


More information about the libvir-list mailing list