From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKkoq-00083q-BH for qemu-devel@nongnu.org; Thu, 30 Jul 2015 06:12:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZKkop-0006oH-EC for qemu-devel@nongnu.org; Thu, 30 Jul 2015 06:12:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60399) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKkop-0006oB-A9 for qemu-devel@nongnu.org; Thu, 30 Jul 2015 06:12:07 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 0F1E61CA6DD for ; Thu, 30 Jul 2015 10:12:07 +0000 (UTC) From: Igor Mammedov Date: Thu, 30 Jul 2015 12:11:59 +0200 Message-Id: <1438251119-285996-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1438251119-285996-1-git-send-email-imammedo@redhat.com> References: <1438251119-285996-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH for-2.4 v3 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: pbonzini@redhat.com, mst@redhat.com Signed-off-by: Igor Mammedov --- hw/virtio/vhost.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index bcbad48..48fbac1 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -985,6 +985,12 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, hdev->started = false; hdev->memory_changed = false; memory_listener_register(&hdev->memory_listener, &address_space_memory); + if (!vhost_has_free_slot()) { + fprintf(stderr, "vhost backend memory slots limit is less" + " than current number of present memory slots\n"); + vhost_dev_cleanup(hdev); + return -1; + } return 0; fail_vq: while (--i >= 0) { -- 1.8.3.1