From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: Re: [PATCH 2 of 5] xenconsole support for multiple consoles
Date: Thu, 11 Jun 2009 16:10:53 +0100 [thread overview]
Message-ID: <4A311E7D.5060703@eu.citrix.com> (raw)
In-Reply-To: <4A311DCB.10006@eu.citrix.com>
Stefano Stabellini wrote:
> 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>
>
Sorry I sent two copies of the third patch.
This is the correct xenconsole patch.
---
diff -r 5f407cb2fc00 tools/console/client/main.c
--- a/tools/console/client/main.c Thu Jun 11 15:19:43 2009 +0100
+++ b/tools/console/client/main.c Thu Jun 11 15:24:27 2009 +0100
@@ -71,6 +71,7 @@
"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 @@
{
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,14 +277,15 @@
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);
@@ -299,13 +303,13 @@
signal(SIGTERM, sighandler);
- path = xs_get_domain_path(xs, domid);
+ dom_path = xs_get_domain_path(xs, domid);
+ if (dom_path == NULL)
+ err(errno, "xs_get_domain_path()");
+ path = malloc(strlen(dom_path) + strlen("/serial/0/tty") + 3);
if (path == NULL)
- err(errno, "xs_get_domain_path()");
- path = realloc(path, strlen(path) + strlen("/console/tty") + 1);
- 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 @@
restore_term(STDIN_FILENO, &attr);
free(path);
+ free(dom_path);
return 0;
}
diff -r 5f407cb2fc00 tools/python/xen/xm/console.py
--- a/tools/python/xen/xm/console.py Thu Jun 11 15:19:43 2009 +0100
+++ b/tools/python/xen/xm/console.py Thu Jun 11 15:24:27 2009 +0100
@@ -24,8 +24,8 @@
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 -r 5f407cb2fc00 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Thu Jun 11 15:19:43 2009 +0100
+++ b/tools/python/xen/xm/main.py Thu Jun 11 15:24:27 2009 +0100
@@ -1779,12 +1779,13 @@
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 @@
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 @@
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):
prev parent reply other threads:[~2009-06-11 15:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-11 15:07 [PATCH 2 of 5] xenconsole support for multiple consoles Stefano Stabellini
2009-06-11 15:10 ` Stefano Stabellini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A311E7D.5060703@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.