[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] libxl: factor out libxl__console_tty_path
commit 88502c075a393508a6315c4f905132b03be42347 Author: Wei Liu <wei.liu2@xxxxxxxxxx> AuthorDate: Mon Aug 1 12:20:09 2016 +0100 Commit: Wei Liu <wei.liu2@xxxxxxxxxx> CommitDate: Mon Aug 8 11:41:40 2016 +0100 libxl: factor out libxl__console_tty_path No other user yet. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- tools/libxl/libxl.c | 57 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 1de293b..9a7104c 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -1742,6 +1742,40 @@ static void domain_destroy_domid_cb(libxl__egc *egc, dis->callback(egc, dis, rc); } +static int libxl__console_tty_path(libxl__gc *gc, uint32_t domid, int cons_num, + libxl_console_type type, char **tty_path) +{ + int rc; + char *dom_path; + + dom_path = libxl__xs_get_dompath(gc, domid); + if (!dom_path) { + rc = ERROR_FAIL; + goto out; + } + + switch (type) { + case LIBXL_CONSOLE_TYPE_SERIAL: + *tty_path = GCSPRINTF("%s/serial/%d/tty", dom_path, cons_num); + rc = 0; + break; + case LIBXL_CONSOLE_TYPE_PV: + if (cons_num == 0) + *tty_path = GCSPRINTF("%s/console/tty", dom_path); + else + *tty_path = GCSPRINTF("%s/device/console/%d/tty", dom_path, + cons_num); + rc = 0; + break; + default: + rc = ERROR_INVAL; + goto out; + } + +out: + return rc; +} + int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_type type) { @@ -1773,30 +1807,13 @@ int libxl_console_get_tty(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_type type, char **path) { GC_INIT(ctx); - char *dom_path; char *tty_path; char *tty; int rc; - dom_path = libxl__xs_get_dompath(gc, domid); - if (!dom_path) { - rc = ERROR_FAIL; - goto out; - } - - switch (type) { - case LIBXL_CONSOLE_TYPE_SERIAL: - tty_path = GCSPRINTF("%s/serial/%d/tty", dom_path, cons_num); - break; - case LIBXL_CONSOLE_TYPE_PV: - if (cons_num == 0) - tty_path = GCSPRINTF("%s/console/tty", dom_path); - else - tty_path = GCSPRINTF("%s/device/console/%d/tty", dom_path, - cons_num); - break; - default: - rc = ERROR_INVAL; + rc = libxl__console_tty_path(gc, domid, cons_num, type, &tty_path); + if (rc) { + LOG(ERROR, "Failed to get tty path for domain %d\n", domid); goto out; } -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |