Add general trace() function to xenstore, for help in debugging in future.
PATCH 4/11 Add general trace() function to xenstore, for help in debugging in future.
# HG changeset patch
# User Rusty Russell <[email protected]>
# Node ID d4ab9ac93104a13a09ebfaa2384281c4e3392e3f
# Parent 70ea61257cebc00212defe1dbed6de26c2edcf30
Add general trace() function to xenstore, for help in debugging in future.
Signed-off-by Rusty Russell <[email protected]>
tools/xenstore/xenstored_core.c +17 -0
@@ -111,6 +111,8 @@ str =talloc_vasprintf (NULL , fmt, arglist);va_end (arglist); +trace ("xenstored corruption: connection id %i: err %s: %s" , + conn ? (int )conn->id :-1 ,strerror (saved_errno), str);eprintf ("xenstored corruption: connection id %i: err %s: %s" , conn ? (int )conn->id :-1 ,strerror (saved_errno), str);#ifdef TESTING
@@ -228,6 +230,21 @@write (tracefd,sockmsg_string (data->hdr.msg.type),strlen (sockmsg_string (data->hdr.msg.type)));write (tracefd,")\n" ,2 ); +} + +void trace (const char *fmt, ...) +{ +va_list arglist; +char *str; + +if (tracefd <0 ) +return ; + +va_start (arglist, fmt); + str =talloc_vasprintf (NULL , fmt, arglist); +va_end (arglist); +write (tracefd, str,strlen (str)); +talloc_free (str); }static bool write_message (struct connection *conn)
tools/xenstore/xenstored_core.h +1 -0
@@ -147,5 +147,6 @@void trace_create (const void *data,const char *type);void trace_destroy (const void *data,const char *type);void trace_watch_timeout (const struct connection *conn,const char *node,const char *token); +void trace (const char *fmt, ...);#endif /* _XENSTORED_CORE_H */