Enable libvirt users to modify daemon's logging output settings from outside.
---
daemon/admin.c | 10 ++++++++++
include/libvirt/libvirt-admin.h | 4 ++++
src/admin/admin_protocol.x | 12 +++++++++++-
src/admin_protocol-structs | 5 +++++
src/libvirt-admin.c | 36 ++++++++++++++++++++++++++++++++++++
src/libvirt_admin_private.syms | 1 +
src/libvirt_admin_public.syms | 1 +
7 files changed, 68 insertions(+), 1 deletion(-)
diff --git a/daemon/admin.c b/daemon/admin.c
index 663e818..4aa25ff 100644
--- a/daemon/admin.c
+++ b/daemon/admin.c
@@ -197,6 +197,16 @@ adminConnectSetLoggingFilters(virNetDaemonPtr dmn ATTRIBUTE_UNUSED,
}
static int
+adminConnectSetLoggingOutputs(virNetDaemonPtr dmn ATTRIBUTE_UNUSED,
+ const char *outputs,
+ unsigned int flags)
+{
+ virCheckFlags(0, -1);
+
+ return virLogSetOutputs(outputs);
+}
+
+static int
adminDispatchConnectGetLoggingFilters(virNetServerPtr server ATTRIBUTE_UNUSED,
virNetServerClientPtr client ATTRIBUTE_UNUSED,
virNetMessagePtr msg ATTRIBUTE_UNUSED,
diff --git a/include/libvirt/libvirt-admin.h b/include/libvirt/libvirt-admin.h
index 284a8f3..be3af3a 100644
--- a/include/libvirt/libvirt-admin.h
+++ b/include/libvirt/libvirt-admin.h
@@ -128,6 +128,10 @@ int virAdmConnectSetLoggingFilters(virAdmConnectPtr conn,
const char *filters,
unsigned int flags);
+int virAdmConnectSetLoggingOutputs(virAdmConnectPtr conn,
+ const char *outputs,
+ unsigned int flags);
+
# ifdef __cplusplus
}
# endif
diff --git a/src/admin/admin_protocol.x b/src/admin/admin_protocol.x
index aefebd4..00d03a5 100644
--- a/src/admin/admin_protocol.x
+++ b/src/admin/admin_protocol.x
@@ -110,6 +110,11 @@ struct admin_connect_set_logging_filters_args {
unsigned int flags;
};
+struct admin_connect_set_logging_outputs_args {
+ admin_nonnull_string outputs;
+ unsigned int flags;
+};
+
/* Define the program number, protocol version and procedure numbers here. */
const ADMIN_PROGRAM = 0x06900690;
const ADMIN_PROTOCOL_VERSION = 1;
@@ -180,5 +185,10 @@ enum admin_procedure {
/**
* @generate: both
*/
- ADMIN_PROC_CONNECT_SET_LOGGING_FILTERS = 10
+ ADMIN_PROC_CONNECT_SET_LOGGING_FILTERS = 10,
+
+ /**
+ * @generate: both
+ */
+ ADMIN_PROC_CONNECT_SET_LOGGING_OUTPUTS = 11
};
diff --git a/src/admin_protocol-structs b/src/admin_protocol-structs
index 70b1b0e..cd16ee3 100644
--- a/src/admin_protocol-structs
+++ b/src/admin_protocol-structs
@@ -54,6 +54,10 @@ struct admin_connect_set_logging_filters_args {
admin_nonnull_string filters;
u_int flags;
};
+struct admin_connect_set_logging_outputs_args {
+ admin_nonnull_string outputs;
+ u_int flags;
+};
enum admin_procedure {
ADMIN_PROC_CONNECT_OPEN = 1,
ADMIN_PROC_CONNECT_CLOSE = 2,
@@ -65,4 +69,5 @@ enum admin_procedure {
ADMIN_PROC_CONNECT_GET_LOGGING_OUTPUTS = 8,
ADMIN_PROC_CONNECT_SET_LOGGING_LEVEL = 9,
ADMIN_PROC_CONNECT_SET_LOGGING_FILTERS = 10,
+ ADMIN_PROC_CONNECT_SET_LOGGING_OUTPUTS = 11,
};
diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
index 3888fb9..55105f4 100644
--- a/src/libvirt-admin.c
+++ b/src/libvirt-admin.c
@@ -857,3 +857,39 @@ virAdmConnectSetLoggingFilters(virAdmConnectPtr conn,
virDispatchError(NULL);
return -1;
}
+
+/**
+ * virAdmConnectSetLoggingOutputs:
+ * @conn: pointer to an active admin connection
+ * @outputs: list of outputs, the format must conform to the format described in
+ * daemon's configuration file (e.g. libvirtd.conf)
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Redefines the existing (set of) outputs(s) with a new one specified in
+ * @outputs. If multiple outputs are specified, they need to be delimited by
+ * spaces.
+ *
+ * Returns 0 if the list of outputs has been successfully defined or -1 in
+ * case of an error.
+ */
+int
+virAdmConnectSetLoggingOutputs(virAdmConnectPtr conn,
+ const char *outputs,
+ unsigned int flags)
+{
+ int ret = -1;
+
+ VIR_DEBUG("conn=%p, outputs=%s, flags=%x", conn, outputs, flags);
+
+ virResetLastError();
+ virCheckAdmConnectReturn(conn, -1);
+ virCheckNonNullArgGoto(outputs, error);
+
+ if ((ret = remoteAdminConnectSetLoggingOutputs(conn, outputs, 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 f78649e..2ca8cdc 100644
--- a/src/libvirt_admin_private.syms
+++ b/src/libvirt_admin_private.syms
@@ -20,6 +20,7 @@ xdr_admin_connect_lookup_server_ret;
xdr_admin_connect_open_args;
xdr_admin_connect_set_logging_filters_args;
xdr_admin_connect_set_logging_level_args;
+xdr_admin_connect_set_logging_outputs_args;
# datatypes.h
virAdmConnectClass;
diff --git a/src/libvirt_admin_public.syms b/src/libvirt_admin_public.syms
index 0a46cb7..be4a0fe 100644
--- a/src/libvirt_admin_public.syms
+++ b/src/libvirt_admin_public.syms
@@ -30,4 +30,5 @@ LIBVIRT_ADMIN_1.3.0 {
virAdmConnectLookupServer;
virAdmConnectSetLoggingLevel;
virAdmConnectSetLoggingFilters;
+ virAdmConnectSetLoggingOutputs;
};
--
2.4.3