From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlJ79-0002eG-1l for qemu-devel@nongnu.org; Thu, 23 Apr 2015 11:32:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YlJ74-0002UL-2E for qemu-devel@nongnu.org; Thu, 23 Apr 2015 11:32:30 -0400 Message-ID: <55391085.6040107@redhat.com> Date: Thu, 23 Apr 2015 17:32:21 +0200 From: Max Reitz MIME-Version: 1.0 References: <1429747493-24397-1-git-send-email-jsnow@redhat.com> <1429747493-24397-6-git-send-email-jsnow@redhat.com> In-Reply-To: <1429747493-24397-6-git-send-email-jsnow@redhat.com> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 05/10] block: add transactional callbacks feature List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow , qemu-block@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, vsementsov@parallels.com, stefanha@redhat.com On 23.04.2015 02:04, John Snow wrote: > The goal here is to add a new method to transactions that allows > developers to specify a callback that will get invoked only once > all jobs spawned by a transaction are completed, allowing developers > the chance to perform actions conditionally pending complete success, > partial failure, or complete failure. > > In order to register the new callback to be invoked, a user must request > a callback pointer and closure by calling new_action_cb_wrapper, which > creates a wrapper around an opaque pointer and callback that would have > originally been passed to e.g. backup_start(). > > The function will return a function pointer and a new opaque pointer to > be passed instead. The transaction system will effectively intercept the > original callbacks and perform book-keeping on the transaction after it > has delivered the original enveloped callback. > > This means that Transaction Action callback methods will be called after > all callbacks triggered by all Actions in the Transactional group have > been received. > > This feature has no knowledge of any jobs spawned by Actions that do not > inform the system via new_action_cb_wrapper(). > > For an example of how to use the feature, please skip ahead to: > 'block: drive_backup transaction callback support' which serves as an example > for how to hook up a post-transaction callback to the Drive Backup action. > > > Note 1: Defining a callback method alone is not sufficient to have the new > method invoked. You must call new_action_cb_wrapper() AND ensure the > callback it returns is the one used as the callback for the job > launched by the action. > > Note 2: You can use this feature for any system that registers completions of > an asynchronous task via a callback of the form > (void *opaque, int ret), not just block job callbacks. > > Signed-off-by: John Snow > --- > blockdev.c | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 179 insertions(+), 4 deletions(-) Reviewed-by: Max Reitz