ia64/xen-unstable

changeset 6694:a39b1fa10edc

Move console tty/limit information into console directory in domain dir.
Also only store port number of console event channel.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Wed Sep 07 21:24:34 2005 +0000 (2005-09-07)
parents 64ca0d3ea97f
children 7bc32f4c67fb
files tools/console/client/main.c tools/console/daemon/io.c tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/console/client/main.c	Wed Sep 07 21:15:41 2005 +0000
     1.2 +++ b/tools/console/client/main.c	Wed Sep 07 21:24:34 2005 +0000
     1.3 @@ -170,8 +170,7 @@ int main(int argc, char **argv)
     1.4  		{ 0 },
     1.5  
     1.6  	};
     1.7 -	char *str_pty;
     1.8 -	char path[1024];
     1.9 +	char *str_pty, *path;
    1.10  	int spty;
    1.11  	unsigned int len = 0;
    1.12  	struct xs_handle *xs;
    1.13 @@ -214,7 +213,13 @@ int main(int argc, char **argv)
    1.14  	
    1.15  	signal(SIGTERM, sighandler);
    1.16  
    1.17 -	snprintf(path, sizeof(path), "/console/%d/tty", domid);
    1.18 +	path = xs_get_domain_path(xs, domid);
    1.19 +	if (path == NULL)
    1.20 +		err(errno, "xs_get_domain_path()");
    1.21 +	path = realloc(path, strlen(path) + strlen("/console/tty") + 1);
    1.22 +	if (path == NULL)
    1.23 +		err(ENOMEM, "realloc");
    1.24 +	strcat(path, "/console/tty");
    1.25  	str_pty = xs_read(xs, path, &len);
    1.26  
    1.27  	/* FIXME consoled currently does not assume domain-0 doesn't have a
    1.28 @@ -252,6 +257,7 @@ int main(int argc, char **argv)
    1.29  		err(errno, "Could not open tty `%s'", str_pty);
    1.30  	}
    1.31  	free(str_pty);
    1.32 +	free(path);
    1.33  
    1.34  	init_term(STDIN_FILENO, &attr);
    1.35  	console_loop(xc_handle, domid, spty);
     2.1 --- a/tools/console/daemon/io.c	Wed Sep 07 21:15:41 2005 +0000
     2.2 +++ b/tools/console/daemon/io.c	Wed Sep 07 21:24:34 2005 +0000
     2.3 @@ -144,6 +144,7 @@ static int domain_create_tty(struct doma
     2.4  {
     2.5  	char *path;
     2.6  	int master;
     2.7 +	bool success;
     2.8  
     2.9  	if ((master = getpt()) == -1 ||
    2.10  	    grantpt(master) == -1 || unlockpt(master) == -1) {
    2.11 @@ -161,11 +162,17 @@ static int domain_create_tty(struct doma
    2.12  			tcsetattr(master, TCSAFLUSH, &term);
    2.13  		}
    2.14  
    2.15 -		asprintf(&path, "/console/%d/tty", dom->domid);
    2.16 -		xs_write(xs, path, slave, strlen(slave), O_CREAT);
    2.17 +		success = asprintf(&path, "%s/tty", dom->conspath) != -1;
    2.18 +		if (!success)
    2.19 +			goto out;
    2.20 +		success = xs_write(xs, path, slave, strlen(slave), O_CREAT);
    2.21  		free(path);
    2.22 +		if (!success)
    2.23 +			goto out;
    2.24  
    2.25 -		asprintf(&path, "/console/%d/limit", dom->domid);
    2.26 +		success = asprintf(&path, "%s/limit", dom->conspath) != -1;
    2.27 +		if (!success)
    2.28 +			goto out;
    2.29  		data = xs_read(xs, path, &len);
    2.30  		if (data) {
    2.31  			dom->buffer.max_capacity = strtoul(data, 0, 0);
    2.32 @@ -175,6 +182,9 @@ static int domain_create_tty(struct doma
    2.33  	}
    2.34  
    2.35  	return master;
    2.36 + out:
    2.37 +	close(master);
    2.38 +	return -1;
    2.39  }
    2.40  
    2.41  /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */
    2.42 @@ -218,7 +228,7 @@ static int domain_create_ring(struct dom
    2.43  
    2.44  	err = xs_gather(xs, dom->conspath,
    2.45  			"ring-ref", "%u", &ring_ref,
    2.46 -			"console_channel/port1", "%i", &local_port,
    2.47 +			"port", "%i", &local_port,
    2.48  			NULL);
    2.49  	if (err)
    2.50  		goto out;
    2.51 @@ -289,6 +299,17 @@ static struct domain *create_domain(int 
    2.52  	}
    2.53  
    2.54  	dom->domid = domid;
    2.55 +
    2.56 +	dom->conspath = xs_get_domain_path(xs, dom->domid);
    2.57 +	if (dom->conspath == NULL)
    2.58 +		goto out;
    2.59 +	s = realloc(dom->conspath, strlen(dom->conspath) +
    2.60 +		    strlen("/console") + 1);
    2.61 +	if (s == NULL)
    2.62 +		goto out;
    2.63 +	dom->conspath = s;
    2.64 +	strcat(dom->conspath, "/console");
    2.65 +
    2.66  	dom->tty_fd = domain_create_tty(dom);
    2.67  	dom->is_dead = false;
    2.68  	dom->buffer.data = 0;
    2.69 @@ -302,18 +323,6 @@ static struct domain *create_domain(int 
    2.70  	dom->page = NULL;
    2.71  	dom->evtchn_fd = -1;
    2.72  
    2.73 -	dom->conspath = NULL;
    2.74 -
    2.75 -	dom->conspath = xs_get_domain_path(xs, dom->domid);
    2.76 -	if (dom->conspath == NULL)
    2.77 -		goto out;
    2.78 -	s = realloc(dom->conspath, strlen(dom->conspath) +
    2.79 -		    strlen("/console") + 1);
    2.80 -	if (s == NULL)
    2.81 -		goto out;
    2.82 -	dom->conspath = s;
    2.83 -	strcat(dom->conspath, "/console");
    2.84 -
    2.85  	if (!watch_domain(dom, true))
    2.86  		goto out;
    2.87  
     3.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Wed Sep 07 21:15:41 2005 +0000
     3.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Wed Sep 07 21:24:34 2005 +0000
     3.3 @@ -173,7 +173,6 @@ def restore(xd, fd):
     3.4                      if m:
     3.5                          dominfo.console_mfn = int(m.group(2))
     3.6                          dominfo.exportToDB(save=True, sync=True)
     3.7 -                        dominfo.publish_console()
     3.8                      try:
     3.9                          l = child.fromchild.readline()
    3.10                      except:
     4.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Sep 07 21:15:41 2005 +0000
     4.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Sep 07 21:24:34 2005 +0000
     4.3 @@ -298,15 +298,14 @@ class XendDomainInfo:
     4.4              self.store_channel.saveToDB(self.db.addChild("store_channel"),
     4.5                                          save=save)
     4.6          if self.console_channel:
     4.7 -            self.console_channel.saveToDB(self.db.addChild("console/console_channel"),
     4.8 -                                        save=save)
     4.9 +            self.db['console/port'] = "%i" % self.console_channel.port1
    4.10          if self.image:
    4.11              self.image.exportToDB(save=save, sync=sync)
    4.12          self.db.exportToDB(self, fields=self.__exports__, save=save, sync=sync)
    4.13  
    4.14      def importFromDB(self):
    4.15          self.db.importFromDB(self, fields=self.__exports__)
    4.16 -        self.store_channel = self.eventChannel("store_channel")
    4.17 +        self.store_channel = self.eventChannelOld("store_channel")
    4.18  
    4.19      def setdom(self, dom):
    4.20          """Set the domain id.
    4.21 @@ -654,7 +653,6 @@ class XendDomainInfo:
    4.22              self.configure_restart()
    4.23              self.construct_image()
    4.24              self.configure()
    4.25 -            self.publish_console()
    4.26              self.exportToDB(save=True)
    4.27          except Exception, ex:
    4.28              # Catch errors, cleanup and re-raise.
    4.29 @@ -845,7 +843,7 @@ class XendDomainInfo:
    4.30                    id, self.name, self.memory)
    4.31          self.setdom(id)
    4.32  
    4.33 -    def eventChannel(self, key):
    4.34 +    def eventChannelOld(self, key):
    4.35          """Create an event channel to the domain.
    4.36          If saved info is available recreate the channel.
    4.37          
    4.38 @@ -854,11 +852,27 @@ class XendDomainInfo:
    4.39          db = self.db.addChild(key)
    4.40          return EventChannel.restoreFromDB(db, 0, self.id)
    4.41          
    4.42 +    def eventChannel(self, path=None, key=None):
    4.43 +        """Create an event channel to the domain.
    4.44 +        
    4.45 +        @param path under which port is stored in db
    4.46 +        """
    4.47 +        port = 0
    4.48 +        try:
    4.49 +            if path and key:
    4.50 +                if path:
    4.51 +                    db = self.db.addChild(path)
    4.52 +                else:
    4.53 +                    db = self.db
    4.54 +                port = int(db[key].getData())
    4.55 +        except: pass
    4.56 +        return EventChannel.interdomain(0, self.id, port1=port, port2=0)
    4.57 +        
    4.58      def create_channel(self):
    4.59          """Create the channels to the domain.
    4.60          """
    4.61 -        self.store_channel = self.eventChannel("store_channel")
    4.62 -        self.console_channel = self.eventChannel("console/console_channel")
    4.63 +        self.store_channel = self.eventChannelOld("store_channel")
    4.64 +        self.console_channel = self.eventChannel("console", "port")
    4.65  
    4.66      def create_configured_devices(self):
    4.67          devices = sxp.children(self.config, 'device')
    4.68 @@ -1071,11 +1085,6 @@ class XendDomainInfo:
    4.69              backend = blkif.getBackend(0)
    4.70              backend.connect(recreate=self.recreate)
    4.71  
    4.72 -    def publish_console(self):
    4.73 -        db = DBMap(db=XenNode("/console/%d" % self.id))
    4.74 -        db['domain'] = self.db.getPath()
    4.75 -        db.saveDB(save=True)
    4.76 -
    4.77      def configure_fields(self):
    4.78          """Process the vm configuration fields using the registered handlers.
    4.79          """
    4.80 @@ -1143,7 +1152,7 @@ class XendDomainInfo:
    4.81  
    4.82      def dom0_init_store(self):
    4.83          if not self.store_channel:
    4.84 -            self.store_channel = self.eventChannel("store_channel")
    4.85 +            self.store_channel = self.eventChannelOld("store_channel")
    4.86          self.store_mfn = xc.init_store(self.store_channel.port2)
    4.87          if self.store_mfn >= 0:
    4.88              self.db.introduceDomain(self.id, self.store_mfn,