diff options
author | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-09-11 14:32:27 +0000 |
---|---|---|
committer | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-09-11 14:32:27 +0000 |
commit | 2c41a5f9e355412bdab3d92329ae5637bbdb08f1 (patch) | |
tree | e4bbbb5fd90809305c66daa8d4fa8f3c73a7581d | |
parent | da3d9c5b4683efa5bc106e2abcf181e8b187741f (diff) |
Make sure to read siginfo from signalfd
Otherwise, we'll idle at 100% cpu.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5195 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r-- | block-raw-posix.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/block-raw-posix.c b/block-raw-posix.c index f6dc72ae54..0587950c8f 100644 --- a/block-raw-posix.c +++ b/block-raw-posix.c @@ -449,6 +449,30 @@ static void qemu_aio_poll(void *opaque) { RawAIOCB *acb, **pacb; int ret; + size_t offset; + union { + struct qemu_signalfd_siginfo siginfo; + char buf[128]; + } sig; + + /* try to read from signalfd, don't freak out if we can't read anything */ + offset = 0; + while (offset < 128) { + ssize_t len; + + len = read(aio_sig_fd, sig.buf + offset, 128 - offset); + if (len == -1 && errno == EINTR) + continue; + if (len == -1 && errno == EAGAIN) { + /* there is no natural reason for this to happen, + * so we'll spin hard until we get everything just + * to be on the safe side. */ + if (offset > 0) + continue; + } + + offset += len; + } for(;;) { pacb = &first_aio; @@ -498,6 +522,9 @@ void qemu_aio_init(void) sigprocmask(SIG_BLOCK, &mask, NULL); aio_sig_fd = qemu_signalfd(&mask); + + fcntl(aio_sig_fd, F_SETFL, O_NONBLOCK); + #if !defined(QEMU_IMG) && !defined(QEMU_NBD) qemu_set_fd_handler2(aio_sig_fd, NULL, qemu_aio_poll, NULL, NULL); #endif |