On Thu, Aug 11, 2011 at 4:27 PM, Paolo Bonzini <pbonz...@redhat.com> wrote:
> On 08/11/2011 05:12 PM, Kevin Wolf wrote:
>>>
>>> >  Another possibility is always completing DMA in a bottom half.  This
>>> >  ensures that the callback can access the AIOCB, but it exposes an
>>> >  implementation detail to the caller, so I don't like it.
>>
>> At least in the block layer, AIO callbacks may never be called before
>> the submission function has returned. I think this makes the DMA helpers
>> provide the same behaviour.
>>
>> But I'm not sure if the definition of the AIOCB struct isn't private to
>> the block layer.
>
> Yes, it is; I would add a getter that is specific to the DMAAIOCB.

You don't need to make the dma_bdrv_io() cb function a
BlockDriverCompletionFunc.  Instead define a DMACompletionFunc:

typedef void DMACompletionFunc(void *opaque, int ret,
target_phys_addr_t residual);

The only one invoking dbs->common.cb is dma-helpers.c so you can just
avoid using common.cb and instead use a DMACompletionFunc cb.

Perhaps the AIOCB concept can be made generic where BlockDriverAIOCB
inherits from it.  I'm not even so sure that keeping a
BlockDriverState pointer around is that useful.  At least
dma-helpers.c seems to think it's too much typing and it just
duplicates the bs field into DMAAIOCB directly :).  The question then
becomes how to abstract the typed callback function nicely.

Stefan

Reply via email to