From: David Woodhouse Date: Fri, 30 Dec 2022 15:19:16 +0000 (+0000) Subject: tools/xenstore: Reinstate setup_database() in main() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=refs%2Fheads%2Fxenstore-standalone;p=people%2Fdwmw2%2Fxen.git tools/xenstore: Reinstate setup_database() in main() Commit 60e2f6020d ("tools/xenstore: move the call of setup_structure() to dom0 introduction") deferred the setup of the tdb database, but that doesn't work very well with the -D flag which avoids initialising dom0. We end up just segfaulting with a NULL tdb pointer on any attempted access. Fixes: 60e2f6020d ("tools/xenstore: move the call of setup_structure() to dom0 introduction") Signed-off-by: David Woodhouse --- diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index 78a3edaa4e..ddacaad38f 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -2367,7 +2367,7 @@ static void tdb_logger(TDB_CONTEXT *tdb, int level, const char * fmt, ...) errno = saved_errno; } -void setup_structure(bool live_update) +static void setup_database(void) { char *tdbname; @@ -2383,7 +2383,10 @@ void setup_structure(bool live_update) 0640, &tdb_logger, NULL); if (!tdb_ctx) barf_perror("Could not create tdb file %s", tdbname); +} +void setup_structure(bool live_update) +{ if (live_update) manual_node("/", NULL); else { @@ -2856,6 +2859,9 @@ int main(int argc, char *argv[]) init_pipe(reopen_log_pipe); + /* Setup the database */ + setup_database(); + /* Listen to hypervisor. */ if (!no_domain_init && !live_update) { domain_init(-1);