[PATCH REPOST 25/38] virlog: Take a special care of syslog when setting new set of log outputs

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

 



Now that we're in the critical section, closelog and openlog need to be issued
if the user setting changed, which is something that cannot be done beforehand,
since syslog keeps its file descriptor private.
---
 src/util/virlog.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/util/virlog.c b/src/util/virlog.c
index 62533b1..a20cde4 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1605,6 +1605,8 @@ virLogSetOutputs(const char *outputs)
     int ret = -1;
     int count = 0;
     virLogOutputPtr *list = NULL;
+    size_t i;
+    char *tmp = NULL;
 
     if (virLogInitialize() < 0)
         return -1;
@@ -1612,6 +1614,17 @@ virLogSetOutputs(const char *outputs)
     if ((count = virLogParseOutputs(outputs, &list)) < 0)
         goto cleanup;
 
+    /* syslog needs a special care */
+    for (i = 0; i < count; i++) {
+        if (list[i]->dest == VIR_LOG_TO_SYSLOG) {
+            if (VIR_STRDUP(tmp, list[i]->name) < 0)
+                goto cleanup;
+            VIR_FREE(current_ident);
+            current_ident = tmp;
+            openlog(current_ident, 0, 0);
+        }
+    }
+
     if (virLogDefineOutputs(list, count) < 0)
         goto cleanup;
 
-- 
2.4.11

--
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]