[libvirt] [PATCH 11/12] domain_event: Introduce function virDomainEventGetName

Peter Krempa pkrempa at redhat.com
Fri May 4 10:28:12 UTC 2018


On Fri, May 04, 2018 at 17:25:32 +0800, Lin Ma wrote:
> It will be used in next patch for event name completion.
> 
> Signed-off-by: Lin Ma <lma at suse.com>
> ---
>  src/conf/domain_event.c  | 62 ++++++++++++++++++++++++++++++++++++++++++++++++
>  src/conf/domain_event.h  |  3 +++
>  src/libvirt_private.syms |  1 +
>  3 files changed, 66 insertions(+)
> 
> diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
> index 97520706c9..f8bd457b34 100644
> --- a/src/conf/domain_event.c
> +++ b/src/conf/domain_event.c
> @@ -1968,6 +1968,68 @@ virDomainEventDispatchDefaultFunc(virConnectPtr conn,
>  }
>  
>  
> +const char *
> +virDomainEventGetName(int event)
> +{
> +    virResetLastError();

This should not be necessary. This function shall not touch the error
since it does not report any. The caller needs to handle it properly.

> +
> +    switch (event) {

Typecast event to the proper type so that compiler moans when new events
are added.

> +    case VIR_DOMAIN_EVENT_ID_LIFECYCLE:
> +        return VIR_DOMAIN_EVENT_LIFECYCLE;
> +    case VIR_DOMAIN_EVENT_ID_REBOOT:
> +        return VIR_DOMAIN_EVENT_REBOOT;

[...]
-------------- 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/20180504/34c5bc74/attachment-0001.sig>


More information about the libvir-list mailing list