[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 023/111] virtiofsd: Poll kick_fd for queue
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PULL 023/111] virtiofsd: Poll kick_fd for queue |
Date: |
Thu, 23 Jan 2020 11:57:13 +0000 |
From: "Dr. David Alan Gilbert" <address@hidden>
In the queue thread poll the kick_fd we're passed.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: Daniel P. Berrangé <address@hidden>
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
tools/virtiofsd/fuse_virtio.c | 40 ++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
index 2a94bb3cca..05e7258712 100644
--- a/tools/virtiofsd/fuse_virtio.c
+++ b/tools/virtiofsd/fuse_virtio.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/eventfd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
@@ -100,13 +101,50 @@ static void fv_panic(VuDev *dev, const char *err)
exit(EXIT_FAILURE);
}
+/* Thread function for individual queues, created when a queue is 'started' */
static void *fv_queue_thread(void *opaque)
{
struct fv_QueueInfo *qi = opaque;
fuse_log(FUSE_LOG_INFO, "%s: Start for queue %d kick_fd %d\n", __func__,
qi->qidx, qi->kick_fd);
while (1) {
- /* TODO */
+ struct pollfd pf[1];
+ pf[0].fd = qi->kick_fd;
+ pf[0].events = POLLIN;
+ pf[0].revents = 0;
+
+ fuse_log(FUSE_LOG_DEBUG, "%s: Waiting for Queue %d event\n", __func__,
+ qi->qidx);
+ int poll_res = ppoll(pf, 1, NULL, NULL);
+
+ if (poll_res == -1) {
+ if (errno == EINTR) {
+ fuse_log(FUSE_LOG_INFO, "%s: ppoll interrupted, going
around\n",
+ __func__);
+ continue;
+ }
+ fuse_log(FUSE_LOG_ERR, "fv_queue_thread ppoll: %m\n");
+ break;
+ }
+ assert(poll_res == 1);
+ if (pf[0].revents & (POLLERR | POLLHUP | POLLNVAL)) {
+ fuse_log(FUSE_LOG_ERR, "%s: Unexpected poll revents %x Queue %d\n",
+ __func__, pf[0].revents, qi->qidx);
+ break;
+ }
+ assert(pf[0].revents & POLLIN);
+ fuse_log(FUSE_LOG_DEBUG, "%s: Got queue event on Queue %d\n", __func__,
+ qi->qidx);
+
+ eventfd_t evalue;
+ if (eventfd_read(qi->kick_fd, &evalue)) {
+ fuse_log(FUSE_LOG_ERR, "Eventfd_read for queue: %m\n");
+ break;
+ }
+ if (qi->virtio_dev->se->debug) {
+ fprintf(stderr, "%s: Queue %d gave evalue: %zx\n", __func__,
+ qi->qidx, (size_t)evalue);
+ }
}
return NULL;
--
2.24.1
- [PULL 001/111] virtiofsd: Pull in upstream headers, (continued)
- [PULL 001/111] virtiofsd: Pull in upstream headers, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 014/111] vitriofsd/passthrough_ll: fix fallocate() ifdefs, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 004/111] virtiofsd: Add fuse_lowlevel.c, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 015/111] virtiofsd: Make fsync work even if only inode is passed in, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 020/111] virtiofsd: Add main virtio loop, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 012/111] virtiofsd: Fix common header and define for QEMU builds, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 018/111] virtiofsd: Open vhost connection instead of mounting, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 016/111] virtiofsd: Add options for virtio, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 023/111] virtiofsd: Poll kick_fd for queue,
Dr. David Alan Gilbert (git) <=
- [PULL 025/111] virtiofsd: Send replies to messages, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 024/111] virtiofsd: Start reading commands from queue, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 027/111] virtiofsd: Add Makefile wiring for virtiofsd contrib, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 026/111] virtiofsd: Keep track of replies, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 029/111] virtiofsd: add --fd=FDNUM fd passing option, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 031/111] virtiofsd: add vhost-user.json file, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 021/111] virtiofsd: get/set features callbacks, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 022/111] virtiofsd: Start queue threads, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 017/111] virtiofsd: add -o source=PATH to help output, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 019/111] virtiofsd: Start wiring up vhost-user, Dr. David Alan Gilbert (git), 2020/01/23