[Libguestfs] [PATCH libnbd] generator: Add Mutable type to the generator.

Eric Blake eblake at redhat.com
Tue Jun 25 17:43:47 UTC 2019


On 6/25/19 12:11 PM, Richard W.M. Jones wrote:
> Mutable (Int n) => int *n
> 
> This can currently only be used for callback arguments of type int
> (not for other types, nor for any ordinary function arguments), but it
> could be implemented more generally in future.
> ---
>  generator/generator | 75 +++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 63 insertions(+), 12 deletions(-)

Looks good to me.

As mentioned in other threads [1], I'm interested in attempting some
sort of:

nbd_aio_*_callback (other args, data, callback, flags)

for all transmission requests (or name it nbd_aio_*_with_notify, or
whatever other name we come up with), which calls the callback the
moment that particular reply from the server is ready. The ideal
callback signature would thus be:

int callback(void *opaque, int64_t handle, int *status)

where status on input is what the server replied, and on output is what
the overall nbd_aio_command_completed() will report.

In the nbdkit case, I'm hoping that the callback can change things -
right now, nbdkit uses the I/O polling thread to call
nbd_aio_command_completed with an nbdkit lock held, and for each
completed command, raise the semaphore to let the nbdkit thread that
issued the request wake back up. But with the callback, the I/O polling
thread doesn't ever have to grab an nbdkit lock - the callback would be
the one releasing the semaphore, then the nbdkit thread that made the
request would be the one also calling nbd_aio_command_completed.

Also, in the case of nbd_aio_pread_structured_callback(), it also
creates the nice setup of:

struct pread_validator *data =
generate_pread_structured_validator(offset, length, flags);
handle = nbd_aio_pread_structured_callback(h, buf, count, offset, data,
validate_chunk, validate_complete, flags);

so that validate_complete() can call the appropriate free(data) AND do
any final error manipulations (change a successful return into a failure
if there were insufficient calls to validate_chunk to cover the entire
buffer).


[1] https://www.redhat.com/archives/libguestfs/2019-June/msg00163.html

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190625/b5641693/attachment.sig>


More information about the Libguestfs mailing list