* [Qemu-devel] [PATCH] libvhost-user: Send messages with no data
@ 2018-05-04 9:53 Dr. David Alan Gilbert (git)
2018-05-04 9:56 ` Marc-André Lureau
2018-05-04 13:09 ` Eric Blake
0 siblings, 2 replies; 3+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2018-05-04 9:53 UTC (permalink / raw)
To: qemu-devel, mst, marcandre.lureau
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
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 <dgilbert@redhat.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] libvhost-user: Send messages with no data
2018-05-04 9:53 [Qemu-devel] [PATCH] libvhost-user: Send messages with no data Dr. David Alan Gilbert (git)
@ 2018-05-04 9:56 ` Marc-André Lureau
2018-05-04 13:09 ` Eric Blake
1 sibling, 0 replies; 3+ messages in thread
From: Marc-André Lureau @ 2018-05-04 9:56 UTC (permalink / raw)
To: Dr. David Alan Gilbert (git); +Cc: QEMU, Michael S. Tsirkin
On Fri, May 4, 2018 at 11:53 AM, Dr. David Alan Gilbert (git)
<dgilbert@redhat.com> wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> 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 <dgilbert@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] libvhost-user: Send messages with no data
2018-05-04 9:53 [Qemu-devel] [PATCH] libvhost-user: Send messages with no data Dr. David Alan Gilbert (git)
2018-05-04 9:56 ` Marc-André Lureau
@ 2018-05-04 13:09 ` Eric Blake
1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2018-05-04 13:09 UTC (permalink / raw)
To: Dr. David Alan Gilbert (git), qemu-devel, mst, marcandre.lureau
On 05/04/2018 04:53 AM, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> The response to a VHOST_USER_POSTCOPY_ADVISE contains a fd but doesn't
s/a fd/an fd/ ? Depends on whether you pronounce it "eff-dee" or
"file-descriptor".
> actually contain any data. FIx vu_message_write so that it doesn't
s/FIx/Fix/
> 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 <dgilbert@redhat.com>
> ---
> contrib/libvhost-user/libvhost-user.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-04 13:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-04 9:53 [Qemu-devel] [PATCH] libvhost-user: Send messages with no data Dr. David Alan Gilbert (git)
2018-05-04 9:56 ` Marc-André Lureau
2018-05-04 13:09 ` Eric Blake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).