mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
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>
This commit is contained in:
parent
d8276573da
commit
23bfaf77fa
3 changed files with 16 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue