ia64/xen-unstable

changeset 6099:3d470e8d41f0

Make xenconsole more friendly when invoked directly.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Wed Aug 10 16:47:07 2005 +0000 (2005-08-10)
parents 49671266459c
children a5c488cd3627
files tools/console/client/main.c
line diff
     1.1 --- a/tools/console/client/main.c	Wed Aug 10 15:14:50 2005 +0000
     1.2 +++ b/tools/console/client/main.c	Wed Aug 10 16:47:07 2005 +0000
     1.3 @@ -162,14 +162,11 @@ int main(int argc, char **argv)
     1.4  	struct termios attr;
     1.5  	int domid;
     1.6  	int xc_handle;
     1.7 -	char *sopt = "hf:pc";
     1.8 +	char *sopt = "h";
     1.9  	int ch;
    1.10  	int opt_ind=0;
    1.11  	struct option lopt[] = {
    1.12  		{ "help",    0, 0, 'h' },
    1.13 -		{ "file",    1, 0, 'f' },
    1.14 -		{ "pty",     0, 0, 'p' },
    1.15 -		{ "ctty",    0, 0, 'c' },
    1.16  		{ 0 },
    1.17  
    1.18  	};
    1.19 @@ -178,6 +175,7 @@ int main(int argc, char **argv)
    1.20  	int spty;
    1.21  	unsigned int len = 0;
    1.22  	struct xs_handle *xs;
    1.23 +	char *end;
    1.24  
    1.25  	while((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) {
    1.26  		switch(ch) {
    1.27 @@ -195,7 +193,13 @@ int main(int argc, char **argv)
    1.28  		exit(EINVAL);
    1.29  	}
    1.30  	
    1.31 -	domid = atoi(argv[optind]);
    1.32 +	domid = strtol(argv[optind], &end, 10);
    1.33 +	if (end && *end) {
    1.34 +		fprintf(stderr, "Invalid DOMID `%s'\n", argv[optind]);
    1.35 +		fprintf(stderr, "Try `%s --help' for more information.\n",
    1.36 +			argv[0]);
    1.37 +		exit(EINVAL);
    1.38 +	}
    1.39  
    1.40  	xs = xs_daemon_open();
    1.41  	if (xs == NULL) {
    1.42 @@ -211,7 +215,11 @@ int main(int argc, char **argv)
    1.43  
    1.44  	snprintf(path, sizeof(path), "/console/%d/tty", domid);
    1.45  	str_pty = xs_read(xs, path, &len);
    1.46 -	if (str_pty == NULL) {
    1.47 +	/* FIXME consoled currently does not assume domain-0 doesn't have a
    1.48 +	   console which is good when we break domain-0 up.  To keep us
    1.49 +	   user friendly, we'll bail out here since no data will ever show
    1.50 +	   up on domain-0. */
    1.51 +	if (domid == 0 || str_pty == NULL) {
    1.52  		err(errno, "Could not read tty from store");
    1.53  	}
    1.54  	spty = open(str_pty, O_RDWR | O_NOCTTY);