On 2017-10-10 00:28, Eric Blake wrote: > On 10/09/2017 04:55 PM, Max Reitz wrote: >> Some qcow2 functions (at least perform_cow()) expect s->lock to be >> taken. Therefore, if we want to make use of them, we should execute >> preallocate() (as "preallocate_co") in a coroutine so that we can use >> the qemu_co_mutex_* functions. >> >> Signed-off-by: Max Reitz <[email protected]> >> --- >> block/qcow2.c | 41 ++++++++++++++++++++++++++++++++++------- >> 1 file changed, 34 insertions(+), 7 deletions(-) >> > >> +++ b/block/qcow2.c >> @@ -2460,6 +2460,14 @@ static int qcow2_set_up_encryption(BlockDriverState >> *bs, const char *encryptfmt, >> } >> >> >> +typedef struct PreallocCo { >> + BlockDriverState *bs; >> + uint64_t offset; >> + uint64_t new_length; >> + >> + int ret; >> +} PreallocCo; > > Because you create a typedef here... > > >> +static void coroutine_fn preallocate_co(void *opaque) >> { >> + struct PreallocCo *params = opaque; > > you could drop 'struct' here, the way you already dropped it...
Ah, yes, that was from before I added the typedef... Will fix.
Max
>
>> +static int preallocate(BlockDriverState *bs,
>> + uint64_t offset, uint64_t new_length)
>> +{
>> + PreallocCo params = {
>> + .bs = bs,
>> + .offset = offset,
>> + .new_length = new_length,
>> + .ret = -EINPROGRESS,
>> + };
>
> ...here. But that doesn't change semantics, so either way,
>
> Reviewed-by: Eric Blake <[email protected]>
>
signature.asc
Description: OpenPGP digital signature
