From patchwork Wed Dec 6 09:20:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 31942 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0E0461B19D; Wed, 6 Dec 2017 10:21:21 +0100 (CET) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id ED9E21B19C for ; Wed, 6 Dec 2017 10:21:19 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5EDF180F99; Wed, 6 Dec 2017 09:21:19 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-55.ams2.redhat.com [10.36.112.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9F3C5E26C; Wed, 6 Dec 2017 09:21:16 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, yliu@fridaylinux.org, tiwei.bie@intel.com, jianfeng.tan@intel.com, lprosek@redhat.com, lersek@redhat.com Cc: Maxime Coquelin Date: Wed, 6 Dec 2017 10:20:48 +0100 Message-Id: <20171206092048.3568-5-maxime.coquelin@redhat.com> In-Reply-To: <20171206092048.3568-1-maxime.coquelin@redhat.com> References: <20171206092048.3568-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 06 Dec 2017 09:21:19 +0000 (UTC) Subject: [dpdk-dev] [PATCH v3 4/4] vhost: destroy unused virtqueues when multiqueue not negotiated X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" QEMU sends VHOST_USER_SET_VRING_CALL requests for all queues declared in QEMU command line before the guest is started. It has the effect in DPDK vhost-user backend to allocate vrings for all queues declared by QEMU. If the first driver being used does not support multiqueue, the device never changes to VIRTIO_DEV_RUNNING state as only the first queue pair is initialized. One driver impacted by this bug is virtio-net's iPXE driver which does not support VIRTIO_NET_F_MQ feature. It is safe to destroy unused virtqueues in SET_FEATURES request handler, as it is ensured the device is not in running state at this stage, so virtqueues aren't being processed. Signed-off-by: Maxime Coquelin --- lib/librte_vhost/vhost_user.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index a5e1f2482..92a219052 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -216,6 +216,24 @@ vhost_user_set_features(struct virtio_net *dev, uint64_t features) (dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) ? "on" : "off", (dev->features & (1ULL << VIRTIO_F_VERSION_1)) ? "on" : "off"); + if (!(dev->features & (1ULL << VIRTIO_NET_F_MQ))) { + /* + * Remove all but first queue pair if MQ hasn't been + * negotiated. This is safe because the device is not + * running at this stage. + */ + while (dev->nr_vring > 2) { + struct vhost_virtqueue *vq; + + vq = dev->virtqueue[--dev->nr_vring]; + if (!vq) + continue; + + cleanup_vq(vq, 1); + free_vq(vq); + } + } + return 0; }