trace: add syslog tracing backend
PATCH v2 1/1 trace: add syslog tracing backend
This patch adds a tracing backend which sends output using syslog(). The syslog backend is limited to POSIX compliant systems.
openlog() is called with facility set to LOG_DAEMON, with the LOG_PID option. Trace events are logged at level LOG_INFO.
---
v2:
- Added a section to docs/tracing.txt
- Re-ordered header inclusion in generated code
--- configure | 19 ++++++++++++++++ docs/tracing.txt | 12 ++++++++++ scripts/tracetool/backend/syslog.py | 45 +++++++++++++++++++++++++++++++++++++ trace/control.c | 7 ++++++ 4 files changed, 83 insertions(+) create mode 100644 scripts/tracetool/backend/syslog.py
configure +19 -0
@@ -4189,6 +4189,18 @@ if compile_prog "" "" ; then fi ########################################## +# check if we have posix_syslog + +posix_syslog=no +cat > $TMPC << EOF +#include <syslog.h> +int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; } +EOF +if compile_prog "" "" ; then + posix_syslog=yes +fi + +########################################## # check if trace backend exists $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
@@ -5456,6 +5468,13 @@ if have_backend "ftrace"; then feature_not_found "ftrace(trace backend)" "ftrace requires Linux" fi fi +if have_backend "syslog"; then + if test "$posix_syslog" = "yes" ; then + echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak + else + feature_not_found "syslog(trace backend)" "syslog not available" + fi +fi echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak if test "$rdma" = "yes" ; then
docs/tracing.txt +12 -0
@@ -192,6 +192,18 @@ After running qemu by root user, you can get the trace: Restriction: "ftrace" backend is restricted to Linux only. +=== Syslog === + +The "syslog" backend sends trace events using the POSIX syslog API. The log +is opened specifying the LOG_DAEMON facility and LOG_PID option (so events +are tagged with the pid of the particular QEMU process that generated +them). All events are logged at LOG_INFO level. + +NOTE: syslog may squash duplicate consecutive trace events and apply rate + limiting. + +Restriction: "syslog" backend is restricted to POSIX compliant OS. + ==== Monitor commands ==== * trace-file on|off|flush|set <path>
scripts/tracetool/backend/syslog.py new file +45 -0
45 lines not on this page · raw message
trace/control.c +7 -0
@@ -19,6 +19,9 @@#ifdef CONFIG_TRACE_LOG #include "qemu/log.h" #endif +#ifdef CONFIG_TRACE_SYSLOG +#include <syslog.h> +#endif #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/config-file.h"
@@ -250,6 +253,10 @@ bool trace_init_backends(void) }#endif +#ifdef CONFIG_TRACE_SYSLOG +openlog (NULL ,LOG_PID ,LOG_DAEMON ); +#endif +return true; }
Signature · 1 line
2.1.4
Stefan Hajnoczi
AppliedQuoted 13 lines · Paul Durrant
This patch adds a tracing backend which sends output using
syslog(). The syslog backend is limited to POSIX compliant systems.
openlog()is called with facility set toLOG_DAEMON, with theLOG_PIDoption. Trace events are logged at levelLOG_INFO.Signed-off-by Paul Durrant <[email protected]>Cc Stefan Hajnoczi <[email protected]>---
v2:
- Added a section todocs/tracing.txt
- Re-ordered header inclusion in generated code
Quoted 7 lines
--- configure | 19 ++++++++++++++++ docs/tracing.txt | 12 ++++++++++ scripts/tracetool/backend/syslog.py | 45 +++++++++++++++++++++++++++++++++++++ trace/control.c | 7 ++++++ 4 files changed, 83 insertions(+) create mode 100644 scripts/tracetool/backend/syslog.py
Thanks, applied to my tracing-next tree:
https://github.com/stefanha/qemu/commits/tracing-next
Stefan