[libvirt] [PATCH 07/13] send-key: Implementing the public API

Matthias Bolte matthias.bolte at googlemail.com
Wed May 25 20:31:28 UTC 2011


2011/5/25 Lai Jiangshan <laijs at cn.fujitsu.com>:
> Signed-off-by: Lai Jiangshan <laijs at fujitsu.com>
> ---
>  src/libvirt.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 54 insertions(+), 0 deletions(-)
>
> diff --git a/src/libvirt.c b/src/libvirt.c
> index ff16c48..8246975 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -6080,6 +6080,60 @@ error:
>  }
>
>  /**
> + * virDomainSendKey:
> + * @domain:    pointer to domain object, or NULL for Domain0
> + * @codeset:   the code set of keycodes
> + * @holdtime:  the time (in millsecond) how long the keys will be held
> + * @nkeycodes: number of keycodes
> + * @keycodes:  array of keycodes
> + * @flags:     the flags for controlling behavior, pass 0 for now
> + *
> + * Send key to the guest
> + *
> + * Returns 0 in case of success, -1 in case of failure.
> + */
> +
> +int virDomainSendKey(virDomainPtr domain,
> +                     unsigned int codeset,
> +                     unsigned int holdtime,
> +                     unsigned int nkeycodes,
> +                     unsigned int *keycodes,
> +                     unsigned int flags)
> +{
> +    virConnectPtr conn;
> +    VIR_DOMAIN_DEBUG(domain, "flags=%u", flags);
> +
> +    virResetLastError();
> +
> +    if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
> +        virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
> +        virDispatchError(NULL);
> +        return -1;
> +    }
> +    if (domain->conn->flags & VIR_CONNECT_RO) {
> +        virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
> +        goto error;
> +    }
> +

Invalid argument checks are missing, For example keycodes should not
be NULL and nkeycodes should probably be larger than 0.

Also the comment about renaming an reordering of nkeycodes and
keycodes applies here too.

Matthias




More information about the libvir-list mailing list