[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC 3/3] libvhost-user: quit when no more data r
From: |
Marc-André Lureau |
Subject: |
Re: [Qemu-devel] [PATCH RFC 3/3] libvhost-user: quit when no more data received |
Date: |
Thu, 13 Jul 2017 16:01:34 +0000 |
Hi
On Wed, Jul 12, 2017 at 1:47 PM Jens Freimann <address@hidden> wrote:
> From: Jens Freimann <address@hidden>
>
> When recvmsg() returns a message size of zero and
> errno is ENOENT end processing of vhost-user messages.
>
> Without this we run into a vubr_panic() call and get
> PANIC: Error while recvmsg: No such file or directory
> Error while dispatching.
>
>
How do you get ENOENT on recvmsg()?
Add a switch "quit" to the vhost user device and set true to stop
> processing messages.
>
> Signed-off-by: Jens Freimann <address@hidden>
> ---
> contrib/libvhost-user/libvhost-user.c | 12 +++++++++++-
> contrib/libvhost-user/libvhost-user.h | 1 +
> 2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/libvhost-user/libvhost-user.c
> b/contrib/libvhost-user/libvhost-user.c
> index 9efb9da..5538859 100644
> --- a/contrib/libvhost-user/libvhost-user.c
> +++ b/contrib/libvhost-user/libvhost-user.c
> @@ -161,7 +161,10 @@ vu_message_read(VuDev *dev, int conn_fd, VhostUserMsg
> *vmsg)
> rc = recvmsg(conn_fd, &msg, 0);
> } while (rc < 0 && (errno == EINTR || errno == EAGAIN));
>
> - if (rc <= 0) {
> + if (rc == 0 && (errno == ENOENT)) {
> + vmsg->size = 0;
> + dev->quit = true;
> + } else if (rc < 0) {
> vu_panic(dev, "Error while recvmsg: %s", strerror(errno));
> return false;
> }
> @@ -755,6 +758,10 @@ vu_process_message(VuDev *dev, VhostUserMsg *vmsg)
> DPRINT("Flags: 0x%x\n", vmsg->flags);
> DPRINT("Size: %d\n", vmsg->size);
>
> + if (dev->quit) {
> + return true;
> + }
>
Make it false, as no reply is expected then
> +
> if (vmsg->fd_num) {
> int i;
> DPRINT("Fds:");
> @@ -822,6 +829,9 @@ vu_dispatch(VuDev *dev)
> bool success = false;
>
> if (!vu_message_read(dev, dev->sock, &vmsg)) {
> + if (vmsg.size == 0) {
> + success = true;
> + }
>
There might be better ways to indicate a disconnection than modifying and
checking vmsg.size. Perhaps dev->quit alone is enough?
goto end;
> }
>
> diff --git a/contrib/libvhost-user/libvhost-user.h
> b/contrib/libvhost-user/libvhost-user.h
> index 53ef222..c02215a 100644
> --- a/contrib/libvhost-user/libvhost-user.h
> +++ b/contrib/libvhost-user/libvhost-user.h
> @@ -217,6 +217,7 @@ struct VuDev {
> uint64_t features;
> uint64_t protocol_features;
> bool broken;
> + bool quit;
>
I also think you could re-use broken in this case.
>
> /* @set_watch: add or update the given fd to the watch set,
> * call cb when condition is met */
> --
> 2.9.4
>
>
> --
Marc-André Lureau
- [Qemu-devel] [PATCH RFC 0/3] tests/pxe-testt: add testcase using vhost-user-bridge, Jens Freimann, 2017/07/12
- [Qemu-devel] [PATCH RFC 1/3] tests/vhost-user-bridge: disable debug output by default, Jens Freimann, 2017/07/12
- [Qemu-devel] [PATCH RFC 2/3] tests/pxe-test: add testcase using vhost-user-bridge, Jens Freimann, 2017/07/12
- [Qemu-devel] [PATCH RFC 3/3] libvhost-user: quit when no more data received, Jens Freimann, 2017/07/12
- Re: [Qemu-devel] [PATCH RFC 0/3] tests/pxe-testt: add testcase using vhost-user-bridge, no-reply, 2017/07/12
- Re: [Qemu-devel] [PATCH RFC 0/3] tests/pxe-testt: add testcase using vhost-user-bridge, no-reply, 2017/07/12
- Re: [Qemu-devel] [PATCH RFC 0/3] tests/pxe-testt: add testcase using vhost-user-bridge, Michael S. Tsirkin, 2017/07/12