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

[libvirt] [PATCH REPOST 31/38] admin: Introduce virAdmConnectGetLoggingLevel



Enable libvirt users to query for the current logging level setting.
---
 daemon/admin.c                  |  9 +++++++++
 include/libvirt/libvirt-admin.h |  2 ++
 src/admin/admin_protocol.x      | 16 +++++++++++++++-
 src/admin_protocol-structs      |  8 ++++++++
 src/libvirt-admin.c             | 34 ++++++++++++++++++++++++++++++++++
 src/libvirt_admin_private.syms  |  2 ++
 src/libvirt_admin_public.syms   |  1 +
 7 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/daemon/admin.c b/daemon/admin.c
index 3de09ca..5129e2d 100644
--- a/daemon/admin.c
+++ b/daemon/admin.c
@@ -295,4 +295,13 @@ adminDispatchClientGetInfo(virNetServerPtr server ATTRIBUTE_UNUSED,
     virObjectUnref(srv);
     return rv;
 }
+
+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 0a1ea61..2878c78 100644
--- a/include/libvirt/libvirt-admin.h
+++ b/include/libvirt/libvirt-admin.h
@@ -349,6 +349,8 @@ int virAdmClientGetInfo(virAdmClientPtr client,
                         int *nparams,
                         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 67bdbf3..6a95665 100644
--- a/src/admin/admin_protocol.x
+++ b/src/admin/admin_protocol.x
@@ -158,6 +158,15 @@ struct admin_client_get_info_args {
 
 struct admin_client_get_info_ret { /* insert 1 */
     admin_typed_param params<ADMIN_CLIENT_INFO_PARAMETERS_MAX>;
+    unsigned int flags;
+};
+
+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. */
@@ -230,5 +239,10 @@ enum admin_procedure {
     /**
      * @generate: none
      */
-    ADMIN_PROC_CLIENT_GET_INFO = 10
+    ADMIN_PROC_CLIENT_GET_INFO = 10,
+
+    /**
+     * @generate: both
+     */
+    ADMIN_PROC_CONNECT_GET_LOGGING_LEVEL = 11
 };
diff --git a/src/admin_protocol-structs b/src/admin_protocol-structs
index ea9adf6..72d93ec 100644
--- a/src/admin_protocol-structs
+++ b/src/admin_protocol-structs
@@ -104,6 +104,13 @@ struct admin_client_get_info_ret {
                 u_int              params_len;
                 admin_typed_param * params_val;
         } params;
+        u_int                      flags;
+};
+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,
@@ -116,4 +123,5 @@ enum admin_procedure {
         ADMIN_PROC_SERVER_LIST_CLIENTS = 8,
         ADMIN_PROC_SERVER_LOOKUP_CLIENT = 9,
         ADMIN_PROC_CLIENT_GET_INFO = 10,
+        ADMIN_PROC_CONNECT_GET_LOGGING_LEVEL = 11,
 };
diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
index a94f5dd..898b9c1 100644
--- a/src/libvirt-admin.c
+++ b/src/libvirt-admin.c
@@ -975,3 +975,37 @@ virAdmClientGetInfo(virAdmClientPtr client,
     virDispatchError(NULL);
     return -1;
 }
+
+/**
+ * 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);
+    virCheckFlagsGoto(0, error);
+
+    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 affe8c1..8534ab1 100644
--- a/src/libvirt_admin_private.syms
+++ b/src/libvirt_admin_private.syms
@@ -9,6 +9,8 @@
 xdr_admin_client_get_info_args;
 xdr_admin_client_get_info_ret;
 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 27e4a1d..4cc0a5b 100644
--- a/src/libvirt_admin_public.syms
+++ b/src/libvirt_admin_public.syms
@@ -26,6 +26,7 @@ LIBVIRT_ADMIN_1.3.0 {
         virAdmConnectRegisterCloseCallback;
         virAdmConnectUnregisterCloseCallback;
         virAdmConnectListServers;
+        virAdmConnectGetLoggingLevel;
         virAdmServerGetName;
         virAdmServerGetThreadPoolParameters;
         virAdmServerFree;
-- 
2.4.11


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