]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
tools/xenstore: Reinstate setup_database() in main() xenstore-standalone
authorDavid Woodhouse <dwmw@amazon.co.uk>
Fri, 30 Dec 2022 15:19:16 +0000 (15:19 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Fri, 30 Dec 2022 15:19:16 +0000 (15:19 +0000)
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 <dwmw@amazon.co.uk>
tools/xenstore/xenstored_core.c

index 78a3edaa4e8218f88f3b4845efa79895752ade36..ddacaad38ffa45f8b73862bbb418e0fc62cdc4b7 100644 (file)
@@ -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);