libvhost-user: Send messages with no data
PATCH 1/1 libvhost-user: Send messages with no data
From: "Dr. David Alan Gilbert" <[email protected]>
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.
--- contrib/libvhost-user/libvhost-user.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
contrib/libvhost-user/libvhost-user.c +9 -7
@@ -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));
Signature · 1 line
2.17.0
Quoted 8 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
The response to a
VHOST_USER_POSTCOPY_ADVISEcontains a fd but doesn't
actually contain any data. FIxvu_message_writeso that it doesn't
do a 0-bytewrite()call, since this was ending up with rc=0 that was confusing the error handling code.Signed-off-by Dr. David Alan Gilbert <[email protected]>
Quoted 35 lines
--- contrib/libvhost-user/libvhost-user.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)contrib/libvhost-user/libvhost-user.c +9
-8@@ -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
Signature · 1 line
Marc-André Lureau
Quoted 3 lines · Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" <[email protected]>
The response to a
VHOST_USER_POSTCOPY_ADVISEcontains a fd but doesn't
s/a fd/an fd/ ? Depends on whether you pronounce it "eff-dee" or "file-descriptor".
Quoted 1 line
actually contain any data. FIx
vu_message_writeso that it doesn't
s/FIx/Fix/
Quoted 8 lines
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 <[email protected]>--- contrib/libvhost-user/libvhost-user.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org