qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] libvhost-user: Send messages with no data


From: Marc-André Lureau
Subject: Re: [Qemu-devel] [PATCH] libvhost-user: Send messages with no data
Date: Fri, 4 May 2018 11:56:07 +0200

On Fri, May 4, 2018 at 11:53 AM, Dr. David Alan Gilbert (git)
<address@hidden> wrote:
> From: "Dr. David Alan Gilbert" <address@hidden>
>
> The response to a VHOST_USER_POSTCOPY_ADVISE contains a fd but doesn't
> actually contain any data.   FIx vu_message_write so that it doesn't
> do a 0-byte write() call, since this was ending up with rc=0
> that was confusing the error handling code.
>
> Signed-off-by: Dr. David Alan Gilbert <address@hidden>

Reviewed-by: Marc-André Lureau <address@hidden>


> ---
>  contrib/libvhost-user/libvhost-user.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/contrib/libvhost-user/libvhost-user.c 
> b/contrib/libvhost-user/libvhost-user.c
> index beeed0c43f..54e643d871 100644
> --- a/contrib/libvhost-user/libvhost-user.c
> +++ b/contrib/libvhost-user/libvhost-user.c
> @@ -323,13 +323,15 @@ vu_message_write(VuDev *dev, int conn_fd, VhostUserMsg 
> *vmsg)
>          rc = sendmsg(conn_fd, &msg, 0);
>      } while (rc < 0 && (errno == EINTR || errno == EAGAIN));
>
> -    do {
> -        if (vmsg->data) {
> -            rc = write(conn_fd, vmsg->data, vmsg->size);
> -        } else {
> -            rc = write(conn_fd, p + VHOST_USER_HDR_SIZE, vmsg->size);
> -        }
> -    } while (rc < 0 && (errno == EINTR || errno == EAGAIN));
> +    if (vmsg->size) {
> +        do {
> +            if (vmsg->data) {
> +                rc = write(conn_fd, vmsg->data, vmsg->size);
> +            } else {
> +                rc = write(conn_fd, p + VHOST_USER_HDR_SIZE, vmsg->size);
> +            }
> +        } while (rc < 0 && (errno == EINTR || errno == EAGAIN));
> +    }
>
>      if (rc <= 0) {
>          vu_panic(dev, "Error while writing: %s", strerror(errno));
> --
> 2.17.0
>
>



-- 
Marc-André Lureau



reply via email to

[Prev in Thread] Current Thread [Next in Thread]