From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCD-0000vn-EE for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCA-0005BN-9N for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:57 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60778 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUC9-0005Aq-UW for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:54 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E7Lh043811 for ; Mon, 28 Aug 2017 20:15:53 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmu3kpdwp-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:53 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:15:52 -0400 From: Michael Roth Date: Mon, 28 Aug 2017 19:13:55 -0500 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Message-Id: <1503965694-10794-21-git-send-email-mdroth@linux.vnet.ibm.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 20/79] hw/virtio: fix vhost user fails to startup when MQ List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Zhiyong Yang , "Michael S . Tsirkin" From: Zhiyong Yang Qemu2.7~2.9 and vhost user for dpdk 17.02 release work together to cause failures of new connection when negotiating to set MQ. (one queue pair works well). Because there exist some bugs in qemu code when introducing VHOST_USER_PROTOCOL_F_REPLY_ACK to qemu. When vhost_user_set_mem_table is invoked to deal with the vhost message VHOST_USER_SET_MEM_TABLE for the second time, qemu indeed doesn't send the messge (The message needs to be sent only once)but still will be waiting for dpdk's reply ack, then, qemu is always freezing, while DPDK is always waiting for next vhost message from qemu. The patch aims to fix the bug, MQ can work well. The same bug is found in function vhost_user_net_set_mtu, it is fixed at the same time. DPDK related patch is as following: http://www.dpdk.org/dev/patchwork/patch/23955/ Signed-off-by: Zhiyong Yang Cc: qemu-stable@nongnu.org Fixes: ca525ce5618b ("vhost-user: Introduce a new protocol feature REPLY_= ACK.") Reviewed-by: Maxime Coquelin Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Tested-by: Jens Freimann Reviewed-by: Marc-Andr=C3=A9 Lureau (cherry picked from commit 60cd11024f41cc73175e651a2dfe09a3cade56bb) Signed-off-by: Michael Roth --- hw/virtio/vhost-user.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 9334a8a..32a95a8c 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -163,22 +163,26 @@ fail: } =20 static int process_message_reply(struct vhost_dev *dev, - VhostUserRequest request) + VhostUserMsg msg) { - VhostUserMsg msg; + VhostUserMsg msg_reply; =20 - if (vhost_user_read(dev, &msg) < 0) { + if ((msg.flags & VHOST_USER_NEED_REPLY_MASK) =3D=3D 0) { + return 0; + } + + if (vhost_user_read(dev, &msg_reply) < 0) { return -1; } =20 - if (msg.request !=3D request) { + if (msg_reply.request !=3D msg.request) { error_report("Received unexpected msg type." "Expected %d received %d", - request, msg.request); + msg.request, msg_reply.request); return -1; } =20 - return msg.payload.u64 ? -1 : 0; + return msg_reply.payload.u64 ? -1 : 0; } =20 static bool vhost_user_one_time_request(VhostUserRequest request) @@ -208,6 +212,7 @@ static int vhost_user_write(struct vhost_dev *dev, Vh= ostUserMsg *msg, * request, we just ignore it. */ if (vhost_user_one_time_request(msg->request) && dev->vq_index !=3D = 0) { + msg->flags &=3D ~VHOST_USER_NEED_REPLY_MASK; return 0; } =20 @@ -320,7 +325,7 @@ static int vhost_user_set_mem_table(struct vhost_dev = *dev, } =20 if (reply_supported) { - return process_message_reply(dev, msg.request); + return process_message_reply(dev, msg); } =20 return 0; @@ -712,7 +717,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *d= ev, uint16_t mtu) =20 /* If reply_ack supported, slave has to ack specified MTU is valid *= / if (reply_supported) { - return process_message_reply(dev, msg.request); + return process_message_reply(dev, msg); } =20 return 0; --=20 2.7.4