Prepare a method that only defines a set of filters. It takes a list of
filters, preferably created by virLogParseFilters. The original set of filters
is reset and replaced by the new user-provided set of filters.
---
src/libvirt_private.syms | 1 +
src/util/virlog.c | 25 +++++++++++++++++++++++++
src/util/virlog.h | 1 +
3 files changed, 27 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index e97ec45..8773270 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1742,6 +1742,7 @@ virLockSpaceReleaseResourcesForOwner;
# util/virlog.h
virLogDefineFilter;
+virLogDefineFilters;
virLogDefineOutput;
virLogDefineOutputs;
virLogGetDefaultPriority;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index e5923ce..60573a9 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1564,3 +1564,28 @@ virLogDefineOutputs(virLogOutputPtr *outputs, size_t noutputs)
return virLogNbOutputs;
}
+
+/**
+ * virLogDefineFilters:
+ * @filters: new set of filters to be defined
+ * @nfilters: number of filters in @filters
+ *
+ * Resets any existing set of filters and defines a completely new one.
+ *
+ * Returns number of filters successfully defined or -1 in case of error;
+ */
+int
+virLogDefineFilters(virLogFilterPtr *filters, size_t nfilters)
+{
+ if (virLogInitialize() < 0)
+ return -1;
+
+ virLogLock();
+ virLogResetOutputs();
+ virLogFilters = filters;
+ virLogNbOutputs = nfilters;
+ virLogFiltersSerial++;
+ virLogUnlock();
+
+ return virLogNbFilters;
+}
diff --git a/src/util/virlog.h b/src/util/virlog.h
index 166db5a..ff16034 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -225,5 +225,6 @@ extern void virLogVMessage(virLogSourcePtr source,
bool virLogProbablyLogMessage(const char *str);
int virLogDefineOutputs(virLogOutputPtr *outputs, size_t noutputs);
+int virLogDefineFilters(virLogFilterPtr *filters, size_t nfilters);
#endif
--
2.4.3