From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjNq6-0003HG-Um for qemu-devel@nongnu.org; Tue, 06 Oct 2015 04:43:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjNq4-00035d-PA for qemu-devel@nongnu.org; Tue, 06 Oct 2015 04:43:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40319) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjNkd-0006wJ-PC for qemu-devel@nongnu.org; Tue, 06 Oct 2015 04:37:35 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 7DD54C075D95 for ; Tue, 6 Oct 2015 08:37:35 +0000 (UTC) From: Igor Mammedov Date: Tue, 6 Oct 2015 10:37:29 +0200 Message-Id: <1444120649-197078-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1444120649-197078-1-git-send-email-imammedo@redhat.com> References: <1444120649-197078-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH v4 3/3] vhost: fail backend intialization if memslots number is more than its supported limit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: marcel@redhat.com, mst@redhat.com Signed-off-by: Igor Mammedov --- v4: * check that used slots are less than limit of new backend (Michael S. Tsirkin) --- hw/virtio/vhost.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index a3b4f9e..f14a5c5 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -933,6 +933,12 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, return -errno; } + if (used_memslots > hdev->vhost_ops->vhost_backend_memslots_limit(hdev)) { + fprintf(stderr, "vhost backend memory slots limit is less" + " than current number of present memory slots\n"); + close((uintptr_t)opaque); + return -1; + } QLIST_INSERT_HEAD(&vhost_devices, hdev, entry); r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_OWNER, NULL); -- 1.8.3.1