From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKpmP-0001x5-SB for qemu-devel@nongnu.org; Thu, 30 Jul 2015 11:30:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZKpmK-0003Px-Iu for qemu-devel@nongnu.org; Thu, 30 Jul 2015 11:29:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60197) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKpmK-0003PL-E4 for qemu-devel@nongnu.org; Thu, 30 Jul 2015 11:29:52 -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 0B8BA461EE for ; Thu, 30 Jul 2015 15:29:51 +0000 (UTC) Date: Thu, 30 Jul 2015 18:29:49 +0300 From: "Michael S. Tsirkin" Message-ID: <20150730182849-mutt-send-email-mst@redhat.com> References: <1438251119-285996-1-git-send-email-imammedo@redhat.com> <1438251119-285996-4-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438251119-285996-4-git-send-email-imammedo@redhat.com> Subject: Re: [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: Igor Mammedov Cc: pbonzini@redhat.com, qemu-devel@nongnu.org On Thu, Jul 30, 2015 at 12:11:59PM +0200, Igor Mammedov wrote: > 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()) { I think this one needs a different test: we are not adding a new slot so just checking <= there should be enough. > + 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