From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiBK7-0004Ck-Hk for qemu-devel@nongnu.org; Thu, 30 May 2013 18:27:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiBK6-0004wG-Fy for qemu-devel@nongnu.org; Thu, 30 May 2013 18:27:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22227) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiBK5-0004w8-Tk for qemu-devel@nongnu.org; Thu, 30 May 2013 18:27:54 -0400 Message-ID: <51A7D264.1020102@redhat.com> Date: Thu, 30 May 2013 16:27:48 -0600 From: Eric Blake MIME-Version: 1.0 References: <1369917299-5725-1-git-send-email-stefanha@redhat.com> <1369917299-5725-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1369917299-5725-2-git-send-email-stefanha@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2HKWXUXDCHKVOADMPXELG" 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: Stefan Hajnoczi Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, xiawenc@linux.vnet.ibm.com, imain@redhat.com, Paolo Bonzini , dietmar@proxmox.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2HKWXUXDCHKVOADMPXELG Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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. >=20 > 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. >=20 > Signed-off-by: Stefan Hajnoczi > --- > include/qemu/notify.h | 25 +++++++++++++++++++++++++ > util/notify.c | 30 ++++++++++++++++++++++++++++++ > 2 files changed, 55 insertions(+) >=20 > 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); > =20 > void notifier_list_notify(NotifierList *list, void *data); > =20 > +/* 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). 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? At any rate, adding a new naming scheme minimizes churn, and the code itself looks okay; Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2HKWXUXDCHKVOADMPXELG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRp9JkAAoJEKeha0olJ0NqfywH/RjvyLmInKKZ7vMw3CYp7iis yKpoHAUyX6pbaUZIn1Z0N5JlP5Rb7AFPu+ZlECA2o032NONPjQ5KIhPYTC6joNVP at3tvsnK3WPQKWG/9zwE40uv+feWSUQBTXOkbjK+nyxyQubBm3SSustR18HpCoyN zISxyxGL5Y6FT9QaFJs5IPMmkLWxzZ9fbU5zNrnZTphqxvz8LVgeBNuJs7xF2MUE yPWiUkIEsLJQl3llJ6Da0qCIdmT4jjpJfqdVaq5fI3Uop30duJ3zI5mPFHNemlDE cPDNViNHqayHNF/JGsBBw/65MVRK33qoPCve1Z/R9eQIxzznwjDrDWUTIah+3h0= =wvLF -----END PGP SIGNATURE----- ------enig2HKWXUXDCHKVOADMPXELG--