From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZDSC-0005Yi-Dg for qemu-devel@nongnu.org; Tue, 08 Sep 2015 03:36:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZDS8-0004VV-A8 for qemu-devel@nongnu.org; Tue, 08 Sep 2015 03:36:32 -0400 Received: from mga14.intel.com ([192.55.52.115]:25900) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZDS8-0004Uq-4o for qemu-devel@nongnu.org; Tue, 08 Sep 2015 03:36:28 -0400 From: Yuanhan Liu Date: Tue, 8 Sep 2015 15:38:45 +0800 Message-Id: <1441697927-16456-6-git-send-email-yuanhan.liu@linux.intel.com> In-Reply-To: <1441697927-16456-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1441697927-16456-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [Qemu-devel] [PATCH 5/7] vhost_net: move vhost_net_set_vq_index ahead at vhost_net_init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Yuanhan Liu , changchun.ouyang@intel.com, mst@redhat.com So that we could use the `vq_index' as well in the vhost_net_init stage, which is required when adding vhost-user multiple-queue support, where we need the vq_index to indicate which queue pair we are gonna initiate. vhost-user has no multiple queue support yet, hence no queue_index set before. Here is a quick set to 0 at net_vhost_user_init() stage, and it will be set properly soon in the next patch. Signed-off-by: Yuanhan Liu --- hw/net/vhost_net.c | 16 +++++++--------- net/vhost-user.c | 1 + 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index f9441e9..141b557 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -138,6 +138,11 @@ static int vhost_net_get_fd(NetClientState *backend) } } +static void vhost_net_set_vq_index(struct vhost_net *net, int vq_index) +{ + net->dev.vq_index = vq_index; +} + struct vhost_net *vhost_net_init(VhostNetOptions *options) { int r; @@ -167,6 +172,8 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) } net->nc = options->net_backend; + vhost_net_set_vq_index(net, net->nc->queue_index * 2); + net->dev.nvqs = 2; net->dev.vqs = net->vqs; @@ -196,11 +203,6 @@ fail: return NULL; } -static void vhost_net_set_vq_index(struct vhost_net *net, int vq_index) -{ - net->dev.vq_index = vq_index; -} - static int vhost_net_set_vnet_endian(VirtIODevice *dev, NetClientState *peer, bool set) { @@ -325,10 +327,6 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, goto err; } - for (i = 0; i < total_queues; i++) { - vhost_net_set_vq_index(get_vhost_net(ncs[i].peer), i * 2); - } - r = k->set_guest_notifiers(qbus->parent, total_queues * 2, true); if (r < 0) { error_report("Error binding guest notifier: %d", -r); diff --git a/net/vhost-user.c b/net/vhost-user.c index 93dcecd..2d6bbe5 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -146,6 +146,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, /* We don't provide a receive callback */ s->nc.receive_disabled = 1; s->chr = chr; + nc->queue_index = 0; qemu_chr_add_handlers(s->chr, NULL, NULL, net_vhost_user_event, s); -- 1.9.0