Blame SOURCES/kvm-hw-virtio-fix-vhost-user-fails-to-startup-when-MQ.patch

76daa3
From 15a523d06dc0977624c6574825152a6c5d25ae2a Mon Sep 17 00:00:00 2001
76daa3
From: Jens Freimann <jfreiman@redhat.com>
76daa3
Date: Thu, 18 May 2017 14:06:46 +0200
76daa3
Subject: [PATCH 21/27] hw/virtio: fix vhost user fails to startup when MQ
76daa3
MIME-Version: 1.0
76daa3
Content-Type: text/plain; charset=UTF-8
76daa3
Content-Transfer-Encoding: 8bit
76daa3
76daa3
RH-Author: Jens Freimann <jfreiman@redhat.com>
76daa3
Message-id: <20170518140646.19126-2-jfreiman@redhat.com>
76daa3
Patchwork-id: 75329
76daa3
O-Subject: [RHV-7.4 qemu-kvm-rhev PATCH 1/1] hw/virtio: fix vhost user fails to startup when MQ
76daa3
Bugzilla: 1447592
76daa3
RH-Acked-by: wexu@redhat.com
76daa3
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
76daa3
RH-Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
76daa3
76daa3
From: Zhiyong Yang <zhiyong.yang@intel.com>
76daa3
76daa3
 Qemu2.7~2.9 and vhost user for dpdk 17.02 release work together
76daa3
to cause failures of new connection when negotiating to set MQ.
76daa3
(one queue pair works well).
76daa3
   Because there exist some bugs in qemu code when introducing
76daa3
VHOST_USER_PROTOCOL_F_REPLY_ACK to qemu. When vhost_user_set_mem_table
76daa3
is invoked to deal with the vhost message VHOST_USER_SET_MEM_TABLE
76daa3
for the second time, qemu indeed doesn't send the messge (The message
76daa3
needs to be sent only once)but still will be waiting for dpdk's reply
76daa3
ack, then, qemu is always freezing, while DPDK is always waiting for
76daa3
next vhost message from qemu.
76daa3
  The patch aims to fix the bug, MQ can work well.
76daa3
  The same bug is found in function vhost_user_net_set_mtu, it is fixed
76daa3
at the same time.
76daa3
  DPDK related patch is as following:
76daa3
  http://www.dpdk.org/dev/patchwork/patch/23955/
76daa3
76daa3
Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
76daa3
Cc: qemu-stable@nongnu.org
76daa3
Fixes: ca525ce5618b ("vhost-user: Introduce a new protocol feature REPLY_ACK.")
76daa3
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
76daa3
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
76daa3
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
76daa3
Tested-by: Jens Freimann <jfreiman@redhat.com>
76daa3
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
76daa3
(cherry picked from commit 60cd11024f41cc73175e651a2dfe09a3cade56bb)
76daa3
Signed-off-by: Jens Freimann <jfreiman@redhat.com>
76daa3
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
76daa3
---
76daa3
 hw/virtio/vhost-user.c | 21 +++++++++++++--------
76daa3
 1 file changed, 13 insertions(+), 8 deletions(-)
76daa3
76daa3
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
76daa3
index 9334a8a..32a95a8 100644
76daa3
--- a/hw/virtio/vhost-user.c
76daa3
+++ b/hw/virtio/vhost-user.c
76daa3
@@ -163,22 +163,26 @@ fail:
76daa3
 }
76daa3
 
76daa3
 static int process_message_reply(struct vhost_dev *dev,
76daa3
-                                 VhostUserRequest request)
76daa3
+                                 VhostUserMsg msg)
76daa3
 {
76daa3
-    VhostUserMsg msg;
76daa3
+    VhostUserMsg msg_reply;
76daa3
 
76daa3
-    if (vhost_user_read(dev, &msg) < 0) {
76daa3
+    if ((msg.flags & VHOST_USER_NEED_REPLY_MASK) == 0) {
76daa3
+        return 0;
76daa3
+    }
76daa3
+
76daa3
+    if (vhost_user_read(dev, &msg_reply) < 0) {
76daa3
         return -1;
76daa3
     }
76daa3
 
76daa3
-    if (msg.request != request) {
76daa3
+    if (msg_reply.request != msg.request) {
76daa3
         error_report("Received unexpected msg type."
76daa3
                      "Expected %d received %d",
76daa3
-                     request, msg.request);
76daa3
+                     msg.request, msg_reply.request);
76daa3
         return -1;
76daa3
     }
76daa3
 
76daa3
-    return msg.payload.u64 ? -1 : 0;
76daa3
+    return msg_reply.payload.u64 ? -1 : 0;
76daa3
 }
76daa3
 
76daa3
 static bool vhost_user_one_time_request(VhostUserRequest request)
76daa3
@@ -208,6 +212,7 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,
76daa3
      * request, we just ignore it.
76daa3
      */
76daa3
     if (vhost_user_one_time_request(msg->request) && dev->vq_index != 0) {
76daa3
+        msg->flags &= ~VHOST_USER_NEED_REPLY_MASK;
76daa3
         return 0;
76daa3
     }
76daa3
 
76daa3
@@ -320,7 +325,7 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev,
76daa3
     }
76daa3
 
76daa3
     if (reply_supported) {
76daa3
-        return process_message_reply(dev, msg.request);
76daa3
+        return process_message_reply(dev, msg);
76daa3
     }
76daa3
 
76daa3
     return 0;
76daa3
@@ -712,7 +717,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu)
76daa3
 
76daa3
     /* If reply_ack supported, slave has to ack specified MTU is valid */
76daa3
     if (reply_supported) {
76daa3
-        return process_message_reply(dev, msg.request);
76daa3
+        return process_message_reply(dev, msg);
76daa3
     }
76daa3
 
76daa3
     return 0;
76daa3
-- 
76daa3
1.8.3.1
76daa3