All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sasha.levin@oracle.com>
To: penberg@kernel.org, asias@redhat.com
Cc: kvm@vger.kernel.org, Sasha Levin <sasha.levin@oracle.com>
Subject: [PATCH 2/8] kvm tools: fix vhost interaction with ctrl vq
Date: Fri,  3 May 2013 16:29:11 -0400	[thread overview]
Message-ID: <1367612957-6719-2-git-send-email-sasha.levin@oracle.com> (raw)
In-Reply-To: <1367612957-6719-1-git-send-email-sasha.levin@oracle.com>

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@oracle.com>
---
 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);
-- 
1.8.2.1


  reply	other threads:[~2013-05-03 20:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-03 20:29 [PATCH 1/8] kvm tools: pass virtio header size to uip_init Sasha Levin
2013-05-03 20:29 ` Sasha Levin [this message]
2013-05-03 20:29 ` [PATCH 3/8] kvm tools: add status notification hook for virtio Sasha Levin
2013-05-03 20:29 ` [PATCH 4/8] kvm tools: init network devices only when the virtio driver is ready to go Sasha Levin
2013-05-03 20:29 ` [PATCH 5/8] kvm tools: use correct vnet header size for mergable rx buffers Sasha Levin
2013-05-03 20:29 ` [PATCH 6/8] kvm tools: steal iovec handling routines from the kernel Sasha Levin
2013-05-03 20:29 ` [PATCH 7/8] kvm tools: use iovec functions in uip_rx Sasha Levin
2013-05-03 20:29 ` [PATCH 8/8] kvm tools: virtio-net mergable rx buffers Sasha Levin
2013-05-14 15:30 ` [PATCH 1/8] kvm tools: pass virtio header size to uip_init Pekka Enberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1367612957-6719-2-git-send-email-sasha.levin@oracle.com \
    --to=sasha.levin@oracle.com \
    --cc=asias@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=penberg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.