aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-06-16 11:24:58 +0100
committerKeir Fraser <keir.fraser@citrix.com>2009-06-16 11:24:58 +0100
commitc811d0d548ac0124a899428d7c813267c977c651 (patch)
treecb9058277092152148a54cfaf686bcbb3f3a6f46 /tools
parentf84ee327e5b8311dfa73f059453ef80a5e8a2af2 (diff)
downloadxen-c811d0d548ac0124a899428d7c813267c977c651.tar.gz
xen-c811d0d548ac0124a899428d7c813267c977c651.tar.bz2
xen-c811d0d548ac0124a899428d7c813267c977c651.zip
xenconsole: support for multiple consoles per domain
This patch adds a new command line argument to xenconsole to specify to which console to connect to in case a domain has more than one. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/console/client/main.c33
-rw-r--r--tools/python/xen/xm/console.py4
-rw-r--r--tools/python/xen/xm/main.py9
3 files changed, 27 insertions, 19 deletions
diff --git a/tools/console/client/main.c b/tools/console/client/main.c
index 39556da5a0..b66baf8ae6 100644
--- a/tools/console/client/main.c
+++ b/tools/console/client/main.c
@@ -71,6 +71,7 @@ static void usage(const char *program) {
"Attaches to a virtual domain console\n"
"\n"
" -h, --help display this help and exit\n"
+ " -n, --num N use console number N\n"
, program);
}
@@ -255,15 +256,17 @@ int main(int argc, char **argv)
{
struct termios attr;
int domid;
- char *sopt = "h";
+ char *sopt = "hn:";
int ch;
+ unsigned int num = 0;
int opt_ind=0;
struct option lopt[] = {
+ { "num", 1, 0, 'n' },
{ "help", 0, 0, 'h' },
{ 0 },
};
- char *path;
+ char *dom_path = NULL, *path = NULL;
int spty, xsfd;
struct xs_handle *xs;
char *end;
@@ -274,16 +277,17 @@ int main(int argc, char **argv)
usage(argv[0]);
exit(0);
break;
+ case 'n':
+ num = atoi(optarg);
+ break;
+ default:
+ fprintf(stderr, "Invalid argument\n");
+ fprintf(stderr, "Try `%s --help' for more information.\n",
+ argv[0]);
+ exit(EINVAL);
}
}
- if ((argc - optind) != 1) {
- fprintf(stderr, "Invalid number of arguments\n");
- fprintf(stderr, "Try `%s --help' for more information.\n",
- argv[0]);
- exit(EINVAL);
- }
-
domid = strtol(argv[optind], &end, 10);
if (end && *end) {
fprintf(stderr, "Invalid DOMID `%s'\n", argv[optind]);
@@ -299,13 +303,13 @@ int main(int argc, char **argv)
signal(SIGTERM, sighandler);
- path = xs_get_domain_path(xs, domid);
- if (path == NULL)
+ dom_path = xs_get_domain_path(xs, domid);
+ if (dom_path == NULL)
err(errno, "xs_get_domain_path()");
- path = realloc(path, strlen(path) + strlen("/console/tty") + 1);
+ path = malloc(strlen(dom_path) + strlen("/serial/0/tty") + 3);
if (path == NULL)
- err(ENOMEM, "realloc");
- strcat(path, "/console/tty");
+ err(ENOMEM, "malloc");
+ snprintf(path, strlen(dom_path) + strlen("/serial/0/tty") + 2, "%s/serial/%d/tty", dom_path, num);
/* FIXME consoled currently does not assume domain-0 doesn't have a
console which is good when we break domain-0 up. To keep us
@@ -336,5 +340,6 @@ int main(int argc, char **argv)
restore_term(STDIN_FILENO, &attr);
free(path);
+ free(dom_path);
return 0;
}
diff --git a/tools/python/xen/xm/console.py b/tools/python/xen/xm/console.py
index 0b83f1139d..f31d561836 100644
--- a/tools/python/xen/xm/console.py
+++ b/tools/python/xen/xm/console.py
@@ -24,8 +24,8 @@ from xen.util import utils
XENCONSOLE = "xenconsole"
-def execConsole(domid):
- xen.util.auxbin.execute(XENCONSOLE, [str(domid)])
+def execConsole(domid, num = 0):
+ xen.util.auxbin.execute(XENCONSOLE, [str(domid), "--num", str(num)])
class OurXenstoreConnection:
diff --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py
index bea552452e..d14eabcc91 100644
--- a/tools/python/xen/xm/main.py
+++ b/tools/python/xen/xm/main.py
@@ -1779,12 +1779,13 @@ def xm_info(args):
print "%-23s:" % x[0], x[1]
def xm_console(args):
- arg_check(args, "console", 1, 2)
+ arg_check(args, "console", 1, 3)
+ num = 0
quiet = False;
try:
- (options, params) = getopt.gnu_getopt(args, 'q', ['quiet'])
+ (options, params) = getopt.gnu_getopt(args, 'qn:', ['quiet', 'num'])
except getopt.GetoptError, opterr:
err(opterr)
usage('console')
@@ -1792,6 +1793,8 @@ def xm_console(args):
for (k, v) in options:
if k in ['-q', '--quiet']:
quiet = True
+ elif k in ['-n', '--num']:
+ num = int(v[0])
else:
assert False
@@ -1819,7 +1822,7 @@ def xm_console(args):
else:
raise xmlrpclib.Fault(0, "Domain '%s' is not started" % dom)
- console.execConsole(domid)
+ console.execConsole(domid, num)
def domain_name_to_domid(domain_name):