|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] xl console: Add interactive option
Added an interactive option to the 'xl console'-command that
forwards the input stream of the console to the underlying pty.
Made corresponding changes to libxl, xl and xenconsole.
Signed-off-by: Felix Schmoll <eggi.innovations@xxxxxxxxx>
---
tools/console/client/main.c | 4 ++++
tools/libxl/libxl.h | 5 +++--
tools/libxl/libxl_console.c | 19 ++++++++++++++-----
tools/xl/xl_console.c | 11 +++++++----
tools/xl/xl_vmcontrol.c | 2 +-
5 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/tools/console/client/main.c b/tools/console/client/main.c
index 977779f034..a3c4b00835 100644
--- a/tools/console/client/main.c
+++ b/tools/console/client/main.c
@@ -334,6 +334,7 @@ int main(int argc, char **argv)
{ "num", 1, 0, 'n' },
{ "help", 0, 0, 'h' },
{ "start-notify-fd", 1, 0, 's' },
+ { "pipe", 0, 0, 'p' },
{ 0 },
};
@@ -370,6 +371,9 @@ int main(int argc, char **argv)
case 's':
start_notify_fd = atoi(optarg);
break;
+ case 'p':
+ interactive = 1;
+ break;
default:
fprintf(stderr, "Invalid argument\n");
fprintf(stderr, "Try `%s --help' for more
information.\n",
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index cf8687aa7e..a55f9b1cc7 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1499,7 +1499,8 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid,
int autopass);
* the caller that it has connected to the guest console.
*/
int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num,
- libxl_console_type type, int notify_fd);
+ libxl_console_type type, int notify_fd,
+ int interactive);
/* libxl_primary_console_exec finds the domid and console number
* corresponding to the primary console of the given vm, then calls
* libxl_console_exec with the right arguments (domid might be different
@@ -1511,7 +1512,7 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid,
int cons_num,
* the caller that it has connected to the guest console.
*/
int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm,
- int notify_fd);
+ int notify_fd, int interactive);
#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040800
diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
index 446e766911..86b8062be6 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -51,7 +51,8 @@ out:
}
int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num,
- libxl_console_type type, int notify_fd)
+ libxl_console_type type, int notify_fd,
+ int interactive)
{
GC_INIT(ctx);
char *p = GCSPRINTF("%s/xenconsole", libxl__private_bindir_path());
@@ -59,6 +60,7 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int
cons_num,
char *cons_num_s = GCSPRINTF("%d", cons_num);
char *notify_fd_s;
char *cons_type_s;
+ char interactive_str[] = "--pipe";
switch (type) {
case LIBXL_CONSOLE_TYPE_PV:
@@ -71,13 +73,18 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int
cons_num,
goto out;
}
+ if(!interactive) {
+ interactive_str[0] = '\0';
+ }
+
if (notify_fd != -1) {
notify_fd_s = GCSPRINTF("%d", notify_fd);
execl(p, p, domid_s, "--num", cons_num_s, "--type", cons_type_s,
- "--start-notify-fd", notify_fd_s, (void *)NULL);
+ "--start-notify-fd", notify_fd_s, interactive_str,
+ (void *)NULL);
} else {
execl(p, p, domid_s, "--num", cons_num_s, "--type", cons_type_s,
- (void *)NULL);
+ interactive_str, (void *)NULL);
}
out:
@@ -151,7 +158,8 @@ out:
return rc;
}
-int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm, int
notify_fd)
+int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm,
+ int notify_fd, int interactive)
{
uint32_t domid;
int cons_num;
@@ -160,7 +168,8 @@ int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t
domid_vm, int notify_fd)
rc = libxl__primary_console_find(ctx, domid_vm, &domid, &cons_num, &type);
if ( rc ) return rc;
- return libxl_console_exec(ctx, domid, cons_num, type, notify_fd);
+ return libxl_console_exec(ctx, domid, cons_num, type, notify_fd,
+ interactive);
}
int libxl_primary_console_get_tty(libxl_ctx *ctx, uint32_t domid_vm,
diff --git a/tools/xl/xl_console.c b/tools/xl/xl_console.c
index 0508ddaa32..68a2096dfc 100644
--- a/tools/xl/xl_console.c
+++ b/tools/xl/xl_console.c
@@ -25,10 +25,10 @@
int main_console(int argc, char **argv)
{
uint32_t domid;
- int opt = 0, num = 0;
+ int opt = 0, num = 0, interactive = 0;
libxl_console_type type = 0;
- SWITCH_FOREACH_OPT(opt, "n:t:", NULL, "console", 1) {
+ SWITCH_FOREACH_OPT(opt, "n:t:i", NULL, "console", 1) {
case 't':
if (!strcmp(optarg, "pv"))
type = LIBXL_CONSOLE_TYPE_PV;
@@ -42,13 +42,16 @@ int main_console(int argc, char **argv)
case 'n':
num = atoi(optarg);
break;
+ case 'i':
+ interactive = 1;
+ break;
}
domid = find_domain(argv[optind]);
if (!type)
- libxl_primary_console_exec(ctx, domid, -1);
+ libxl_primary_console_exec(ctx, domid, -1, interactive);
else
- libxl_console_exec(ctx, domid, num, type, -1);
+ libxl_console_exec(ctx, domid, num, type, -1, interactive);
fprintf(stderr, "Unable to attach console\n");
return EXIT_FAILURE;
}
diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c
index 89c2b25ded..5472f43e6f 100644
--- a/tools/xl/xl_vmcontrol.c
+++ b/tools/xl/xl_vmcontrol.c
@@ -632,7 +632,7 @@ static void autoconnect_console(libxl_ctx *ctx_ignored,
postfork();
sleep(1);
- libxl_primary_console_exec(ctx, bldomid, notify_fd);
+ libxl_primary_console_exec(ctx, bldomid, notify_fd, 0);
/* Do not return. xl continued in child process */
perror("xl: unable to exec console client");
_exit(1);
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |