|
|
ddf19c |
From 6f413d8b76ff38e5bc01f36515ca71d7fd6e6144 Mon Sep 17 00:00:00 2001
|
|
|
ddf19c |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
ddf19c |
Date: Mon, 27 Jan 2020 19:00:58 +0100
|
|
|
ddf19c |
Subject: [PATCH 027/116] virtiofsd: Add main virtio loop
|
|
|
ddf19c |
MIME-Version: 1.0
|
|
|
ddf19c |
Content-Type: text/plain; charset=UTF-8
|
|
|
ddf19c |
Content-Transfer-Encoding: 8bit
|
|
|
ddf19c |
|
|
|
ddf19c |
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
ddf19c |
Message-id: <20200127190227.40942-24-dgilbert@redhat.com>
|
|
|
ddf19c |
Patchwork-id: 93475
|
|
|
ddf19c |
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 023/112] virtiofsd: Add main virtio loop
|
|
|
ddf19c |
Bugzilla: 1694164
|
|
|
ddf19c |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
Processes incoming requests on the vhost-user fd.
|
|
|
ddf19c |
|
|
|
ddf19c |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
ddf19c |
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
ddf19c |
(cherry picked from commit 204d8ae57b3c57098642c79b3c03d42495149c09)
|
|
|
ddf19c |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ddf19c |
---
|
|
|
ddf19c |
tools/virtiofsd/fuse_virtio.c | 42 +++++++++++++++++++++++++++++++++++++++---
|
|
|
ddf19c |
1 file changed, 39 insertions(+), 3 deletions(-)
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
|
|
|
ddf19c |
index 2ae3c76..1928a20 100644
|
|
|
ddf19c |
--- a/tools/virtiofsd/fuse_virtio.c
|
|
|
ddf19c |
+++ b/tools/virtiofsd/fuse_virtio.c
|
|
|
ddf19c |
@@ -11,12 +11,14 @@
|
|
|
ddf19c |
* See the file COPYING.LIB
|
|
|
ddf19c |
*/
|
|
|
ddf19c |
|
|
|
ddf19c |
+#include "fuse_virtio.h"
|
|
|
ddf19c |
#include "fuse_i.h"
|
|
|
ddf19c |
#include "standard-headers/linux/fuse.h"
|
|
|
ddf19c |
#include "fuse_misc.h"
|
|
|
ddf19c |
#include "fuse_opt.h"
|
|
|
ddf19c |
-#include "fuse_virtio.h"
|
|
|
ddf19c |
|
|
|
ddf19c |
+#include <assert.h>
|
|
|
ddf19c |
+#include <errno.h>
|
|
|
ddf19c |
#include <stdint.h>
|
|
|
ddf19c |
#include <stdio.h>
|
|
|
ddf19c |
#include <stdlib.h>
|
|
|
ddf19c |
@@ -80,15 +82,49 @@ static const VuDevIface fv_iface = {
|
|
|
ddf19c |
.queue_is_processed_in_order = fv_queue_order,
|
|
|
ddf19c |
};
|
|
|
ddf19c |
|
|
|
ddf19c |
+/*
|
|
|
ddf19c |
+ * Main loop; this mostly deals with events on the vhost-user
|
|
|
ddf19c |
+ * socket itself, and not actual fuse data.
|
|
|
ddf19c |
+ */
|
|
|
ddf19c |
int virtio_loop(struct fuse_session *se)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
fuse_log(FUSE_LOG_INFO, "%s: Entry\n", __func__);
|
|
|
ddf19c |
|
|
|
ddf19c |
- while (1) {
|
|
|
ddf19c |
- /* TODO: Add stuffing */
|
|
|
ddf19c |
+ while (!fuse_session_exited(se)) {
|
|
|
ddf19c |
+ struct pollfd pf[1];
|
|
|
ddf19c |
+ pf[0].fd = se->vu_socketfd;
|
|
|
ddf19c |
+ pf[0].events = POLLIN;
|
|
|
ddf19c |
+ pf[0].revents = 0;
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ fuse_log(FUSE_LOG_DEBUG, "%s: Waiting for VU event\n", __func__);
|
|
|
ddf19c |
+ int poll_res = ppoll(pf, 1, NULL, NULL);
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ if (poll_res == -1) {
|
|
|
ddf19c |
+ if (errno == EINTR) {
|
|
|
ddf19c |
+ fuse_log(FUSE_LOG_INFO, "%s: ppoll interrupted, going around\n",
|
|
|
ddf19c |
+ __func__);
|
|
|
ddf19c |
+ continue;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ fuse_log(FUSE_LOG_ERR, "virtio_loop ppoll: %m\n");
|
|
|
ddf19c |
+ break;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ assert(poll_res == 1);
|
|
|
ddf19c |
+ if (pf[0].revents & (POLLERR | POLLHUP | POLLNVAL)) {
|
|
|
ddf19c |
+ fuse_log(FUSE_LOG_ERR, "%s: Unexpected poll revents %x\n", __func__,
|
|
|
ddf19c |
+ pf[0].revents);
|
|
|
ddf19c |
+ break;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ assert(pf[0].revents & POLLIN);
|
|
|
ddf19c |
+ fuse_log(FUSE_LOG_DEBUG, "%s: Got VU event\n", __func__);
|
|
|
ddf19c |
+ if (!vu_dispatch(&se->virtio_dev->dev)) {
|
|
|
ddf19c |
+ fuse_log(FUSE_LOG_ERR, "%s: vu_dispatch failed\n", __func__);
|
|
|
ddf19c |
+ break;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
fuse_log(FUSE_LOG_INFO, "%s: Exit\n", __func__);
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ return 0;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
int virtio_session_mount(struct fuse_session *se)
|
|
|
ddf19c |
--
|
|
|
ddf19c |
1.8.3.1
|
|
|
ddf19c |
|