Received: from eggs.gnu.org ([2001:4830:134:3::10]:60372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bS9j8-0003VC-QJ for qemu-devel@nongnu.org; Tue, 26 Jul 2016 17:17:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bS9j7-0002Uv-Nv for qemu-devel@nongnu.org; Tue, 26 Jul 2016 17:17:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53718) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bS9j7-0002Ur-IB for qemu-devel@nongnu.org; Tue, 26 Jul 2016 17:17:21 -0400 From: marcandre.lureau@redhat.com Date: Wed, 27 Jul 2016 01:15:24 +0400 Message-Id: <20160726211527.28510-31-marcandre.lureau@redhat.com> In-Reply-To: <20160726211527.28510-1-marcandre.lureau@redhat.com> References: <20160726211527.28510-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v6 30/33] vhost-user: add error report in vhost_user_write() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mukawa@igel.co.jp, yuanhan.liu@linux.intel.com, victork@redhat.com, jonshin@cisco.com, mst@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau Similar to vhost_user_read() error report, it is useful to have early error report. Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/virtio/vhost-user.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 819481d..1995fd2 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, Vh= ostUserMsg *msg, int *fds, int fd_num) { CharDriverState *chr =3D dev->opaque; - int size =3D VHOST_USER_HDR_SIZE + msg->size; + int ret, size =3D VHOST_USER_HDR_SIZE + msg->size; =20 /* * 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, } =20 if (qemu_chr_fe_set_msgfds(chr, fds, fd_num) < 0) { + error_report("Failed to set msg fds."); return -1; } =20 - return qemu_chr_fe_write_all(chr, (const uint8_t *) msg, size) =3D=3D= size ? - 0 : -1; + ret =3D qemu_chr_fe_write_all(chr, (const uint8_t *) msg, size); + if (ret !=3D size) { + error_report("Failed to write msg." + " Wrote %d instead of %d.", ret, size); + return -1; + } + + return 0; } =20 static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, --=20 2.9.0