qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v3 05/10] block: add transactional callbacks fea


From: Max Reitz
Subject: Re: [Qemu-block] [PATCH v3 05/10] block: add transactional callbacks feature
Date: Thu, 23 Apr 2015 17:32:21 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

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 <address@hidden>
---
  blockdev.c | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
  1 file changed, 179 insertions(+), 4 deletions(-)

Reviewed-by: Max Reitz <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]