|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 4/6] libxl: libxl_{primary_, }console_exec now take notify_fd argument
The new argument will be passed down to xenconsole process, which then
uses it to notify readiness.
Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
tools/libxl/libxl.c | 15 +++++++++++----
tools/libxl/libxl.h | 43 ++++++++++++++++++++++++++++++++++++++++---
2 files changed, 51 insertions(+), 7 deletions(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 9a7104c..da79dc1 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1777,12 +1777,13 @@ out:
}
int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num,
- libxl_console_type type)
+ libxl_console_type type, int notify_fd)
{
GC_INIT(ctx);
char *p = GCSPRINTF("%s/xenconsole", libxl__private_bindir_path());
char *domid_s = GCSPRINTF("%d", domid);
char *cons_num_s = GCSPRINTF("%d", cons_num);
+ char *notify_fd_s;
char *cons_type_s;
switch (type) {
@@ -1796,7 +1797,13 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid,
int cons_num,
goto out;
}
- execl(p, p, domid_s, "--num", cons_num_s, "--type", cons_type_s, (void
*)NULL);
+ 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);
+ } else
+ execl(p, p, domid_s, "--num", cons_num_s, "--type", cons_type_s,
+ (void *)NULL);
out:
GC_FREE;
@@ -1868,7 +1875,7 @@ out:
return rc;
}
-int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm)
+int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm, int
notify_fd)
{
uint32_t domid;
int cons_num;
@@ -1877,7 +1884,7 @@ int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t
domid_vm)
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);
+ return libxl_console_exec(ctx, domid, cons_num, type, notify_fd);
}
int libxl_primary_console_get_tty(libxl_ctx *ctx, uint32_t domid_vm,
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 9b59e6e..030aad5 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -67,6 +67,14 @@
* the same $(XEN_VERSION) (e.g. throughout a major release).
*/
+/* LIBXL_HAVE_CONSOLE_NOTIFY_FD
+ *
+ * If this is defined, libxl_console_exec and
+ * libxl_primary_console_exe take a notify_fd parameter. That
+ * parameter will be used to notify the caller that the console is connected.
+ */
+#define LIBXL_HAVE_CONSOLE_NOTIFY_FD 1
+
/* LIBXL_HAVE_CONST_COPY_AND_LENGTH_FUNCTIONS
*
* If this is defined, the copy functions have constified src parameter and the
@@ -1438,15 +1446,44 @@ int libxl_wait_for_memory_target(libxl_ctx *ctx,
uint32_t domid, int wait_secs);
#endif
int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass);
-int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num,
libxl_console_type type);
+
+/*
+ * If notify_fd is not -1, xenconsole will write 0x00 to it to nofity
+ * 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_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
* if the guest is using stubdoms).
* This function can be called after creating the device model, in
* case of HVM guests, and before libxl_run_bootloader in case of PV
- * guests using pygrub. */
-int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm);
+ * 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.
+ */
+int libxl_primary_console_exec(libxl_ctx *ctx, uint32_t domid_vm,
+ int notify_fd);
+
+#if defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040800
+
+static inline int libxl_console_exec_0x040700(libxl_ctx *ctx,
+ uint32_t domid, int cons_num,
+ libxl_console_type type)
+{
+ return libxl_console_exec(ctx, domid, cons_num, type, -1);
+}
+#define libxl_console_exec libxl_console_exec_0x040700
+
+static inline libxl_primary_console_exec_0x040700(libxl_ctx *ctx,
+ uint32_t domid_vm)
+{
+ return libxl_primary_console_exec(ctx, domid_vm, -1);
+}
+#define libxl_primary_console_exec libxl_primary_console_exec_0x040700
+
+#endif
/* libxl_console_get_tty retrieves the specified domain's console tty path
* and stores it in path. Caller is responsible for freeing the memory.
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |