[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH 5/8] 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 a611b29..7f2f2b6 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -1777,13 +1777,14 @@ 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); int rc; 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; char *tty_path; const char *tty; @@ -1822,7 +1823,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; @@ -1894,7 +1901,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; @@ -1903,7 +1910,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 48a43ce..f821e05 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 @@ -1413,15 +1421,44 @@ int libxl_wait_for_free_memory(libxl_ctx *ctx, uint32_t domid, uint32_t memory_k int libxl_wait_for_memory_target(libxl_ctx *ctx, uint32_t domid, int wait_secs); 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 |