ia64/xen-unstable

changeset 14993:650007cf390d

[pv console] Move console information in xenstore to serial/0/.
Support information in console/ in a backwards compatible fashion.
This puts the serial port information for pv domains at the same
location where it is for hvm domains.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author Christian Limpach <Christian.Limpach@xensource.com>
date Tue May 01 14:17:01 2007 +0100 (2007-05-01)
parents 9ceacd71949b
children c1fafdcdb19a
files tools/console/daemon/io.c
line diff
     1.1 --- a/tools/console/daemon/io.c	Tue May 01 14:01:01 2007 +0100
     1.2 +++ b/tools/console/daemon/io.c	Tue May 01 14:17:01 2007 +0100
     1.3 @@ -61,6 +61,8 @@ struct domain
     1.4  	struct buffer buffer;
     1.5  	struct domain *next;
     1.6  	char *conspath;
     1.7 +	char *serialpath;
     1.8 +	int use_consolepath;
     1.9  	int ring_ref;
    1.10  	evtchn_port_t local_port;
    1.11  	evtchn_port_t remote_port;
    1.12 @@ -164,7 +166,20 @@ static int domain_create_tty(struct doma
    1.13  			tcsetattr(master, TCSAFLUSH, &term);
    1.14  		}
    1.15  
    1.16 -		success = asprintf(&path, "%s/limit", dom->conspath) != -1;
    1.17 +		if (dom->use_consolepath) {
    1.18 +			success = asprintf(&path, "%s/limit", dom->conspath) !=
    1.19 +				-1;
    1.20 +			if (!success)
    1.21 +				goto out;
    1.22 +			data = xs_read(xs, XBT_NULL, path, &len);
    1.23 +			if (data) {
    1.24 +				dom->buffer.max_capacity = strtoul(data, 0, 0);
    1.25 +				free(data);
    1.26 +			}
    1.27 +			free(path);
    1.28 +		}
    1.29 +
    1.30 +		success = asprintf(&path, "%s/limit", dom->serialpath) != -1;
    1.31  		if (!success)
    1.32  			goto out;
    1.33  		data = xs_read(xs, XBT_NULL, path, &len);
    1.34 @@ -174,7 +189,7 @@ static int domain_create_tty(struct doma
    1.35  		}
    1.36  		free(path);
    1.37  
    1.38 -		success = asprintf(&path, "%s/tty", dom->conspath) != -1;
    1.39 +		success = asprintf(&path, "%s/tty", dom->serialpath) != -1;
    1.40  		if (!success)
    1.41  			goto out;
    1.42  		success = xs_write(xs, XBT_NULL, path, slave, strlen(slave));
    1.43 @@ -182,6 +197,18 @@ static int domain_create_tty(struct doma
    1.44  		if (!success)
    1.45  			goto out;
    1.46  
    1.47 +		if (dom->use_consolepath) {
    1.48 +			success = asprintf(&path, "%s/tty", dom->conspath) !=
    1.49 +				-1;
    1.50 +			if (!success)
    1.51 +				goto out;
    1.52 +			success = xs_write(xs, XBT_NULL, path, slave,
    1.53 +					   strlen(slave));
    1.54 +			free(path);
    1.55 +			if (!success)
    1.56 +				goto out;
    1.57 +		}
    1.58 +
    1.59  		if (fcntl(master, F_SETFL, O_NONBLOCK) == -1)
    1.60  			goto out;
    1.61  	}
    1.62 @@ -228,12 +255,20 @@ static int domain_create_ring(struct dom
    1.63  {
    1.64  	int err, remote_port, ring_ref, rc;
    1.65  
    1.66 -	err = xs_gather(xs, dom->conspath,
    1.67 +	err = xs_gather(xs, dom->serialpath,
    1.68  			"ring-ref", "%u", &ring_ref,
    1.69  			"port", "%i", &remote_port,
    1.70  			NULL);
    1.71 -	if (err)
    1.72 -		goto out;
    1.73 +	if (err) {
    1.74 +		err = xs_gather(xs, dom->conspath,
    1.75 +				"ring-ref", "%u", &ring_ref,
    1.76 +				"port", "%i", &remote_port,
    1.77 +				NULL);
    1.78 +		if (err)
    1.79 +			goto out;
    1.80 +		dom->use_consolepath = 1;
    1.81 +	} else
    1.82 +		dom->use_consolepath = 0;
    1.83  
    1.84  	if ((ring_ref == dom->ring_ref) && (remote_port == dom->remote_port))
    1.85  		goto out;
    1.86 @@ -301,10 +336,16 @@ static bool watch_domain(struct domain *
    1.87  
    1.88  	sprintf(domid_str, "dom%u", dom->domid);
    1.89  	if (watch) {
    1.90 -		success = xs_watch(xs, dom->conspath, domid_str);
    1.91 -		if (success)
    1.92 -			domain_create_ring(dom);
    1.93 +		success = xs_watch(xs, dom->serialpath, domid_str);
    1.94 +		if (success) {
    1.95 +			success = xs_watch(xs, dom->conspath, domid_str);
    1.96 +			if (success)
    1.97 +				domain_create_ring(dom);
    1.98 +			else
    1.99 +				xs_unwatch(xs, dom->serialpath, domid_str);
   1.100 +		}
   1.101  	} else {
   1.102 +		success = xs_unwatch(xs, dom->serialpath, domid_str);
   1.103  		success = xs_unwatch(xs, dom->conspath, domid_str);
   1.104  	}
   1.105  
   1.106 @@ -324,6 +365,15 @@ static struct domain *create_domain(int 
   1.107  	}
   1.108  
   1.109  	dom->domid = domid;
   1.110 +
   1.111 +	dom->serialpath = xs_get_domain_path(xs, dom->domid);
   1.112 +	s = realloc(dom->serialpath, strlen(dom->serialpath) +
   1.113 +		    strlen("/serial/0") + 1);
   1.114 +	if (s == NULL)
   1.115 +		goto out;
   1.116 +	dom->serialpath = s;
   1.117 +	strcat(dom->serialpath, "/serial/0");
   1.118 +
   1.119  	dom->conspath = xs_get_domain_path(xs, dom->domid);
   1.120  	s = realloc(dom->conspath, strlen(dom->conspath) +
   1.121  		    strlen("/console") + 1);
   1.122 @@ -357,6 +407,7 @@ static struct domain *create_domain(int 
   1.123  
   1.124  	return dom;
   1.125   out:
   1.126 +	free(dom->serialpath);
   1.127  	free(dom->conspath);
   1.128  	free(dom);
   1.129  	return NULL;
   1.130 @@ -397,6 +448,9 @@ static void cleanup_domain(struct domain
   1.131  	free(d->buffer.data);
   1.132  	d->buffer.data = NULL;
   1.133  
   1.134 +	free(d->serialpath);
   1.135 +	d->serialpath = NULL;
   1.136 +
   1.137  	free(d->conspath);
   1.138  	d->conspath = NULL;
   1.139