From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSyId-0006cQ-FP for qemu-devel@nongnu.org; Thu, 28 Jul 2016 23:17:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSyIc-0003BK-Gi for qemu-devel@nongnu.org; Thu, 28 Jul 2016 23:17:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43886) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSyIc-0003BF-Ax for qemu-devel@nongnu.org; Thu, 28 Jul 2016 23:17:22 -0400 Date: Fri, 29 Jul 2016 06:17:19 +0300 From: "Michael S. Tsirkin" Message-ID: <1469762011-7902-39-git-send-email-mst@redhat.com> References: <1469762011-7902-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1469762011-7902-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 38/41] 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: Peter Maydell , =?iso-8859-1?Q?Marc-Andr=E9?= Lureau From: Marc-Andr=E9 Lureau Similar to vhost_user_read() error report, it is useful to have early error report. Signed-off-by: Marc-Andr=E9 Lureau Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 MST