[PATCH v2 06/20] virlog: Introduce virLogDefineFilters

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

 



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.

Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/util/virlog.c        | 26 ++++++++++++++++++++++++++
 src/util/virlog.h        |  1 +
 3 files changed, 28 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index fb7f277..0bceba7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1843,6 +1843,7 @@ virLockSpaceReleaseResourcesForOwner;
 
 # util/virlog.h
 virLogDefineFilter;
+virLogDefineFilters;
 virLogDefineOutput;
 virLogDefineOutputs;
 virLogFilterFree;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 2651f70..a74967b 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1707,3 +1707,29 @@ 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 8568830..e0fe008 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -238,5 +238,6 @@ virLogFilterPtr virLogFilterNew(const char *match,
 int virLogFindOutput(virLogOutputPtr *outputs, size_t noutputs,
                      virLogDestination dest, const void *opaque);
 int virLogDefineOutputs(virLogOutputPtr *outputs, size_t noutputs);
+int virLogDefineFilters(virLogFilterPtr *filters, size_t nfilters);
 
 #endif
-- 
2.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]