mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
admin: Introduce virAdmConnectGetLoggingOutputs
Enable libvirt users to query logging output settings. Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
94c465d0eb
commit
fc7d1be79e
@ -383,4 +383,41 @@ adminDispatchServerSetClientLimits(virNetServerPtr server ATTRIBUTE_UNUSED,
|
||||
virObjectUnref(srv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Returns the number of outputs stored in @outputs */
|
||||
static int
|
||||
adminConnectGetLoggingOutputs(char **outputs, unsigned int flags)
|
||||
{
|
||||
char *tmp = NULL;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
if (!(tmp = virLogGetOutputs()))
|
||||
return -1;
|
||||
|
||||
*outputs = tmp;
|
||||
return virLogGetNbOutputs();
|
||||
}
|
||||
|
||||
static int
|
||||
adminDispatchConnectGetLoggingOutputs(virNetServerPtr server ATTRIBUTE_UNUSED,
|
||||
virNetServerClientPtr client ATTRIBUTE_UNUSED,
|
||||
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
||||
virNetMessageErrorPtr rerr,
|
||||
admin_connect_get_logging_outputs_args *args,
|
||||
admin_connect_get_logging_outputs_ret *ret)
|
||||
{
|
||||
char *outputs = NULL;
|
||||
int noutputs = 0;
|
||||
|
||||
if ((noutputs = adminConnectGetLoggingOutputs(&outputs, args->flags) < 0)) {
|
||||
virNetMessageSaveError(rerr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
VIR_STEAL_PTR(ret->outputs, outputs);
|
||||
ret->noutputs = noutputs;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#include "admin_dispatch.h"
|
||||
|
@ -404,6 +404,10 @@ int virAdmServerSetClientLimits(virAdmServerPtr srv,
|
||||
int nparams,
|
||||
unsigned int flags);
|
||||
|
||||
int virAdmConnectGetLoggingOutputs(virAdmConnectPtr conn,
|
||||
char **outputs,
|
||||
unsigned int flags);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
@ -183,6 +183,15 @@ struct admin_server_set_client_limits_args {
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
struct admin_connect_get_logging_outputs_args {
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
struct admin_connect_get_logging_outputs_ret {
|
||||
admin_nonnull_string outputs;
|
||||
unsigned int noutputs;
|
||||
};
|
||||
|
||||
/* Define the program number, protocol version and procedure numbers here. */
|
||||
const ADMIN_PROGRAM = 0x06900690;
|
||||
const ADMIN_PROTOCOL_VERSION = 1;
|
||||
@ -268,5 +277,10 @@ enum admin_procedure {
|
||||
/**
|
||||
* @generate: none
|
||||
*/
|
||||
ADMIN_PROC_SERVER_SET_CLIENT_LIMITS = 13
|
||||
ADMIN_PROC_SERVER_SET_CLIENT_LIMITS = 13,
|
||||
|
||||
/**
|
||||
* @generate: none
|
||||
*/
|
||||
ADMIN_PROC_CONNECT_GET_LOGGING_OUTPUTS = 14
|
||||
};
|
||||
|
@ -425,3 +425,38 @@ remoteAdminServerSetClientLimits(virAdmServerPtr srv,
|
||||
virObjectUnlock(priv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int
|
||||
remoteAdminConnectGetLoggingOutputs(virAdmConnectPtr conn,
|
||||
char **outputs,
|
||||
unsigned int flags)
|
||||
{
|
||||
int rv = -1;
|
||||
remoteAdminPrivPtr priv = conn->privateData;
|
||||
admin_connect_get_logging_outputs_args args;
|
||||
admin_connect_get_logging_outputs_ret ret;
|
||||
|
||||
args.flags = flags;
|
||||
|
||||
memset(&ret, 0, sizeof(ret));
|
||||
virObjectLock(priv);
|
||||
|
||||
if (call(conn,
|
||||
0,
|
||||
ADMIN_PROC_CONNECT_GET_LOGGING_OUTPUTS,
|
||||
(xdrproc_t) xdr_admin_connect_get_logging_outputs_args,
|
||||
(char *) &args,
|
||||
(xdrproc_t) xdr_admin_connect_get_logging_outputs_ret,
|
||||
(char *) &ret) == -1)
|
||||
goto done;
|
||||
|
||||
if (outputs)
|
||||
VIR_STEAL_PTR(*outputs, ret.outputs);
|
||||
|
||||
rv = ret.noutputs;
|
||||
xdr_free((xdrproc_t) xdr_admin_connect_get_logging_outputs_ret, (char *) &ret);
|
||||
|
||||
done:
|
||||
virObjectUnlock(priv);
|
||||
return rv;
|
||||
}
|
||||
|
@ -127,6 +127,13 @@ struct admin_server_set_client_limits_args {
|
||||
} params;
|
||||
u_int flags;
|
||||
};
|
||||
struct admin_connect_get_logging_outputs_args {
|
||||
u_int flags;
|
||||
};
|
||||
struct admin_connect_get_logging_outputs_ret {
|
||||
admin_nonnull_string outputs;
|
||||
u_int noutputs;
|
||||
};
|
||||
enum admin_procedure {
|
||||
ADMIN_PROC_CONNECT_OPEN = 1,
|
||||
ADMIN_PROC_CONNECT_CLOSE = 2,
|
||||
@ -141,4 +148,5 @@ enum admin_procedure {
|
||||
ADMIN_PROC_CLIENT_CLOSE = 11,
|
||||
ADMIN_PROC_SERVER_GET_CLIENT_LIMITS = 12,
|
||||
ADMIN_PROC_SERVER_SET_CLIENT_LIMITS = 13,
|
||||
ADMIN_PROC_CONNECT_GET_LOGGING_OUTPUTS = 14,
|
||||
};
|
||||
|
@ -1084,3 +1084,43 @@ virAdmServerSetClientLimits(virAdmServerPtr srv,
|
||||
virDispatchError(NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* virAdmConnectGetLoggingOutputs:
|
||||
* @conn: pointer to an active admin connection
|
||||
* @outputs: pointer to a variable to store a string containing all currently
|
||||
* defined logging outputs on daemon (allocated automatically) or
|
||||
* NULL if just the number of defined outputs is required
|
||||
* @flags: extra flags; not used yet, so callers should always pass 0
|
||||
*
|
||||
* Retrieves a list of currently installed logging outputs. Outputs returned
|
||||
* are contained within an automatically allocated string and delimited by
|
||||
* spaces. The format of each output conforms to the format described in
|
||||
* daemon's configuration file (e.g. libvirtd.conf).
|
||||
*
|
||||
* To retrieve individual outputs, additional parsing needs to be done by the
|
||||
* caller. Caller is also responsible for freeing @outputs correctly.
|
||||
*
|
||||
* Returns the count of outputs in @outputs, or -1 in case of an error.
|
||||
*/
|
||||
int
|
||||
virAdmConnectGetLoggingOutputs(virAdmConnectPtr conn,
|
||||
char **outputs,
|
||||
unsigned int flags)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
VIR_DEBUG("conn=%p, flags=%x", conn, flags);
|
||||
|
||||
virResetLastError();
|
||||
virCheckAdmConnectReturn(conn, -1);
|
||||
|
||||
if ((ret = remoteAdminConnectGetLoggingOutputs(conn, outputs,
|
||||
flags)) < 0)
|
||||
goto error;
|
||||
|
||||
return ret;
|
||||
error:
|
||||
virDispatchError(NULL);
|
||||
return -1;
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ xdr_admin_client_close_args;
|
||||
xdr_admin_client_get_info_args;
|
||||
xdr_admin_client_get_info_ret;
|
||||
xdr_admin_connect_get_lib_version_ret;
|
||||
xdr_admin_connect_get_logging_outputs_args;
|
||||
xdr_admin_connect_get_logging_outputs_ret;
|
||||
xdr_admin_connect_list_servers_args;
|
||||
xdr_admin_connect_list_servers_ret;
|
||||
xdr_admin_connect_lookup_server_args;
|
||||
|
@ -39,3 +39,8 @@ LIBVIRT_ADMIN_2.0.0 {
|
||||
virAdmServerGetClientLimits;
|
||||
virAdmServerSetClientLimits;
|
||||
};
|
||||
|
||||
LIBVIRT_ADMIN_3.0.0 {
|
||||
global:
|
||||
virAdmConnectGetLoggingOutputs;
|
||||
} LIBVIRT_ADMIN_2.0.0;
|
||||
|
Loading…
Reference in New Issue
Block a user