qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Zhiyong Yang" <zhiyong.yang@intel.com>,
	qemu-stable@nongnu.org,
	"Maxime Coquelin" <maxime.coquelin@redhat.com>,
	"Jens Freimann" <jfreiman@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PULL 3/9] hw/virtio: fix vhost user fails to startup when MQ
Date: Wed, 10 May 2017 22:08:07 +0300	[thread overview]
Message-ID: <1494443192-17177-4-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1494443192-17177-1-git-send-email-mst@redhat.com>

From: Zhiyong Yang <zhiyong.yang@intel.com>

 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 <zhiyong.yang@intel.com>
Cc: qemu-stable@nongnu.org
Fixes: ca525ce5618b ("vhost-user: Introduce a new protocol feature REPLY_ACK.")
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Jens Freimann <jfreiman@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 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:
 }
 
 static int process_message_reply(struct vhost_dev *dev,
-                                 VhostUserRequest request)
+                                 VhostUserMsg msg)
 {
-    VhostUserMsg msg;
+    VhostUserMsg msg_reply;
 
-    if (vhost_user_read(dev, &msg) < 0) {
+    if ((msg.flags & VHOST_USER_NEED_REPLY_MASK) == 0) {
+        return 0;
+    }
+
+    if (vhost_user_read(dev, &msg_reply) < 0) {
         return -1;
     }
 
-    if (msg.request != request) {
+    if (msg_reply.request != msg.request) {
         error_report("Received unexpected msg type."
                      "Expected %d received %d",
-                     request, msg.request);
+                     msg.request, msg_reply.request);
         return -1;
     }
 
-    return msg.payload.u64 ? -1 : 0;
+    return msg_reply.payload.u64 ? -1 : 0;
 }
 
 static bool vhost_user_one_time_request(VhostUserRequest request)
@@ -208,6 +212,7 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,
      * request, we just ignore it.
      */
     if (vhost_user_one_time_request(msg->request) && dev->vq_index != 0) {
+        msg->flags &= ~VHOST_USER_NEED_REPLY_MASK;
         return 0;
     }
 
@@ -320,7 +325,7 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev,
     }
 
     if (reply_supported) {
-        return process_message_reply(dev, msg.request);
+        return process_message_reply(dev, msg);
     }
 
     return 0;
@@ -712,7 +717,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu)
 
     /* 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);
     }
 
     return 0;
-- 
MST

  parent reply	other threads:[~2017-05-10 19:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-10 19:07 [Qemu-devel] [PULL 0/9] pci, virtio, vhost: fixes Michael S. Tsirkin
2017-05-10 19:07 ` [Qemu-devel] [PULL 1/9] hw/acpi-defs: replace leading X with x_ in FADT field names Michael S. Tsirkin
2017-05-10 19:08 ` [Qemu-devel] [PULL 2/9] hw/arm/virt: generate 64-bit addressable ACPI objects Michael S. Tsirkin
2017-05-10 19:08 ` Michael S. Tsirkin [this message]
2017-05-10 19:08 ` [Qemu-devel] [PULL 4/9] libvhost-user: fix crash when rings aren't ready Michael S. Tsirkin
2017-05-10 19:08 ` [Qemu-devel] [PULL 5/9] pc/fwcfg: unbreak migration from qemu-2.5 and qemu-2.6 during firmware boot Michael S. Tsirkin
2017-05-10 19:08 ` [Qemu-devel] [PULL 6/9] pc: add 2.10 machine type Michael S. Tsirkin
2017-05-10 19:08 ` [Qemu-devel] [PULL 7/9] iommu: Don't crash if machine is not PC_MACHINE Michael S. Tsirkin
2017-05-10 19:08 ` [Qemu-devel] [PULL 8/9] ACPI: don't call acpi_pcihp_device_plug_cb on xen Michael S. Tsirkin
2017-05-10 19:08 ` [Qemu-devel] [PULL 9/9] acpi-defs: clean up open brace usage Michael S. Tsirkin
2017-05-10 19:48 ` [Qemu-devel] [PULL 0/9] pci, virtio, vhost: fixes no-reply
2017-05-15 12:58 ` Stefan Hajnoczi
2017-05-15 13:04   ` Michael S. Tsirkin
2017-05-17 21:40     ` Michael S. Tsirkin
2017-05-18  9:02       ` Stefan Hajnoczi
2017-05-18  9:02 ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1494443192-17177-4-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=jfreiman@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=zhiyong.yang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).