From: Anthony Liguori <aliguori@us.ibm.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH] Add timeout to xenconsole to fix race condition in xm create -c
Date: Tue, 30 Aug 2005 16:55:24 -0500 [thread overview]
Message-ID: <4314D5CC.3020107@us.ibm.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 596 bytes --]
This should address the problems people are having now.
Wait a little bit for tty to appear. There is a race condition that
occurs after xend creates a domain. Since no event triggers consoled to
re-examine existing domains, we'll often not see the new pty by the time
we're here. Since consoled sleeps for 2 second periods, a 5 second
timeout should keep us covered.
A xenstore watch isn't much better since we don't want to block forever
if given an invalid domain or worse yes, a domain that someone else has
connected to.
Signed-off-by: Anthony Liguori
Regards,
Anthony Liguori
[-- Attachment #2: 6482_consoled.diff --]
[-- Type: text/x-patch, Size: 1992 bytes --]
# HG changeset patch
# User Anthony Liguori <aliguori@us.ibm.com>
# Node ID fe6c5ecea53aabedc6b53988da25910e108eafe9
# Parent 551870a55f240791695d30fd7fa92a1bf4e48387
Wait for domain tty to become available.
diff -r 551870a55f24 -r fe6c5ecea53a tools/console/client/main.c
--- a/tools/console/client/main.c Tue Aug 30 17:53:49 2005
+++ b/tools/console/client/main.c Tue Aug 30 22:01:01 2005
@@ -176,6 +176,7 @@
unsigned int len = 0;
struct xs_handle *xs;
char *end;
+ time_t now;
while((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) {
switch(ch) {
@@ -215,13 +216,37 @@
snprintf(path, sizeof(path), "/console/%d/tty", domid);
str_pty = xs_read(xs, path, &len);
+
/* FIXME consoled currently does not assume domain-0 doesn't have a
console which is good when we break domain-0 up. To keep us
user friendly, we'll bail out here since no data will ever show
up on domain-0. */
- if (domid == 0 || str_pty == NULL) {
+ if (domid == 0) {
err(errno, "Could not read tty from store");
}
+
+ /* FIXME wait a little bit for tty to appear. There is a race
+ condition that occurs after xend creates a domain. Since no event
+ triggers consoled to re-examine existing domains, we'll often not
+ see the new pty by the time we're here. Since consoled sleeps for
+ 2 second periods, a 5 second timeout should keep us covered.
+
+ A xenstore watch isn't much better since we don't want to block
+ forever if given an invalid domain or worse yes, a domain that
+ someone else has connected to. */
+
+ now = time(0);
+ while (str_pty == NULL && (now + 5) > time(0)) {
+ struct timeval tv = { 0, 500 };
+ select(0, NULL, NULL, NULL, &tv); /* pause briefly */
+
+ str_pty = xs_read(xs, path, &len);
+ }
+
+ if (str_pty == NULL) {
+ err(errno, "Could not read tty from store");
+ }
+
spty = open(str_pty, O_RDWR | O_NOCTTY);
if (spty == -1) {
err(errno, "Could not open tty `%s'", str_pty);
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next reply other threads:[~2005-08-30 21:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-30 21:55 Anthony Liguori [this message]
2005-08-31 10:31 ` [PATCH] Add timeout to xenconsole to fix race condition in xm create -c Christian Limpach
2005-08-31 20:42 ` Anthony Liguori
-- strict thread matches above, loose matches on Subject: below --
2005-08-31 5:54 Nakajima, Jun
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=4314D5CC.3020107@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=xen-devel@lists.xensource.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.