Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
SUSE:SLE-12-SP1:GA
xen.8005
54b3f023-xenstored-log-tdb-messages.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 54b3f023-xenstored-log-tdb-messages.patch of Package xen.8005
Subject: xenstored: log tdb message via xenstored's logging mechanisms From: Ian Campbell ian.campbell@citrix.com Mon Jan 12 15:18:02 2015 +0000 Date: Mon Jan 12 16:02:43 2015 +0000: Git: 16cc7dc7ae32c72f73f95d83fe36cdea366e398a TDB provides us with a callback for this purpose. Use it in both xenstored and xs_tdb_dump. While at it make the existing log() macro tollerate memory failures. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Wei Liu <wei.liu2@citrix.com> Index: xen-4.4.4-testing/tools/xenstore/xenstored_core.c =================================================================== --- xen-4.4.4-testing.orig/tools/xenstore/xenstored_core.c +++ xen-4.4.4-testing/tools/xenstore/xenstored_core.c @@ -78,9 +78,14 @@ static void check_store(void); #define log(...) \ do { \ char *s = talloc_asprintf(NULL, __VA_ARGS__); \ - trace("%s\n", s); \ - syslog(LOG_ERR, "%s", s); \ - talloc_free(s); \ + if (s) { \ + trace("%s\n", s); \ + syslog(LOG_ERR, "%s", s); \ + talloc_free(s); \ + } else { \ + trace("talloc failure during logging\n"); \ + syslog(LOG_ERR, "talloc failure during logging\n"); \ + } \ } while (0) @@ -1468,13 +1473,35 @@ static void manual_node(const char *name talloc_free(node); } +static void tdb_logger(TDB_CONTEXT *tdb, int level, const char * fmt, ...) +{ + va_list ap; + char *s; + + va_start(ap, fmt); + s = talloc_vasprintf(NULL, fmt, ap); + va_end(ap); + + if (s) { + trace("TDB: %s\n", s); + syslog(LOG_ERR, "TDB: %s", s); + if (verbose) + xprintf("TDB: %s", s); + talloc_free(s); + } else { + trace("talloc failure during logging\n"); + syslog(LOG_ERR, "talloc failure during logging\n"); + } +} + static void setup_structure(void) { char *tdbname; tdbname = talloc_strdup(talloc_autofree_context(), xs_daemon_tdb()); if (!(tdb_flags & TDB_INTERNAL)) - tdb_ctx = tdb_open(tdbname, 0, tdb_flags, O_RDWR, 0); + tdb_ctx = tdb_open_ex(tdbname, 0, tdb_flags, O_RDWR, 0, + &tdb_logger, NULL); if (tdb_ctx) { /* XXX When we make xenstored able to restart, this will have @@ -1505,8 +1532,8 @@ static void setup_structure(void) talloc_free(tlocal); } else { - tdb_ctx = tdb_open(tdbname, 7919, tdb_flags, O_RDWR|O_CREAT, - 0640); + tdb_ctx = tdb_open_ex(tdbname, 7919, tdb_flags, O_RDWR|O_CREAT, + 0640, &tdb_logger, NULL); if (!tdb_ctx) barf_perror("Could not create tdb file %s", tdbname); Index: xen-4.4.4-testing/tools/xenstore/xs_tdb_dump.c =================================================================== --- xen-4.4.4-testing.orig/tools/xenstore/xs_tdb_dump.c +++ xen-4.4.4-testing/tools/xenstore/xs_tdb_dump.c @@ -32,6 +32,15 @@ static char perm_to_char(enum xs_perm_ty '?'; } +static void tdb_logger(TDB_CONTEXT *tdb, int level, const char * fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); +} + int main(int argc, char *argv[]) { TDB_DATA key; @@ -40,7 +49,8 @@ int main(int argc, char *argv[]) if (argc != 2) barf("Usage: xs_tdb_dump <tdbfile>"); - tdb = tdb_open(talloc_strdup(NULL, argv[1]), 0, 0, O_RDONLY, 0); + tdb = tdb_open_ex(talloc_strdup(NULL, argv[1]), 0, 0, O_RDONLY, 0, + &tdb_logger, NULL); if (!tdb) barf_perror("Could not open %s", argv[1]);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor