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(a)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,
+ 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, ¶ms, &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;
+
+ *params = tmpparams;
+ tmpparams = NULL;
+ ret = 0;
+
+ cleanup:
+ virTypedParamsFree(tmpparams, *nparams);
+ return ret;
+}
diff --git a/daemon/admin_server.h b/daemon/admin_server.h
index 2953e10..279e530 100644
--- a/daemon/admin_server.h
+++ b/daemon/admin_server.h
@@ -62,4 +62,9 @@ int adminClientGetInfo(virNetServerClientPtr client,
int adminClientClose(virNetServerClientPtr client,
unsigned int flags);
+int adminServerGetClientProcessingControls(virNetServerPtr srv,
+ virTypedParameterPtr *params,
+ int *nparams,
+ unsigned int flags);
+
#endif /* __LIBVIRTD_ADMIN_SERVER_H__ */
diff --git a/include/libvirt/libvirt-admin.h b/include/libvirt/libvirt-admin.h
index 245313e..bb290e3 100644
--- a/include/libvirt/libvirt-admin.h
+++ b/include/libvirt/libvirt-admin.h
@@ -393,6 +393,11 @@ int virAdmClientClose(virAdmClientPtr client, unsigned int flags);
# define VIR_SERVER_CLIENTS_UNAUTH_CURRENT "nclients_unauth"
+int virAdmServerGetClientProcessingControls(virAdmServerPtr srv,
+ virTypedParameterPtr *params,
+ int *nparams,
+ unsigned int flags);
+
# ifdef __cplusplus
}
# endif
diff --git a/src/admin/admin_protocol.x b/src/admin/admin_protocol.x
index 1da7f90..249c062 100644
--- a/src/admin/admin_protocol.x
+++ b/src/admin/admin_protocol.x
@@ -45,6 +45,9 @@ const ADMIN_CLIENT_LIST_MAX = 16384;
/* Upper limit on number of client info parameters */
const ADMIN_CLIENT_INFO_PARAMETERS_MAX = 64;
+/* Upper limit on number of client processing controls */
+const ADMIN_SERVER_CLIENT_PROCESSING_CONTROLS_MAX = 32;
+
/* A long string, which may NOT be NULL. */
typedef string admin_nonnull_string<ADMIN_STRING_MAX>;
@@ -165,6 +168,15 @@ struct admin_client_close_args {
unsigned int flags;
};
+struct admin_server_get_client_processing_controls_args {
+ admin_nonnull_server srv;
+ unsigned int flags;
+};
+
+struct admin_server_get_client_processing_controls_ret {
+ admin_typed_param params<ADMIN_SERVER_CLIENT_PROCESSING_CONTROLS_MAX>;
+};
+
/* Define the program number, protocol version and procedure numbers here. */
const ADMIN_PROGRAM = 0x06900690;
const ADMIN_PROTOCOL_VERSION = 1;
@@ -240,5 +252,10 @@ enum admin_procedure {
/**
* @generate: both
*/
- ADMIN_PROC_CLIENT_CLOSE = 11
+ ADMIN_PROC_CLIENT_CLOSE = 11,
+
+ /**
+ * @generate: none
+ */
+ ADMIN_PROC_SERVER_GET_CLIENT_PROCESSING_CONTROLS = 12
};
diff --git a/src/admin/admin_remote.c b/src/admin/admin_remote.c
index 632aaa8..e3fae4b 100644
--- a/src/admin/admin_remote.c
+++ b/src/admin/admin_remote.c
@@ -355,3 +355,42 @@ remoteAdminClientGetInfo(virAdmClientPtr client,
virObjectUnlock(priv);
return rv;
}
+
+static int
+remoteAdminServerGetClientProcessingControls(virAdmServerPtr srv,
+ virTypedParameterPtr *params,
+ int *nparams,
+ unsigned int flags)
+{
+ int rv = -1;
+ admin_server_get_client_processing_controls_args args;
+ admin_server_get_client_processing_controls_ret ret;
+ remoteAdminPrivPtr priv = srv->conn->privateData;
+ args.flags = flags;
+ make_nonnull_server(&args.srv, srv);
+
+ memset(&ret, 0, sizeof(ret));
+ virObjectLock(priv);
+
+ if (call(srv->conn, 0, ADMIN_PROC_SERVER_GET_CLIENT_PROCESSING_CONTROLS,
+ (xdrproc_t) xdr_admin_server_get_client_processing_controls_args,
+ (char *) &args,
+ (xdrproc_t) xdr_admin_server_get_client_processing_controls_ret,
+ (char *) &ret) == -1)
+ goto cleanup;
+
+ if (virTypedParamsDeserialize((virTypedParameterRemotePtr) ret.params.params_val,
+ ret.params.params_len,
+ ADMIN_SERVER_CLIENT_PROCESSING_CONTROLS_MAX,
+ params,
+ nparams) < 0)
+ goto cleanup;
+
+ rv = 0;
+ xdr_free((xdrproc_t) xdr_admin_server_get_client_processing_controls_ret,
+ (char *) &ret);
+
+ cleanup:
+ virObjectUnlock(priv);
+ return rv;
+}
diff --git a/src/admin_protocol-structs b/src/admin_protocol-structs
index b4db415..3ea0ba6 100644
--- a/src/admin_protocol-structs
+++ b/src/admin_protocol-structs
@@ -109,6 +109,16 @@ struct admin_client_close_args {
admin_nonnull_client clnt;
u_int flags;
};
+struct admin_server_get_client_processing_controls_args {
+ admin_nonnull_server srv;
+ u_int flags;
+};
+struct admin_server_get_client_processing_controls_ret {
+ struct {
+ u_int params_len;
+ admin_typed_param * params_val;
+ } params;
+};
enum admin_procedure {
ADMIN_PROC_CONNECT_OPEN = 1,
ADMIN_PROC_CONNECT_CLOSE = 2,
@@ -121,4 +131,5 @@ enum admin_procedure {
ADMIN_PROC_SERVER_LOOKUP_CLIENT = 9,
ADMIN_PROC_CLIENT_GET_INFO = 10,
ADMIN_PROC_CLIENT_CLOSE = 11,
+ ADMIN_PROC_SERVER_GET_CLIENT_PROCESSING_CONTROLS = 12,
};
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);
+
+ 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;
};
--
2.5.5