tools/xenstore: switch barf[_perror]() to use syslog()
authorJuergen Gross <jgross@suse.com>
Tue, 15 Dec 2020 16:35:39 +0000 (17:35 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 17 Dec 2020 15:04:43 +0000 (15:04 +0000)
When xenstored crashes due to an unrecoverable condition it is calling
either barf() or barf_perror() to issue a message and then exit().

Make sure the message is visible somewhere by using syslog()
additionally to xprintf(), as the latter will be visible only with
tracing active.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Reviewed-by: Julien Grall <jgrall@amazon.com>
tools/xenstore/utils.c

index a1ac12584a2321452b0b7d1d7fa5cb6edf297cb3..633ce3b4fcbe3e99be022709ac25c686b287235b 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -35,6 +36,7 @@ void barf(const char *fmt, ...)
        va_end(arglist);
 
        if (bytes >= 0) {
+               syslog(LOG_CRIT, "%s\n", str);
                xprintf("%s\n", str);
                free(str);
        }
@@ -54,6 +56,7 @@ void barf_perror(const char *fmt, ...)
        va_end(arglist);
 
        if (bytes >= 0) {
+               syslog(LOG_CRIT, "%s: %s\n", str, strerror(err));
                xprintf("%s: %s\n", str, strerror(err));
                free(str);
        }