From: Peter Hoyes
Add -e argument to xl console and pass to new escape_character argument
of libxl_console_exec.
Introduce a new API version to support this new argument and advertise
the new functionality in libxl.h
In libxl_console_exec, there are currently two call sites to execl,
which uses varargs, in order to support optionally passing
'start-notify-fd' to the console client. In order to support passing
the 'escape' argument optionally too, refactor to instead have a single
call site to execv, which has the same behavior but takes an array of
arguments.
If -e is not specified, --escape is not passed to the console client and
the existing value (^]) is used as a default.
Update the xl docs.
Signed-off-by: Peter Hoyes
---
Changes in v6:
- Fix the new compatiblity functions to use last presented version
- Fix the arguments of the existing compatibility functions
Changes in v5:
- Add this changelog
- Fix comment style in libxl_console_exec
Changes in v4:
- Document xl console -e argument in xl.1.pod.in
- Add changes for libxl API version compatibility
Changes in v3:
- Re-add the Reviewed-By tag accidentally removed in v2
Changes in v2:
- Drop the tags intended only for internal use at Arm
docs/man/xl.1.pod.in | 8 +-
tools/include/libxl.h| 43
tools/libs/light/libxl_console.c | 30 --
tools/xl/xl_cmdtable.c | 3 ++-
tools/xl/xl_console.c| 10 +---
tools/xl/xl_vmcontrol.c | 2 +-
6 files changed, 77 insertions(+), 19 deletions(-)
diff --git a/docs/man/xl.1.pod.in b/docs/man/xl.1.pod.in
index 101e14241d..9ba22a8fa2 100644
--- a/docs/man/xl.1.pod.in
+++ b/docs/man/xl.1.pod.in
@@ -222,7 +222,8 @@ Attach to the console of a domain specified by
I. If you've set up
your domains to have a traditional login console this will look much like a
normal text login screen.
-Use the key combination Ctrl+] to detach from the domain console.
+Use the escape character key combination (default Ctrl+]) to detach from the
+domain console.
B
@@ -239,6 +240,11 @@ emulated serial for HVM guests and PV console for PV
guests.
Connect to console number I. Console numbers start from 0.
+=item I<-e escapechar>
+
+Customize the escape sequence used to detach from the domain console to
+I. If not specified, the value "^]" is used.
+
=back
=item B [I] I
diff --git a/tools/include/libxl.h b/tools/include/libxl.h
index cac641a7eb..de29f11bc9 100644
--- a/tools/include/libxl.h
+++ b/tools/include/libxl.h
@@ -81,6 +81,15 @@
*/
#define LIBXL_HAVE_CONSOLE_NOTIFY_FD 1
+/* LIBXL_HAVE_CONSOLE_ESCAPE_CHARACTER
+ *
+ * If this is defined, libxl_console_exec and
+ * libxl_primary_console_exe take an escape_character parameter. That
+ * parameter will be used to modify the escape sequence used to exit the
+ * console.
+ */
+#define LIBXL_HAVE_CONSOLE_ESCAPE_CHARACTER 1
+
/* LIBXL_HAVE_CONST_COPY_AND_LENGTH_FUNCTIONS
*
* If this is defined, the copy functions have constified src parameter and the
@@ -790,7 +799,8 @@ typedef struct libxl__ctx libxl_ctx;
#if LIBXL_API_VERSION != 0x040200 && LIBXL_API_VERSION != 0x040300 && \
LIBXL_API_VERSION != 0x040400 && LIBXL_API_VERSION != 0x040500 && \
LIBXL_API_VERSION != 0x040700 && LIBXL_API_VERSION != 0x040800 && \
-LIBXL_API_VERSION != 0x041300 && LIBXL_API_VERSION != 0x041400
+LIBXL_API_VERSION != 0x041300 && LIBXL_API_VERSION != 0x041400 && \
+LIBXL_API_VERSION != 0x041800
#error Unknown LIBXL_API_VERSION
#endif
#endif
@@ -1958,7 +1968,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,
+ char* escape_character);
/* 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
@@ -1968,9 +1979,12 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid,
int cons_num,
* guests using pygrub.
* If notify_fd is not -1, xenconsole will write 0x00 to it to nofity
* the caller that it has connected to the guest console.
+ * If escape_character is not NULL, the provided value is used to exit
+ * the guest console.
*/
int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm,
- int notify_fd);
+ int notify_fd,
+ char* escape_character);
#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040800
@@ -1978,17 +1992,36 @@ static inline int libxl_console_exec_0x040700(libxl_ctx
*ctx,
uint32_t domid, int cons_num,