Received: from eggs.gnu.org ([2001:4830:134:3::10]:59203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjQo7-0006sg-Hn for qemu-devel@nongnu.org; Mon, 03 Jun 2013 05:12:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UjQnv-0003pP-KX for qemu-devel@nongnu.org; Mon, 03 Jun 2013 05:12:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27056) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjQnv-0003pB-Au for qemu-devel@nongnu.org; Mon, 03 Jun 2013 05:11:51 -0400 Date: Mon, 3 Jun 2013 11:11:43 +0200 From: Stefan Hajnoczi Message-ID: <20130603091143.GB16498@stefanha-thinkpad.redhat.com> References: <1369917299-5725-1-git-send-email-stefanha@redhat.com> <1369917299-5725-2-git-send-email-stefanha@redhat.com> <51A7D264.1020102@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51A7D264.1020102@redhat.com> Subject: Re: [Qemu-devel] [PATCH v5 01/11] notify: add NotiferWithReturn so notifier list can abort List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, xiawenc@linux.vnet.ibm.com, imain@redhat.com, Paolo Bonzini , dietmar@proxmox.com On Thu, May 30, 2013 at 04:27:48PM -0600, Eric Blake wrote: > On 05/30/2013 06:34 AM, Stefan Hajnoczi wrote: > > notifier_list_notify() has no return value. This is fine when we just > > want to invoke side-effects. > > > > Sometimes it's useful for notifiers to produce a return value. This > > allows notifiers to "veto" an operation and will be used by the block > > layer before-write notifier. > > > > Signed-off-by: Stefan Hajnoczi > > --- > > include/qemu/notify.h | 25 +++++++++++++++++++++++++ > > util/notify.c | 30 ++++++++++++++++++++++++++++++ > > 2 files changed, 55 insertions(+) > > > > diff --git a/include/qemu/notify.h b/include/qemu/notify.h > > index 4e2e7f0..d3103e7 100644 > > --- a/include/qemu/notify.h > > +++ b/include/qemu/notify.h > > @@ -40,4 +40,29 @@ void notifier_remove(Notifier *notifier); > > > > void notifier_list_notify(NotifierList *list, void *data); > > > > +/* Same as Notifier but allows .notify() to return errors */ > > It's probably worth documenting that the callback must return 0 for > success, and that the first non-zero return is passed back without > further interpretation (thus allowing negative errno values if desired, > vs. a simpler -1). You are right, let's improve the doc comments. > Isn't this really just syntax sugar since existing notifiers could > already use a member within the opaque *data argument as a way to > short-circuit later notifiers on earlier errors? If so, how hard would > it be to scrub the existing code base to always return 0 in existing > notifiers, rather than adding a parallel naming scheme? I considered both approaches and decided on NotifierWithReturn because it neither touches existing users nor adds a side-effect for aborting. BTW adding a side-effect in the BdrvTrackedRequest case is ugly, the struct is used for more than just the pre-write notifier and the field would be useless in the other cases. Stefan