[libvirt] [PATCH v3 03/13] Introduce virConnectSetKeepAlive
Daniel P. Berrange
berrange at redhat.com
Tue Oct 18 09:31:28 UTC 2011
On Wed, Oct 12, 2011 at 07:16:21AM +0200, Jiri Denemark wrote:
> virConnectSetKeepAlive public API can be used by a client connecting to
> remote server to start using keepalive protocol. The API is handled
> directly by remote driver and not transmitted over the wire to the
> server.
> ---
> Notes:
> Version 3:
> - remove virConnectAllowKeepAlive
> - rename virConnectStartKeepAlive as virConnectSetKeepAlive
> - add a note to virEventRegisterImpl that running the event loop
> is mandatory once registered
>
> Version 2:
> - no change
>
> include/libvirt/libvirt.h.in | 4 +++
> src/driver.h | 5 ++++
> src/libvirt.c | 54 ++++++++++++++++++++++++++++++++++++++++++
> src/libvirt_internal.h | 10 ++++++-
> src/libvirt_public.syms | 1 +
> src/util/event.c | 6 ++--
> 6 files changed, 75 insertions(+), 5 deletions(-)
>
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index c991dfc..ad59804 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -3235,6 +3235,10 @@ typedef struct _virTypedParameter virMemoryParameter;
> */
> typedef virMemoryParameter *virMemoryParameterPtr;
>
> +int virConnectSetKeepAlive(virConnectPtr conn,
> + int interval,
> + unsigned int count);
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/src/driver.h b/src/driver.h
> index b899d0e..c1223c1 100644
> --- a/src/driver.h
> +++ b/src/driver.h
> @@ -735,6 +735,10 @@ typedef int
> (*virDrvDomainBlockPull)(virDomainPtr dom, const char *path,
> unsigned long bandwidth, unsigned int flags);
>
> +typedef int
> + (*virDrvSetKeepAlive)(virConnectPtr conn,
> + int interval,
> + unsigned int count);
>
> /**
> * _virDriver:
> @@ -893,6 +897,7 @@ struct _virDriver {
> virDrvDomainGetBlockJobInfo domainGetBlockJobInfo;
> virDrvDomainBlockJobSetSpeed domainBlockJobSetSpeed;
> virDrvDomainBlockPull domainBlockPull;
> + virDrvSetKeepAlive setKeepAlive;
> };
>
> typedef int
> diff --git a/src/libvirt.c b/src/libvirt.c
> index f07c720..23602f7 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -16817,3 +16817,57 @@ error:
> virDispatchError(dom->conn);
> return -1;
> }
> +
> +/**
> + * virConnectSetKeepAlive:
> + * @conn: pointer to a hypervisor connection
> + * @interval: number of seconds of inactivity before a keepalive message is sent
> + * @count: number of messages that can be sent in a row
> + *
> + * Start sending keepalive messages after interval second of inactivity and
> + * consider the connection to be broken when no response is received after
> + * count keepalive messages sent in a row. In other words, sending count + 1
> + * keepalive message results in closing the connection.
> + *
> + * Note: client has to implement and run event loop to be able to use keepalive
> + * messages. Failure to do so may result in connections being closed
> + * unexpectedly.
It is probably obvious, but we should document that if either interval or
count are zero, then keepalives are disabled.
ACK to patch
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 :|
More information about the libvir-list
mailing list