[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 020/108] virtiofsd: Add main virtio loop
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PULL 020/108] virtiofsd: Add main virtio loop |
Date: |
Thu, 23 Jan 2020 16:45:02 +0000 |
From: "Dr. David Alan Gilbert" <address@hidden>
Processes incoming requests on the vhost-user fd.
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 | 42 ++++++++++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 3 deletions(-)
diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
index 2ae3c764dd..1928a2025c 100644
--- a/tools/virtiofsd/fuse_virtio.c
+++ b/tools/virtiofsd/fuse_virtio.c
@@ -11,12 +11,14 @@
* See the file COPYING.LIB
*/
+#include "fuse_virtio.h"
#include "fuse_i.h"
#include "standard-headers/linux/fuse.h"
#include "fuse_misc.h"
#include "fuse_opt.h"
-#include "fuse_virtio.h"
+#include <assert.h>
+#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -80,15 +82,49 @@ static const VuDevIface fv_iface = {
.queue_is_processed_in_order = fv_queue_order,
};
+/*
+ * Main loop; this mostly deals with events on the vhost-user
+ * socket itself, and not actual fuse data.
+ */
int virtio_loop(struct fuse_session *se)
{
fuse_log(FUSE_LOG_INFO, "%s: Entry\n", __func__);
- while (1) {
- /* TODO: Add stuffing */
+ while (!fuse_session_exited(se)) {
+ struct pollfd pf[1];
+ pf[0].fd = se->vu_socketfd;
+ pf[0].events = POLLIN;
+ pf[0].revents = 0;
+
+ fuse_log(FUSE_LOG_DEBUG, "%s: Waiting for VU event\n", __func__);
+ 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, "virtio_loop 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\n",
__func__,
+ pf[0].revents);
+ break;
+ }
+ assert(pf[0].revents & POLLIN);
+ fuse_log(FUSE_LOG_DEBUG, "%s: Got VU event\n", __func__);
+ if (!vu_dispatch(&se->virtio_dev->dev)) {
+ fuse_log(FUSE_LOG_ERR, "%s: vu_dispatch failed\n", __func__);
+ break;
+ }
}
fuse_log(FUSE_LOG_INFO, "%s: Exit\n", __func__);
+
+ return 0;
}
int virtio_session_mount(struct fuse_session *se)
--
2.24.1
- [PULL 009/108] virtiofsd: remove unused notify reply support, (continued)
- [PULL 009/108] virtiofsd: remove unused notify reply support, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 011/108] virtiofsd: Fix fuse_daemonize ignored return values, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 012/108] virtiofsd: Fix common header and define for QEMU builds, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 014/108] vitriofsd/passthrough_ll: fix fallocate() ifdefs, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 013/108] virtiofsd: Trim out compatibility code, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 017/108] virtiofsd: add -o source=PATH to help output, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 015/108] virtiofsd: Make fsync work even if only inode is passed in, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 016/108] virtiofsd: Add options for virtio, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 019/108] virtiofsd: Start wiring up vhost-user, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 001/108] virtiofsd: Pull in upstream headers, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 020/108] virtiofsd: Add main virtio loop,
Dr. David Alan Gilbert (git) <=
- [PULL 007/108] virtiofsd: Format imported files to qemu style, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 018/108] virtiofsd: Open vhost connection instead of mounting, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 021/108] virtiofsd: get/set features callbacks, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 022/108] virtiofsd: Start queue threads, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 025/108] virtiofsd: Send replies to messages, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 026/108] virtiofsd: Keep track of replies, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 023/108] virtiofsd: Poll kick_fd for queue, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 024/108] virtiofsd: Start reading commands from queue, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 027/108] virtiofsd: Add Makefile wiring for virtiofsd contrib, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 029/108] virtiofsd: add --fd=FDNUM fd passing option, Dr. David Alan Gilbert (git), 2020/01/23