Enable libvirt users to query for the current logging level setting. --- daemon/admin.c | 8 ++++++++ include/libvirt/libvirt-admin.h | 1 + src/admin/admin_protocol.x | 15 ++++++++++++++- src/admin_protocol-structs | 7 +++++++ src/libvirt-admin.c | 33 +++++++++++++++++++++++++++++++++ src/libvirt_admin_private.syms | 2 ++ src/libvirt_admin_public.syms | 1 + 7 files changed, 66 insertions(+), 1 deletion(-) diff --git a/daemon/admin.c b/daemon/admin.c index 3169cdd..ed07988 100644 --- a/daemon/admin.c +++ b/daemon/admin.c @@ -133,4 +133,12 @@ adminConnectGetLibVersion(virNetDaemonPtr dmn ATTRIBUTE_UNUSED, return 0; } +static int +adminConnectGetLoggingLevel(virNetDaemonPtr dmn ATTRIBUTE_UNUSED, + unsigned int flags) +{ + virCheckFlags(0, -1); + + return virLogGetDefaultPriority(); +} #include "admin_dispatch.h" diff --git a/include/libvirt/libvirt-admin.h b/include/libvirt/libvirt-admin.h index 25bcbf4..c1aba01 100644 --- a/include/libvirt/libvirt-admin.h +++ b/include/libvirt/libvirt-admin.h @@ -110,6 +110,7 @@ virAdmServerPtr virAdmConnectLookupServer(virAdmConnectPtr conn, const char *name, unsigned int flags); +int virAdmConnectGetLoggingLevel(virAdmConnectPtr conn, unsigned int flags); # ifdef __cplusplus } # endif diff --git a/src/admin/admin_protocol.x b/src/admin/admin_protocol.x index 6590980..268c81e 100644 --- a/src/admin/admin_protocol.x +++ b/src/admin/admin_protocol.x @@ -74,6 +74,14 @@ struct admin_connect_lookup_server_ret { admin_nonnull_server srv; }; +struct admin_connect_get_logging_level_args { + unsigned int flags; +}; + +struct admin_connect_get_logging_level_ret { + int level; +}; + /* Define the program number, protocol version and procedure numbers here. */ const ADMIN_PROGRAM = 0x06900690; const ADMIN_PROTOCOL_VERSION = 1; @@ -119,5 +127,10 @@ enum admin_procedure { /** * @generate: both */ - ADMIN_PROC_CONNECT_LOOKUP_SERVER = 5 + ADMIN_PROC_CONNECT_LOOKUP_SERVER = 5, + + /** + * @generate: both + */ + ADMIN_PROC_CONNECT_GET_LOGGING_LEVEL = 6 }; diff --git a/src/admin_protocol-structs b/src/admin_protocol-structs index d8aca06..9d0397c 100644 --- a/src/admin_protocol-structs +++ b/src/admin_protocol-structs @@ -26,10 +26,17 @@ struct admin_connect_lookup_server_args { struct admin_connect_lookup_server_ret { admin_nonnull_server srv; }; +struct admin_connect_get_logging_level_args { + u_int flags; +}; +struct admin_connect_get_logging_level_ret { + int level; +}; enum admin_procedure { ADMIN_PROC_CONNECT_OPEN = 1, ADMIN_PROC_CONNECT_CLOSE = 2, ADMIN_PROC_CONNECT_GET_LIB_VERSION = 3, ADMIN_PROC_CONNECT_LIST_SERVERS = 4, ADMIN_PROC_CONNECT_LOOKUP_SERVER = 5, + ADMIN_PROC_CONNECT_GET_LOGGING_LEVEL = 6, }; diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c index 54af90c..f29c83d 100644 --- a/src/libvirt-admin.c +++ b/src/libvirt-admin.c @@ -674,3 +674,36 @@ virAdmConnectLookupServer(virAdmConnectPtr conn, virDispatchError(NULL); return ret; } + +/** + * virAdmConnectGetLoggingLevel: + * @conn: pointer to an active admin connection + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * Retrieves the current global logging level (as per daemon configuration): + * 1: DEBUG + * 2: INFO + * 3: WARNING + * 4: ERROR + * + * Returns the numeric logging level representation or -1 in case of an error. + */ +int +virAdmConnectGetLoggingLevel(virAdmConnectPtr conn, + unsigned int flags) +{ + int ret = -1; + + VIR_DEBUG("conn=%p, flags=%x", conn, flags); + + virResetLastError(); + virCheckAdmConnectReturn(conn, -1); + + if ((ret = remoteAdminConnectGetLoggingLevel(conn, 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 268f1e6..d2e2292 100644 --- a/src/libvirt_admin_private.syms +++ b/src/libvirt_admin_private.syms @@ -7,6 +7,8 @@ # admin/admin_protocol.x xdr_admin_connect_get_lib_version_ret; +xdr_admin_connect_get_logging_level_args; +xdr_admin_connect_get_logging_level_ret; xdr_admin_connect_list_servers_args; xdr_admin_connect_list_servers_ret; xdr_admin_connect_lookup_server_args; diff --git a/src/libvirt_admin_public.syms b/src/libvirt_admin_public.syms index 58d085e..37d534e 100644 --- a/src/libvirt_admin_public.syms +++ b/src/libvirt_admin_public.syms @@ -22,6 +22,7 @@ LIBVIRT_ADMIN_1.3.0 { virAdmConnectRegisterCloseCallback; virAdmConnectUnregisterCloseCallback; virAdmConnectListServers; + virAdmConnectGetLoggingLevel; virAdmServerGetName; virAdmServerFree; virAdmConnectLookupServer; -- 2.4.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list