diff options
author | Amit Shah <amit.shah@redhat.com> | 2010-08-26 09:36:29 +0530 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2010-08-26 09:43:58 +0530 |
commit | 6978ab579482e055bd679893491f74392b84e6ed (patch) | |
tree | 266b9b73b103b0e5215bca9e7896c5d94e6463df /auto-virtserial-guest.c | |
parent | 875796bff9d5d1aea84648b1b634a6f374ad0c7f (diff) | |
download | test-virtserial-6978ab579482e055bd679893491f74392b84e6ed.tar.gz test-virtserial-6978ab579482e055bd679893491f74392b84e6ed.tar.xz test-virtserial-6978ab579482e055bd679893491f74392b84e6ed.zip |
auto-test: Add a key to specify poll events to poll for
We always invoked a guest poll with POLLIN|POLLOUT events. There's a
case where custom events might be necessary -- the sigio handler test,
for example. Add a new key to set the poll events.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'auto-virtserial-guest.c')
-rw-r--r-- | auto-virtserial-guest.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/auto-virtserial-guest.c b/auto-virtserial-guest.c index 7e16282..10daeb5 100644 --- a/auto-virtserial-guest.c +++ b/auto-virtserial-guest.c @@ -40,6 +40,8 @@ /* The fd to work with for read / write requests. Set by the open message */ static int g_fd; +/* The events to poll for */ +static int g_poll_events; /* The fd to stuff in bytes for a big file receive command */ static int g_bigfile_fd; /* The length to read / write. Set by the length message. Unset at close */ @@ -179,13 +181,18 @@ static int open_port(int nr) return fd; } +static int set_poll_events(int events) +{ + return g_poll_events = events; +} + static int poll_port(int timeout) { struct pollfd pollfds[1]; int ret; pollfds[0].fd = g_fd; - pollfds[0].events = POLLIN | POLLOUT; + pollfds[0].events = g_poll_events ? : POLLIN | POLLOUT; ret = safepoll(pollfds, 1, timeout); if (ret <= 0) return ret; @@ -654,6 +661,10 @@ back_to_open: ret = write_port(gpkt.value); send_report(cfd, ret); break; + case KEY_POLL_EVENTS: + ret = set_poll_events(gpkt.value); + send_report(cfd, ret); + break; case KEY_POLL: ret = poll_port(gpkt.value); send_report(cfd, ret); |