aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-07-27 01:15:24 +0400
committerMichael S. Tsirkin <mst@redhat.com>2016-07-29 00:33:49 +0300
commitf6b8571041eea057b9e55fad51357e8d8ac9b1c0 (patch)
tree1443855f0061c58a09ab32d7e37880ebecf100dd /hw/virtio
parent69179fe2fc0b91f68699012ba72d329e74ff629e (diff)
vhost-user: add error report in vhost_user_write()
Similar to vhost_user_read() error report, it is useful to have early error report. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/virtio')
-rw-r--r--hw/virtio/vhost-user.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 819481dee2..1995fd20bd 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -176,7 +176,7 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,
int *fds, int fd_num)
{
CharDriverState *chr = dev->opaque;
- int size = VHOST_USER_HDR_SIZE + msg->size;
+ int ret, size = VHOST_USER_HDR_SIZE + msg->size;
/*
* For non-vring specific requests, like VHOST_USER_SET_MEM_TABLE,
@@ -188,11 +188,18 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,
}
if (qemu_chr_fe_set_msgfds(chr, fds, fd_num) < 0) {
+ error_report("Failed to set msg fds.");
return -1;
}
- return qemu_chr_fe_write_all(chr, (const uint8_t *) msg, size) == size ?
- 0 : -1;
+ ret = qemu_chr_fe_write_all(chr, (const uint8_t *) msg, size);
+ if (ret != size) {
+ error_report("Failed to write msg."
+ " Wrote %d instead of %d.", ret, size);
+ return -1;
+ }
+
+ return 0;
}
static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base,