From nobody Mon Apr 29 18:34:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493915573779849.6736585124702; Thu, 4 May 2017 09:32:53 -0700 (PDT) Received: from localhost ([::1]:43001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6JgS-0007NS-6s for importer@patchew.org; Thu, 04 May 2017 12:32:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6JeK-0005fb-Im for qemu-devel@nongnu.org; Thu, 04 May 2017 12:30:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6JeG-0004jG-LJ for qemu-devel@nongnu.org; Thu, 04 May 2017 12:30:40 -0400 Received: from mga14.intel.com ([192.55.52.115]:62621) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6JeG-0004iY-BC for qemu-devel@nongnu.org; Thu, 04 May 2017 12:30:36 -0400 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 May 2017 09:30:32 -0700 Received: from unknown (HELO dpdk5.bj.intel.com) ([172.16.182.182]) by fmsmga004.fm.intel.com with ESMTP; 04 May 2017 09:30:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,287,1491289200"; d="scan'208";a="256931302" From: Zhiyong Yang To: qemu-devel@nongnu.org Date: Fri, 5 May 2017 00:25:36 +0800 Message-Id: <1493915136-19150-1-git-send-email-zhiyong.yang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493363372-16861-1-git-send-email-zhiyong.yang@intel.com> References: <1493363372-16861-1-git-send-email-zhiyong.yang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH v2] hw/virtio: fix vhost user fails to startup when MQ X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhiyong Yang , maxime.coquelin@redhat.com, marcandre.lureau@gmail.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Maxime Coquelin Tested-by: Jens Freimann --- Changes in V2: Thanks for Maxime's suggestion, if one-time request, clear the VHOST_USER_NEED_REPLY flag in function vhost_user_write, in process_message_reply(), return early, if this flag isn't set. 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..32a95a8 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, Vhos= tUserMsg *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 *d= ev, } =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 *dev= , 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