Skip to content

Commit

Permalink
vhost_net should call the poll callback only when it is set
Browse files Browse the repository at this point in the history
The poll callback needs to be called when bringing up or down
the vhost_net instance. As it is not mandatory for an NetClient
to implement it, invoke it only when it is set.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Nikolay Nikolaev authored and mstsirkin committed Jun 19, 2014
1 parent 2e6d46d commit 212d69f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions hw/net/vhost_net.c
Expand Up @@ -168,7 +168,10 @@ static int vhost_net_start_one(struct vhost_net *net,
goto fail_start;
}

net->nc->info->poll(net->nc, false);
if (net->nc->info->poll) {
net->nc->info->poll(net->nc, false);
}

qemu_set_fd_handler(net->backend, NULL, NULL, NULL);
file.fd = net->backend;
for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
Expand All @@ -185,7 +188,9 @@ static int vhost_net_start_one(struct vhost_net *net,
int r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file);
assert(r >= 0);
}
net->nc->info->poll(net->nc, true);
if (net->nc->info->poll) {
net->nc->info->poll(net->nc, true);
}
vhost_dev_stop(&net->dev, dev);
fail_start:
vhost_dev_disable_notifiers(&net->dev, dev);
Expand All @@ -206,7 +211,9 @@ static void vhost_net_stop_one(struct vhost_net *net,
int r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file);
assert(r >= 0);
}
net->nc->info->poll(net->nc, true);
if (net->nc->info->poll) {
net->nc->info->poll(net->nc, true);
}
vhost_dev_stop(&net->dev, dev);
vhost_dev_disable_notifiers(&net->dev, dev);
}
Expand Down

0 comments on commit 212d69f

Please sign in to comment.