diff options
author | Jason Wang <jasowang@redhat.com> | 2019-03-25 11:40:36 +0800 |
---|---|---|
committer | Jason Wang <jasowang@redhat.com> | 2019-05-17 17:00:12 +0800 |
commit | 23bfaf77fa801ba30bb136de7cec47728eb02f4b (patch) | |
tree | c7ef1f748984a222eca2d7418a471bcd4c2d2ebd /hw/net/vhost_net.c | |
parent | d8276573da58e8ce78dab8c46dd660efd664bcb7 (diff) | |
download | qemu-23bfaf77fa801ba30bb136de7cec47728eb02f4b.zip qemu-23bfaf77fa801ba30bb136de7cec47728eb02f4b.tar.gz qemu-23bfaf77fa801ba30bb136de7cec47728eb02f4b.tar.bz2 |
vhost_net: don't set backend for the uninitialized virtqueue
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.
Reviewed-by: Michael S. Tsirkin<mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'hw/net/vhost_net.c')
-rw-r--r-- | hw/net/vhost_net.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index be3cc88..a6b7190 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -244,6 +244,11 @@ 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) { + if (!virtio_queue_enabled(dev, net->dev.vq_index + + file.index)) { + /* Queue might not be ready for start */ + continue; + } r = vhost_net_set_backend(&net->dev, &file); if (r < 0) { r = -errno; @@ -256,6 +261,11 @@ fail: file.fd = -1; if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) { while (file.index-- > 0) { + if (!virtio_queue_enabled(dev, net->dev.vq_index + + file.index)) { + /* Queue might not be ready for start */ + continue; + } int r = vhost_net_set_backend(&net->dev, &file); assert(r >= 0); } |