ia64/xen-unstable

changeset 8160:2e3051c01757

Remove /local when xenstored starts. This stops stale data affecting the
system immediately after reboot.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Thu Dec 01 03:32:39 2005 +0000 (2005-12-01)
parents fbbb8a2a6013
children e0d01dd6c4ca
files tools/xenstore/xenstored_core.c
line diff
     1.1 --- a/tools/xenstore/xenstored_core.c	Thu Dec 01 03:26:47 2005 +0000
     1.2 +++ b/tools/xenstore/xenstored_core.c	Thu Dec 01 03:32:39 2005 +0000
     1.3 @@ -1009,6 +1009,15 @@ static int _rm(struct connection *conn, 
     1.4  }
     1.5  
     1.6  
     1.7 +static void internal_rm(const char *name)
     1.8 +{
     1.9 +	char *tname = talloc_strdup(talloc_autofree_context(), name);
    1.10 +	struct node *node = read_node(NULL, tname);
    1.11 +	if (node)
    1.12 +		_rm(NULL, node, tname);
    1.13 +}
    1.14 +
    1.15 +
    1.16  static void do_rm(struct connection *conn, const char *name)
    1.17  {
    1.18  	struct node *node;
    1.19 @@ -1417,7 +1426,24 @@ static void setup_structure(void)
    1.20  	tdbname = talloc_strdup(talloc_autofree_context(), xs_daemon_tdb());
    1.21  	tdb_ctx = tdb_open(tdbname, 0, TDB_FLAGS, O_RDWR, 0);
    1.22  
    1.23 -	if (!tdb_ctx) {
    1.24 +	if (tdb_ctx) {
    1.25 +		/* XXX When we make xenstored able to restart, this will have
    1.26 +		   to become cleverer, checking for existing domains and not
    1.27 +		   removing the corresponding entries, but for now xenstored
    1.28 +		   cannot be restarted without losing all the registered
    1.29 +		   watches, which breaks all the backend drivers anyway.  We
    1.30 +		   can therefore get away with just clearing /local and
    1.31 +		   expecting Xend to put the appropriate entries back in.
    1.32 +
    1.33 +		   When this change is made it is important to note that
    1.34 +		   dom0's entries must be cleaned up on reboot _before_ this
    1.35 +		   daemon starts, otherwise the backend drivers and dom0's
    1.36 +		   balloon driver will pick up stale entries.  In the case of
    1.37 +		   the balloon driver, this can be fatal.
    1.38 +		*/
    1.39 +		internal_rm("/local");
    1.40 +	}
    1.41 +	else {
    1.42  		tdb_ctx = tdb_open(tdbname, 7919, TDB_FLAGS, O_RDWR|O_CREAT,
    1.43  				   0640);
    1.44  		if (!tdb_ctx)