|
|
ed5979 |
From 0c19fb7c4a22a30830152b224b2e66963f829a7a Mon Sep 17 00:00:00 2001
|
|
|
ed5979 |
From: Greg Kurz <groug@kaod.org>
|
|
|
ed5979 |
Date: Thu, 19 Jan 2023 18:24:24 +0100
|
|
|
ed5979 |
Subject: [PATCH 19/20] Revert "vhost-user: Introduce nested event loop in
|
|
|
ed5979 |
vhost_user_read()"
|
|
|
ed5979 |
MIME-Version: 1.0
|
|
|
ed5979 |
Content-Type: text/plain; charset=UTF-8
|
|
|
ed5979 |
Content-Transfer-Encoding: 8bit
|
|
|
ed5979 |
|
|
|
ed5979 |
RH-Author: Laurent Vivier <lvivier@redhat.com>
|
|
|
ed5979 |
RH-MergeRequest: 146: Fix vhost-user with dpdk
|
|
|
ed5979 |
RH-Bugzilla: 2155173
|
|
|
ed5979 |
RH-Acked-by: Cindy Lu <lulu@redhat.com>
|
|
|
ed5979 |
RH-Acked-by: Greg Kurz (RH) <gkurz@redhat.com>
|
|
|
ed5979 |
RH-Acked-by: Eugenio PĂ©rez <eperezma@redhat.com>
|
|
|
ed5979 |
RH-Commit: [2/2] 9b67041f92f29f70b7ccb41d8087801e4e4e38af (lvivier/qemu-kvm-centos)
|
|
|
ed5979 |
|
|
|
ed5979 |
This reverts commit a7f523c7d114d445c5d83aecdba3efc038e5a692.
|
|
|
ed5979 |
|
|
|
ed5979 |
The nested event loop is broken by design. It's only user was removed.
|
|
|
ed5979 |
Drop the code as well so that nobody ever tries to use it again.
|
|
|
ed5979 |
|
|
|
ed5979 |
I had to fix a couple of trivial conflicts around return values because
|
|
|
ed5979 |
of 025faa872bcf ("vhost-user: stick to -errno error return convention").
|
|
|
ed5979 |
|
|
|
ed5979 |
Signed-off-by: Greg Kurz <groug@kaod.org>
|
|
|
ed5979 |
Message-Id: <20230119172424.478268-3-groug@kaod.org>
|
|
|
ed5979 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
ed5979 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
ed5979 |
Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
ed5979 |
(cherry picked from commit 4382138f642f69fdbc79ebf4e93d84be8061191f)
|
|
|
ed5979 |
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
ed5979 |
---
|
|
|
ed5979 |
hw/virtio/vhost-user.c | 65 ++++--------------------------------------
|
|
|
ed5979 |
1 file changed, 5 insertions(+), 60 deletions(-)
|
|
|
ed5979 |
|
|
|
ed5979 |
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
|
|
|
ed5979 |
index 0ac00eb901..7cb49c50f9 100644
|
|
|
ed5979 |
--- a/hw/virtio/vhost-user.c
|
|
|
ed5979 |
+++ b/hw/virtio/vhost-user.c
|
|
|
ed5979 |
@@ -305,19 +305,8 @@ static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)
|
|
|
ed5979 |
return 0;
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
-struct vhost_user_read_cb_data {
|
|
|
ed5979 |
- struct vhost_dev *dev;
|
|
|
ed5979 |
- VhostUserMsg *msg;
|
|
|
ed5979 |
- GMainLoop *loop;
|
|
|
ed5979 |
- int ret;
|
|
|
ed5979 |
-};
|
|
|
ed5979 |
-
|
|
|
ed5979 |
-static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
|
|
|
ed5979 |
- gpointer opaque)
|
|
|
ed5979 |
+static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
|
|
|
ed5979 |
{
|
|
|
ed5979 |
- struct vhost_user_read_cb_data *data = opaque;
|
|
|
ed5979 |
- struct vhost_dev *dev = data->dev;
|
|
|
ed5979 |
- VhostUserMsg *msg = data->msg;
|
|
|
ed5979 |
struct vhost_user *u = dev->opaque;
|
|
|
ed5979 |
CharBackend *chr = u->user->chr;
|
|
|
ed5979 |
uint8_t *p = (uint8_t *) msg;
|
|
|
ed5979 |
@@ -325,8 +314,7 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
|
|
|
ed5979 |
|
|
|
ed5979 |
r = vhost_user_read_header(dev, msg);
|
|
|
ed5979 |
if (r < 0) {
|
|
|
ed5979 |
- data->ret = r;
|
|
|
ed5979 |
- goto end;
|
|
|
ed5979 |
+ return r;
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
/* validate message size is sane */
|
|
|
ed5979 |
@@ -334,8 +322,7 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
|
|
|
ed5979 |
error_report("Failed to read msg header."
|
|
|
ed5979 |
" Size %d exceeds the maximum %zu.", msg->hdr.size,
|
|
|
ed5979 |
VHOST_USER_PAYLOAD_SIZE);
|
|
|
ed5979 |
- data->ret = -EPROTO;
|
|
|
ed5979 |
- goto end;
|
|
|
ed5979 |
+ return -EPROTO;
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
if (msg->hdr.size) {
|
|
|
ed5979 |
@@ -346,53 +333,11 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
|
|
|
ed5979 |
int saved_errno = errno;
|
|
|
ed5979 |
error_report("Failed to read msg payload."
|
|
|
ed5979 |
" Read %d instead of %d.", r, msg->hdr.size);
|
|
|
ed5979 |
- data->ret = r < 0 ? -saved_errno : -EIO;
|
|
|
ed5979 |
- goto end;
|
|
|
ed5979 |
+ return r < 0 ? -saved_errno : -EIO;
|
|
|
ed5979 |
}
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
-end:
|
|
|
ed5979 |
- g_main_loop_quit(data->loop);
|
|
|
ed5979 |
- return G_SOURCE_REMOVE;
|
|
|
ed5979 |
-}
|
|
|
ed5979 |
-
|
|
|
ed5979 |
-static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
|
|
|
ed5979 |
-{
|
|
|
ed5979 |
- struct vhost_user *u = dev->opaque;
|
|
|
ed5979 |
- CharBackend *chr = u->user->chr;
|
|
|
ed5979 |
- GMainContext *prev_ctxt = chr->chr->gcontext;
|
|
|
ed5979 |
- GMainContext *ctxt = g_main_context_new();
|
|
|
ed5979 |
- GMainLoop *loop = g_main_loop_new(ctxt, FALSE);
|
|
|
ed5979 |
- struct vhost_user_read_cb_data data = {
|
|
|
ed5979 |
- .dev = dev,
|
|
|
ed5979 |
- .loop = loop,
|
|
|
ed5979 |
- .msg = msg,
|
|
|
ed5979 |
- .ret = 0
|
|
|
ed5979 |
- };
|
|
|
ed5979 |
-
|
|
|
ed5979 |
- /*
|
|
|
ed5979 |
- * We want to be able to monitor the slave channel fd while waiting
|
|
|
ed5979 |
- * for chr I/O. This requires an event loop, but we can't nest the
|
|
|
ed5979 |
- * one to which chr is currently attached : its fd handlers might not
|
|
|
ed5979 |
- * be prepared for re-entrancy. So we create a new one and switch chr
|
|
|
ed5979 |
- * to use it.
|
|
|
ed5979 |
- */
|
|
|
ed5979 |
- qemu_chr_be_update_read_handlers(chr->chr, ctxt);
|
|
|
ed5979 |
- qemu_chr_fe_add_watch(chr, G_IO_IN | G_IO_HUP, vhost_user_read_cb, &data);
|
|
|
ed5979 |
-
|
|
|
ed5979 |
- g_main_loop_run(loop);
|
|
|
ed5979 |
-
|
|
|
ed5979 |
- /*
|
|
|
ed5979 |
- * Restore the previous event loop context. This also destroys/recreates
|
|
|
ed5979 |
- * event sources : this guarantees that all pending events in the original
|
|
|
ed5979 |
- * context that have been processed by the nested loop are purged.
|
|
|
ed5979 |
- */
|
|
|
ed5979 |
- qemu_chr_be_update_read_handlers(chr->chr, prev_ctxt);
|
|
|
ed5979 |
-
|
|
|
ed5979 |
- g_main_loop_unref(loop);
|
|
|
ed5979 |
- g_main_context_unref(ctxt);
|
|
|
ed5979 |
-
|
|
|
ed5979 |
- return data.ret;
|
|
|
ed5979 |
+ return 0;
|
|
|
ed5979 |
}
|
|
|
ed5979 |
|
|
|
ed5979 |
static int process_message_reply(struct vhost_dev *dev,
|
|
|
ed5979 |
--
|
|
|
ed5979 |
2.31.1
|
|
|
ed5979 |
|