qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH V2 RFT] vhost_net: don't set backend for the uni


From: Jason Wang
Subject: Re: [Qemu-devel] [PATCH V2 RFT] vhost_net: don't set backend for the uninitialized virtqueue
Date: Mon, 25 Mar 2019 17:59:32 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1


On 2019/3/25 下午5:56, Yuri Benditovich wrote:
Hi Jason,

This seems ok now (4 previous patches + this one)


Thanks for the testing. Could you test with just this patch? Since even without 4 previous patch, we've already had the check through virtio_queue_get_desc_addr() in vhost_virtqueue_start().



On Mon, Mar 25, 2019 at 5:56 AM Jason Wang <address@hidden> wrote:
We used to set backend unconditionally, this won't work for some
guests (e.g windows driver) who may not initialize all virtqueues. For
kernel backend, this will fail since it may try to validate the rings
during setting backend.

Fixing this by simply skipping the backend set when we find desc is
not ready.

Signed-off-by: Jason Wang <address@hidden>
---
  hw/net/vhost_net.c | 15 +++++++++++++++
  1 file changed, 15 insertions(+)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index be3cc88370..04fd924d15 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -221,6 +221,7 @@ static int vhost_net_start_one(struct vhost_net *net,
                                 VirtIODevice *dev)
  {
      struct vhost_vring_file file = { };
+    hwaddr a;
      int r;

      net->dev.nvqs = 2;
@@ -244,6 +245,13 @@ static int vhost_net_start_one(struct vhost_net *net,
          qemu_set_fd_handler(net->backend, NULL, NULL, NULL);
          file.fd = net->backend;
          for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
+            a = virtio_queue_get_desc_addr(dev,
+                                           net->dev.vq_index +
+                                           file.index);
+            if (a == 0) {
+                /* Queue might not be ready for start */
+                continue;
+            }
              r = vhost_net_set_backend(&net->dev, &file);
              if (r < 0) {
                  r = -errno;
@@ -256,6 +264,13 @@ fail:
      file.fd = -1;
      if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) {
          while (file.index-- > 0) {
+            a = virtio_queue_get_desc_addr(dev,
+                                           net->dev.vq_index +
+                                           file.index);
+            if (a == 0) {
+                /* Queue might not be ready for start */
+                continue;
+            }
              int r = vhost_net_set_backend(&net->dev, &file);
              assert(r >= 0);
          }
--
2.19.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]