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

Re: [libvirt] [PATCH REPOST 3/5] admin: Introduce virAdmServerGetClientProcessingControls



On 11.05.2016 12:20, Erik Skultety wrote:
> Enable retrieval of the number of maximum clients connected to all sockets
> combined as well as the number of maximum clients waiting for authentication,
> in order to be successfully connected. These are the attributes configurable
> through libvirtd.conf, however, it could be handy to not only know values for
> these limits, but also the values for the current number of clients
> connected and number of clients currently waiting for authentication which are
> changing dynamically. This API does both, retrieves the limits as well as the
> current dynamic values.
> 
> Signed-off-by: Erik Skultety <eskultet redhat com>
> ---
>  daemon/admin.c                  | 45 +++++++++++++++++++++++++++++++++++++++++
>  daemon/admin_server.c           | 41 +++++++++++++++++++++++++++++++++++++
>  daemon/admin_server.h           |  5 +++++
>  include/libvirt/libvirt-admin.h |  5 +++++
>  src/admin/admin_protocol.x      | 19 ++++++++++++++++-
>  src/admin/admin_remote.c        | 39 +++++++++++++++++++++++++++++++++++
>  src/admin_protocol-structs      | 11 ++++++++++
>  src/libvirt-admin.c             | 43 +++++++++++++++++++++++++++++++++++++++
>  src/libvirt_admin_private.syms  |  2 ++
>  src/libvirt_admin_public.syms   |  1 +
>  10 files changed, 210 insertions(+), 1 deletion(-)
> 
> diff --git a/daemon/admin.c b/daemon/admin.c
> index 03774d7..819b1c0 100644
> --- a/daemon/admin.c
> +++ b/daemon/admin.c
> @@ -301,4 +301,49 @@ adminDispatchClientGetInfo(virNetServerPtr server ATTRIBUTE_UNUSED,
>      virObjectUnref(srv);
>      return rv;
>  }
> +
> +static int
> +adminDispatchServerGetClientProcessingControls(virNetServerPtr server ATTRIBUTE_UNUSED,

Ugrh. I couldn't say it in one breath. How about
virAdminServerGetClientLimits? Yeah, not much shorter.

> +                                               virNetServerClientPtr client,
> +                                               virNetMessagePtr msg ATTRIBUTE_UNUSED,
> +                                               virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED,
> +                                               admin_server_get_client_processing_controls_args *args,
> +                                               admin_server_get_client_processing_controls_ret *ret)
> +{
> +    int rv = -1;
> +    virNetServerPtr srv = NULL;
> +    virTypedParameterPtr params = NULL;
> +    int nparams = 0;
> +    struct daemonAdmClientPrivate *priv =
> +        virNetServerClientGetPrivateData(client);
> +
> +    if (!(srv = virNetDaemonGetServer(priv->dmn, args->srv.name)))
> +        goto cleanup;
> +
> +    if (adminServerGetClientProcessingControls(srv, &params, &nparams,
> +                                               args->flags) < 0)
> +        goto cleanup;
> +
> +    if (nparams > ADMIN_SERVER_CLIENT_PROCESSING_CONTROLS_MAX) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("Number of client processing parameters %d exceeds "
> +                         "max allowed limit: %d"), nparams,
> +                       ADMIN_SERVER_CLIENT_PROCESSING_CONTROLS_MAX);
> +        goto cleanup;
> +    }
> +
> +    if (virTypedParamsSerialize(params, nparams,
> +                                (virTypedParameterRemotePtr *) &ret->params.params_val,
> +                                &ret->params.params_len, 0) < 0)
> +        goto cleanup;
> +
> +    rv = 0;
> + cleanup:
> +    if (rv < 0)
> +        virNetMessageSaveError(rerr);
> +
> +    virTypedParamsFree(params, nparams);
> +    virObjectUnref(srv);
> +    return rv;
> +}
>  #include "admin_dispatch.h"
> diff --git a/daemon/admin_server.c b/daemon/admin_server.c
> index 9f40688..79437a1 100644
> --- a/daemon/admin_server.c
> +++ b/daemon/admin_server.c
> @@ -311,3 +311,44 @@ int adminClientClose(virNetServerClientPtr client,
>      virNetServerClientClose(client);
>      return 0;
>  }
> +
> +int
> +adminServerGetClientProcessingControls(virNetServerPtr srv,
> +                                       virTypedParameterPtr *params,
> +                                       int *nparams,
> +                                       unsigned int flags)
> +{
> +    int ret = -1;
> +    int maxparams = 0;
> +    virTypedParameterPtr tmpparams = NULL;
> +
> +    virCheckFlags(0, -1);
> +
> +    if (virTypedParamsAddUInt(&tmpparams, nparams, &maxparams,
> +                              VIR_SERVER_CLIENTS_MAX,
> +                              virNetServerGetMaxClients(srv)) < 0)
> +        goto cleanup;
> +
> +    if (virTypedParamsAddUInt(&tmpparams, nparams, &maxparams,
> +                              VIR_SERVER_CLIENTS_CURRENT,
> +                              virNetServerGetCurrentClients(srv)) < 0)
> +        goto cleanup;
> +
> +    if (virTypedParamsAddUInt(&tmpparams, nparams, &maxparams,
> +                              VIR_SERVER_CLIENTS_UNAUTH_MAX,
> +                              virNetServerGetMaxUnauthClients(srv)) < 0)
> +        goto cleanup;
> +
> +    if (virTypedParamsAddUInt(&tmpparams, nparams, &maxparams,
> +                              VIR_SERVER_CLIENTS_UNAUTH_CURRENT,
> +                              virNetServerGetCurrentUnauthClients(srv)) < 0)
> +        goto cleanup;


Well, all of these are type of size_t in our implementation. Should we
make these ULL?

> +
> +    *params = tmpparams;
> +    tmpparams = NULL;
> +    ret = 0;
> +
> + cleanup:
> +    virTypedParamsFree(tmpparams, *nparams);
> +    return ret;
> +}


> diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
> index 9d5e5b9..0b317c5 100644
> --- a/src/libvirt-admin.c
> +++ b/src/libvirt-admin.c
> @@ -1000,3 +1000,46 @@ int virAdmClientClose(virAdmClientPtr client,
>      virDispatchError(NULL);
>      return -1;
>  }
> +
> +/**
> + * virAdmServerGetClientProcessingControls:
> + * @srv: a valid server object reference
> + * @params: pointer to client processing controls object
> + *          (return value, allocated automatically)
> + * @nparams: pointer to number of parameters returned in @params
> + * @flags: extra flags; not used yet, so callers should always pass 0
> + *
> + * Retrieve client processing controls. These include:
> + *  - current number of clients connected to @srv,
> + *  - maximum number of clients connected to @srv,
> + *  - current number of clients connected to @srv waiting for authentication,
> + *  - maximum number of clients connected to @srv that can be wainting for
> + *  authentication.
> + *
> + * Returns 0 on success, allocating @params to size returned in @nparams, or
> + * -1 in case of an error. Caller is responsible for deallocating @params.
> + */
> +int
> +virAdmServerGetClientProcessingControls(virAdmServerPtr srv,
> +                                        virTypedParameterPtr *params,
> +                                        int *nparams,
> +                                        unsigned int flags)
> +{
> +    int ret = -1;
> +
> +    VIR_DEBUG("srv=%p, flags=%x", srv, flags);
> +    virResetLastError();
> +
> +    virCheckAdmServerGoto(srv, error);
> +    virCheckFlagsGoto(0, error);

Drop this check ^^

> +
> +    if ((ret = remoteAdminServerGetClientProcessingControls(srv, params,
> +                                                            nparams,
> +                                                            flags)) < 0)
> +        goto error;
> +
> +    return ret;
> + error:
> +    virDispatchError(NULL);
> +    return -1;
> +}
> diff --git a/src/libvirt_admin_private.syms b/src/libvirt_admin_private.syms
> index e55b91e..9a30ff5 100644
> --- a/src/libvirt_admin_private.syms
> +++ b/src/libvirt_admin_private.syms
> @@ -15,6 +15,8 @@ xdr_admin_connect_list_servers_ret;
>  xdr_admin_connect_lookup_server_args;
>  xdr_admin_connect_lookup_server_ret;
>  xdr_admin_connect_open_args;
> +xdr_admin_server_get_client_processing_controls_args;
> +xdr_admin_server_get_client_processing_controls_ret;
>  xdr_admin_server_get_threadpool_parameters_args;
>  xdr_admin_server_get_threadpool_parameters_ret;
>  xdr_admin_server_list_clients_args;
> diff --git a/src/libvirt_admin_public.syms b/src/libvirt_admin_public.syms
> index 57df1f4..59b0160 100644
> --- a/src/libvirt_admin_public.syms
> +++ b/src/libvirt_admin_public.syms
> @@ -35,4 +35,5 @@ LIBVIRT_ADMIN_1.3.0 {
>          virAdmServerListClients;
>          virAdmClientGetInfo;
>          virAdmClientClose;
> +        virAdmServerGetClientProcessingControls;
>  };
> 

Michal


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