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: [PATCH v2 2/6] tools/console: introduce --start-notify-fd option for console client
Date: Fri, 5 Aug 2016 18:41:30 +0100 [thread overview]
Message-ID: <1470418894-11358-3-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1470418894-11358-1-git-send-email-wei.liu2@citrix.com>
The console client will write 0x00 to that fd before entering console
loop to indicate its readiness.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
v2: properly handle write(2) errors
---
tools/console/client/main.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/tools/console/client/main.c b/tools/console/client/main.c
index be39700..977779f 100644
--- a/tools/console/client/main.c
+++ b/tools/console/client/main.c
@@ -77,6 +77,7 @@ static void usage(const char *program) {
" -h, --help display this help and exit\n"
" -n, --num N use console number N\n"
" --type TYPE console type. must be 'pv' or 'serial'\n"
+ " --start-notify-fd N file descriptor used to notify parent\n"
, program);
}
@@ -327,10 +328,12 @@ int main(int argc, char **argv)
int ch;
unsigned int num = 0;
int opt_ind=0;
+ int start_notify_fd = -1;
struct option lopt[] = {
{ "type", 1, 0, 't' },
{ "num", 1, 0, 'n' },
{ "help", 0, 0, 'h' },
+ { "start-notify-fd", 1, 0, 's' },
{ 0 },
};
@@ -364,6 +367,9 @@ int main(int argc, char **argv)
exit(EINVAL);
}
break;
+ case 's':
+ start_notify_fd = atoi(optarg);
+ break;
default:
fprintf(stderr, "Invalid argument\n");
fprintf(stderr, "Try `%s --help' for more information.\n",
@@ -462,6 +468,22 @@ int main(int argc, char **argv)
init_term(STDIN_FILENO, &stdin_old_attr);
atexit(restore_term_stdin); /* if this fails, oh dear */
}
+
+ if (start_notify_fd != -1) {
+ /* Write 0x00 to notify parent about client's readiness */
+ static const char msg[] = { 0x00 };
+ int r;
+
+ do {
+ r = write(start_notify_fd, msg, 1);
+ } while ((r == -1 && errno == EINTR) || r == 0);
+
+ if (r == -1)
+ err(errno, "Could not notify parent with fd %d",
+ start_notify_fd);
+ close(start_notify_fd);
+ }
+
console_loop(spty, xs, path, interactive);
free(path);
--
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-05 17:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-05 17:41 [PATCH v2 0/6] Fix console synchronisation issues Wei Liu
2016-08-05 17:41 ` [PATCH v2 1/6] tools/console: fix help string in client Wei Liu
2016-08-05 17:41 ` Wei Liu [this message]
2016-08-08 10:11 ` [PATCH v2 2/6] tools/console: introduce --start-notify-fd option for console client Ian Jackson
2016-08-05 17:41 ` [PATCH v2 3/6] libxl: factor out libxl__console_tty_path Wei Liu
2016-08-08 10:12 ` Ian Jackson
2016-08-05 17:41 ` [PATCH v2 4/6] libxl: libxl_{primary_, }console_exec now take notify_fd argument Wei Liu
2016-08-08 10:15 ` Ian Jackson
2016-08-08 10:16 ` Wei Liu
2016-08-08 10:34 ` Wei Liu
2016-08-08 11:06 ` Ian Jackson
2016-08-05 17:41 ` [PATCH v2 5/6] docs: document xenconsole startup protocol Wei Liu
2016-08-05 17:41 ` [PATCH v2 6/6] xl: use " Wei Liu
2016-08-08 10:17 ` Ian Jackson
2016-08-08 10:32 ` Wei Liu
2016-08-08 11:06 ` [PATCH v2 0/6] Fix console synchronisation issues Wei Liu
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=1470418894-11358-3-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).