[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 01/11] notify: add NotiferWithReturn so notif
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v5 01/11] notify: add NotiferWithReturn so notifier list can abort |
Date: |
Thu, 30 May 2013 16:27:48 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 |
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 <address@hidden>
> ---
> 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).
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 <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v5 10/11] blockdev: add Abort transaction, (continued)
- [Qemu-devel] [PATCH v5 04/11] blockdev: drop redundant proto_drv check, Stefan Hajnoczi, 2013/05/30
- [Qemu-devel] [PATCH v5 07/11] blockdev: rename BlkTransactionStates to singular, Stefan Hajnoczi, 2013/05/30
- [Qemu-devel] [PATCH v5 05/11] blockdev: use bdrv_getlength() in qmp_drive_mirror(), Stefan Hajnoczi, 2013/05/30
- [Qemu-devel] [PATCH v5 02/11] block: add bdrv_add_before_write_notifier(), Stefan Hajnoczi, 2013/05/30
- [Qemu-devel] [PATCH v5 11/11] qemu-iotests: add 055 drive-backup test case, Stefan Hajnoczi, 2013/05/30
- [Qemu-devel] [PATCH v5 01/11] notify: add NotiferWithReturn so notifier list can abort, Stefan Hajnoczi, 2013/05/30
- Re: [Qemu-devel] [PATCH v5 01/11] notify: add NotiferWithReturn so notifier list can abort,
Eric Blake <=
- [Qemu-devel] [PATCH v5 06/11] block: add drive-backup QMP command, Stefan Hajnoczi, 2013/05/30
- [Qemu-devel] [PATCH v5 03/11] block: add basic backup support to block driver, Stefan Hajnoczi, 2013/05/30