From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>
Subject: [RFC PATCH 7/8] xl: use xenconsole startup protocol
Date: Mon, 1 Aug 2016 14:16:24 +0100 [thread overview]
Message-ID: <1470057385-31599-8-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1470057385-31599-1-git-send-email-wei.liu2@citrix.com>
If user asks xl to automatically connect to console when creating a
guest, use the new startup protocol before trying to unpause domain so
that we don't lose any console output.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
tools/libxl/xl_cmdimpl.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 51dc7a0..bd64149 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -2728,6 +2728,7 @@ static void autoconnect_console(libxl_ctx *ctx_ignored,
libxl_event *ev, void *priv)
{
uint32_t bldomid = ev->domid;
+ int notify_fd = *(int*)priv; /* write end of the notification pipe */
libxl_event_free(ctx, ev);
@@ -2740,7 +2741,7 @@ static void autoconnect_console(libxl_ctx *ctx_ignored,
postfork();
sleep(1);
- libxl_primary_console_exec(ctx, bldomid);
+ libxl_primary_console_exec(ctx, bldomid, notify_fd);
/* Do not return. xl continued in child process */
perror("xl: unable to exec console client");
_exit(1);
@@ -2810,6 +2811,7 @@ static int create_domain(struct domain_create *dom_info)
int restore_fd_to_close = -1;
int send_back_fd = -1;
const libxl_asyncprogress_how *autoconnect_console_how;
+ int notify_pipe[2] = { -1, -1 };
struct save_file_header hdr;
uint32_t domid_soft_reset = INVALID_DOMID;
@@ -2997,7 +2999,15 @@ start:
libxl_asyncprogress_how autoconnect_console_how_buf;
if ( dom_info->console_autoconnect ) {
+ if (pipe(notify_pipe)) {
+ fprintf(stderr,
+ "Failed to create console notification pipe, errno %d\n",
+ errno);
+ ret = ERROR_FAIL;
+ goto error_out;
+ }
autoconnect_console_how_buf.callback = autoconnect_console;
+ autoconnect_console_how_buf.for_callback = ¬ify_pipe[1];
autoconnect_console_how = &autoconnect_console_how_buf;
}else{
autoconnect_console_how = 0;
@@ -3047,6 +3057,18 @@ start:
restore_fd_to_close = -1;
}
+ if (autoconnect_console_how) {
+ char buf[1];
+ if (read(notify_pipe[0], buf, 1) != 1 && buf[0] != 0x00) {
+ fprintf(stderr,
+ "Failed to get notification from xenconsole, errno %d\n",
+ errno);
+ }
+ close(notify_pipe[0]);
+ close(notify_pipe[1]);
+ notify_pipe[0] = notify_pipe[1] = -1;
+ }
+
if (!paused)
libxl_domain_unpause(ctx, domid);
@@ -3754,9 +3776,9 @@ int main_console(int argc, char **argv)
domid = find_domain(argv[optind]);
if (!type)
- libxl_primary_console_exec(ctx, domid);
+ libxl_primary_console_exec(ctx, domid, -1);
else
- libxl_console_exec(ctx, domid, num, type);
+ libxl_console_exec(ctx, domid, num, type, -1);
fprintf(stderr, "Unable to attach console\n");
return EXIT_FAILURE;
}
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-08-01 13:16 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-29 12:07 [XTF PATCH] xtf-runner: fix two synchronisation issues Wei Liu
2016-07-29 12:43 ` Andrew Cooper
2016-07-29 12:58 ` Wei Liu
2016-07-29 13:06 ` Andrew Cooper
2016-07-29 13:12 ` Wei Liu
2016-07-29 13:23 ` Andrew Cooper
2016-07-29 13:26 ` Wei Liu
2016-07-29 14:31 ` Ian Jackson
2016-07-29 14:55 ` Wei Liu
2016-07-29 16:18 ` Ian Jackson
2016-07-29 16:35 ` Andrew Cooper
2016-07-29 16:41 ` Wei Liu
2016-07-29 15:05 ` Andrew Cooper
2016-08-01 13:16 ` [RFC PATCH 0/8] Fix console " Wei Liu
2016-08-01 13:16 ` [RFC PATCH 1/8] tools/console: fix help string in client Wei Liu
2016-08-05 15:40 ` Ian Jackson
2016-08-01 13:16 ` [RFC PATCH 2/8] tools/console: introduce --start-notify-fd option for console client Wei Liu
2016-08-05 15:43 ` Ian Jackson
2016-08-01 13:16 ` [RFC PATCH 3/8] libxl: factor out libxl__console_tty_path Wei Liu
2016-08-05 15:44 ` Ian Jackson
2016-08-01 13:16 ` [RFC PATCH 4/8] libxl: wait up to 5s in libxl_console_exec for xenconsoled Wei Liu
2016-08-05 15:48 ` Ian Jackson
2016-08-01 13:16 ` [RFC PATCH 5/8] libxl: libxl_{primary_, }console_exec now take notify_fd argument Wei Liu
2016-08-05 15:49 ` Ian Jackson
2016-08-05 15:50 ` Ian Jackson
2016-08-01 13:16 ` [RFC PATCH 6/8] docs: document xenconsole startup protocol Wei Liu
2016-08-05 15:52 ` Ian Jackson
2016-08-01 13:16 ` Wei Liu [this message]
2016-08-05 15:55 ` [RFC PATCH 7/8] xl: use " Ian Jackson
2016-08-01 13:16 ` [RFC PATCH 8/8] tools/console: remove 5s bodge in console client Wei Liu
2016-08-05 15:57 ` Ian Jackson
2016-08-05 16:16 ` Wei Liu
2016-08-05 16:18 ` Ian Jackson
2016-08-05 16:28 ` Wei Liu
2016-08-05 16:32 ` Ian Jackson
2016-08-05 16:36 ` Wei Liu
2016-08-05 17:23 ` Wei Liu
2016-08-08 10:07 ` Ian Jackson
2016-08-01 14:04 ` [XTF PATCH] xtf-runner: use xl create -Fc directly Wei Liu
2016-07-29 13:27 ` [XTF PATCH] xtf-runner: fix two synchronisation issues Andrew Cooper
2016-07-29 14:21 ` Ian Jackson
2016-07-29 14:25 ` Wei Liu
2016-07-29 14:35 ` Ian Jackson
2016-07-29 14:46 ` Wei Liu
2016-07-29 14:26 ` Andrew Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1470057385-31599-8-git-send-email-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).