Commit-ID: 5735e21656ff31bc12b1ae94b7b5fe2fe26cce57 Gitweb: http://git.kernel.org/tip/5735e21656ff31bc12b1ae94b7b5fe2fe26cce57 Author: Sasha Levin <sasha.levin@xxxxxxxxxx> AuthorDate: Fri, 3 May 2013 16:29:11 -0400 Committer: Pekka Enberg <penberg@xxxxxxxxxx> CommitDate: Tue, 14 May 2013 14:20:32 +0300 kvm tools: fix vhost interaction with ctrl vq We broke networking using vhost with the introduction of a ctrl vq, make sure that that queue get treated like a special case. Signed-off-by: Sasha Levin <sasha.levin@xxxxxxxxxx> Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx> --- tools/kvm/virtio/net.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c index 2de9222..bef0039 100644 --- a/tools/kvm/virtio/net.c +++ b/tools/kvm/virtio/net.c @@ -357,6 +357,11 @@ static void set_guest_features(struct kvm *kvm, void *dev, u32 features) ndev->features = features; } +static bool is_ctrl_vq(struct net_dev *ndev, u32 vq) +{ + return vq == (u32)(ndev->queue_pairs * 2); +} + static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 page_size, u32 align, u32 pfn) { @@ -377,10 +382,12 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 page_size, u32 align, mutex_init(&ndev->io_lock[vq]); pthread_cond_init(&ndev->io_cond[vq], NULL); - if (ndev->vhost_fd == 0) { - if (vq == (u32)(ndev->queue_pairs * 2)) - pthread_create(&ndev->io_thread[vq], NULL, virtio_net_ctrl_thread, ndev); - else if (vq & 1) + if (is_ctrl_vq(ndev, vq)) { + pthread_create(&ndev->io_thread[vq], NULL, virtio_net_ctrl_thread, ndev); + + return 0; + } else if (ndev->vhost_fd == 0 ) { + if (vq & 1) pthread_create(&ndev->io_thread[vq], NULL, virtio_net_tx_thread, ndev); else pthread_create(&ndev->io_thread[vq], NULL, virtio_net_rx_thread, ndev); @@ -453,7 +460,7 @@ static void notify_vq_eventfd(struct kvm *kvm, void *dev, u32 vq, u32 efd) }; int r; - if (ndev->vhost_fd == 0) + if (ndev->vhost_fd == 0 || is_ctrl_vq(ndev, vq)) return; r = ioctl(ndev->vhost_fd, VHOST_SET_VRING_KICK, &file); -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html