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

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

 



On Tue, Jun 07, 2011 at 05:11:14PM +0800, Lai Jiangshan wrote:
> Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
> ---
>  src/libvirt.c |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 63 insertions(+), 0 deletions(-)
> 
> diff --git a/src/libvirt.c b/src/libvirt.c
> index cbe1926..112f690 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -26,6 +26,8 @@
>  #include <libxml/uri.h>
>  #include "getpass.h"
>  
> +#include <libvirt/virtkeys.h>
> +

If we move the enum/#define into libvirt.h, this extra
include won't be needed (at least not for this file)

>  #ifdef HAVE_WINSOCK2_H
>  # include <winsock2.h>
>  #endif
> @@ -6511,6 +6513,67 @@ 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 *keycodes,
> +                     unsigned int nkeycodes,
> +                     unsigned int flags)
> +{
> +    virConnectPtr conn;
> +    VIR_DOMAIN_DEBUG(domain, "codeset=%u,holdtime=%u,nkeycodes=%u,flags=%u",
> +                     codeset, holdtime, nkeycodes, flags);

Normal formatting is to include whitespace after each comma in
the debug messages, eg "codeset=%u, holdtime...."

> +
> +    virResetLastError();
> +
> +    if (nkeycodes == 0 || nkeycodes > MAX_SEND_KEY) {
> +        virLibDomainError(VIR_ERR_OPERATION_INVALID, __FUNCTION__);
> +        virDispatchError(NULL);
> +        return -1;
> +    }
> +
> +    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;
> +    }
> +
> +    conn = domain->conn;
> +
> +    if (conn->driver->domainSendKey) {
> +        int ret;
> +        ret = conn->driver->domainSendKey(domain, codeset, holdtime,
> +                                          keycodes, nkeycodes, flags);
> +        if (ret < 0)
> +            goto error;
> +        return ret;
> +    }
> +
> +    virLibConnError (VIR_ERR_NO_SUPPORT, __FUNCTION__);
> +
> +error:
> +    virDispatchError(domain->conn);
> +    return -1;
> +}
> +
> +/**
>   * virDomainSetVcpus:
>   * @domain: pointer to domain object, or NULL for Domain0
>   * @nvcpus: the new number of virtual CPUs for this domain

ACK, if the whitespace is fixed in the debug message

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 :|

--
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]