From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NrkbN-0007kn-PY for qemu-devel@nongnu.org; Wed, 17 Mar 2010 00:11:25 -0400 Received: from [199.232.76.173] (port=54976 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrkbN-0007kf-Ef for qemu-devel@nongnu.org; Wed, 17 Mar 2010 00:11:25 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NrkbK-000062-21 for qemu-devel@nongnu.org; Wed, 17 Mar 2010 00:11:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30591) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NrkbH-00005S-PT for qemu-devel@nongnu.org; Wed, 17 Mar 2010 00:11:20 -0400 Date: Wed, 17 Mar 2010 09:39:52 +0530 From: Amit Shah Message-ID: <20100317040952.GC20122@amit-x200.redhat.com> References: <36c10281d19b4c845444363273657c4709210e35.1267636215.git.mst@redhat.com> <20100305181911.GA24686@amit-x200.redhat.com> <20100306190635.GB12235@redhat.com> <20100308062023.GD8436@amit-x200.redhat.com> <20100316153739.GA13674@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100316153739.GA13674@redhat.com> Subject: [Qemu-devel] Re: [PATCHv4 09/12] vhost: vhost net support List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: quintela@redhat.com, qemu-devel@nongnu.org, kraxel@redhat.com On (Tue) Mar 16 2010 [17:37:39], Michael S. Tsirkin wrote: > On Mon, Mar 08, 2010 at 11:50:23AM +0530, Amit Shah wrote: > > On (Sat) Mar 06 2010 [21:06:35], Michael S. Tsirkin wrote: > > > > > > > > + r = vhost_virtqueue_set_addr(dev, vq, idx, dev->log_enabled); > > > > > + if (r < 0) { > > > > > + r = -errno; > > > > > + goto fail_alloc; > > > > > + } > > > > > + if (!vdev->binding->guest_notifier || !vdev->binding->host_notifier) { > > > > > + fprintf(stderr, "binding does not support irqfd/queuefd\n"); > > > > > + r = -ENOSYS; > > > > > + goto fail_alloc; > > > > > + } > > > > > > > > This could be checked much earlier on in the function; so that we avoid > > > > doing all that stuff above and the cleanup. > > > > > > Whatever order we put checks in, we'll have to undo stuff > > > done beforehand on error. > > > > Not if you do this check before any ioctls or allocations. > > !vdev->binding->guest_notifier is not dependent on anything you do above > > it in this function, so just checking for this first thing in the > > function will not need any cleanup. > > Yes, but I think it's clearer to do check function just before > calling it. No? The good thing about doing it before is that we can check for whatever conditions are not met first and exit instead of doing N things and undoing them later and then exiting -- faster and more efficient in the case when vhost is not being used. Amit -- http://log.amitshah.net/