|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH 4/8] libxl: wait up to 5s in libxl_console_exec for xenconsoled
Wait until the tty node is available before exec'ing xenconsole.
Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
tools/libxl/libxl.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 0bc805e..a611b29 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1780,10 +1780,14 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid,
int cons_num,
libxl_console_type type)
{
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 *cons_type_s;
+ char *tty_path;
+ const char *tty;
+ int retry = 50; /* wait for 50 * 0.1 = 5 s for xenconsoled */
switch (type) {
case LIBXL_CONSOLE_TYPE_PV:
@@ -1793,6 +1797,28 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid,
int cons_num,
cons_type_s = "serial";
break;
default:
+ rc = ERROR_FAIL;
+ goto out;
+ }
+
+ /* Make sure tty shows up before exec'ing xenconsole client */
+ rc = libxl__console_tty_path(gc, domid, cons_num, type, &tty_path);
+ if (rc) goto out;
+
+ while (retry-- > 0) {
+ rc = libxl__xs_read_checked(gc, XBT_NULL, tty_path, &tty);
+ if (rc) goto out;
+
+ if (tty != NULL && tty[0] != '\0')
+ break;
+
+ LOG(DEBUG, "TTY is not yet ready, retry");
+ usleep(100000);
+ }
+
+ if (retry == 0 && (!tty || tty[0] == '\0')) {
+ LOG(ERROR, "Failed to get tty from xenstore\n");
+ rc = ERROR_FAIL;
goto out;
}
@@ -1800,7 +1826,7 @@ int libxl_console_exec(libxl_ctx *ctx, uint32_t domid,
int cons_num,
out:
GC_FREE;
- return ERROR_FAIL;
+ return rc;
}
int libxl_console_get_tty(libxl_ctx *ctx, uint32_t domid, int cons_num,
--
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 |