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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2011/5/25 Lai Jiangshan <laijs@xxxxxxxxxxxxxx>:
> Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxx>
> ---
> Â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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]