summaryrefslogtreecommitdiffstats
path: root/auto-virtserial.c
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2010-08-26 05:40:50 +0530
committerAmit Shah <amit.shah@redhat.com>2010-08-26 09:43:22 +0530
commitd99d351e8b683835b43060b562fd68163902d89a (patch)
treefa4f3cf615be9b2a01c454046646a210a4ecd8f3 /auto-virtserial.c
parentc35234eef8dab01e74547ebfceb98f0e8b6ede64 (diff)
downloadtest-virtserial-d99d351e8b683835b43060b562fd68163902d89a.tar.gz
test-virtserial-d99d351e8b683835b43060b562fd68163902d89a.tar.xz
test-virtserial-d99d351e8b683835b43060b562fd68163902d89a.zip
auto-virtserial: Explain how test_blocking_read() works
There's some hackery in the way test_blocking_read() works, document it so that the move to autotest is easier. Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'auto-virtserial.c')
-rw-r--r--auto-virtserial.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/auto-virtserial.c b/auto-virtserial.c
index 54c35a2..260825b 100644
--- a/auto-virtserial.c
+++ b/auto-virtserial.c
@@ -437,6 +437,19 @@ static int test_blocking_read(int nr)
gpkt.value = nr;
guest_cmd_only(&gpkt);
+ /*
+ * We'll try to be a little smart here: The guest is blocked
+ * on read, so we can't start a poll() request in the same
+ * thread. so either we spawn off the blocking read in a
+ * different thread or we poll our controlling port for the
+ * response from the read syscall (the guest will immediately
+ * write the return value from the read() syscall once it
+ * comes out of its blocking state).
+ *
+ * So what we do here is poll on the control port for the read
+ * response. If there is any, it means the guest came out of
+ * its blocking read.
+ */
pollfd[0].fd = chardevs[1].sock;
pollfd[0].events = POLLIN;
/* See if we get something in 5s -- we shouldn't. */