From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id D62181B168 for ; Fri, 12 Jan 2018 16:50:56 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 414975F7B5; Fri, 12 Jan 2018 15:50:56 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-28.ams2.redhat.com [10.36.112.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2118567678; Fri, 12 Jan 2018 15:50:48 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, tiwei.bie@intel.com, yliu@fridaylinux.org, jfreimann@redhat.com Cc: Maxime Coquelin Date: Fri, 12 Jan 2018 16:50:15 +0100 Message-Id: <20180112155016.8990-2-maxime.coquelin@redhat.com> In-Reply-To: <20180112155016.8990-1-maxime.coquelin@redhat.com> References: <20180112155016.8990-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 12 Jan 2018 15:50:56 +0000 (UTC) Subject: [dpdk-dev] [RFC 1/2] vhost-user: don't allocate new queue once device is running 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: , X-List-Received-Date: Fri, 12 Jan 2018 15:50:57 -0000 Once the device is created, it is not possible to hot-add new queues. If it happens, it could confuse the application, as the new queue might not be initialized but nr_vring is incremented. Signed-off-by: Maxime Coquelin --- lib/librte_vhost/vhost_user.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index e54795a41..f94fd16cf 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1220,13 +1220,23 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev, VhostUserMsg *msg) if (vring_idx >= VHOST_MAX_VRING) { RTE_LOG(ERR, VHOST_CONFIG, "invalid vring index: %u\n", vring_idx); - return -1; + return -EINVAL; } if (dev->virtqueue[vring_idx]) return 0; - return alloc_vring_queue(dev, vring_idx); + /* Queues cannot be added dynamically */ + if (dev->flags & VIRTIO_DEV_RUNNING) { + RTE_LOG(DEBUG, VHOST_CONFIG, + "Cannot allocate new queue, device is running\n"); + return -EPERM; + } + + if (alloc_vring_queue(dev, vring_idx) < 0) + return -ENOMEM; + + return 0; } int @@ -1274,7 +1284,10 @@ vhost_user_msg_handler(int vid, int fd) vhost_message_str[msg.request.master]); ret = vhost_user_check_and_alloc_queue_pair(dev, &msg); - if (ret < 0) { + if (ret == -EPERM) { + RTE_LOG(DEBUG, VHOST_CONFIG, "Skipping message\n"); + goto out; + } else if (ret < 0) { RTE_LOG(ERR, VHOST_CONFIG, "failed to alloc queue\n"); return -1; @@ -1383,6 +1396,7 @@ vhost_user_msg_handler(int vid, int fd) } +out: if (msg.flags & VHOST_USER_NEED_REPLY) { msg.payload.u64 = !!ret; msg.size = sizeof(msg.payload.u64); -- 2.14.3