[Libguestfs] [libnbd PATCH 5/6] api: Add new nbd_aio_FOO_notify functions

Richard W.M. Jones rjones at redhat.com
Sat Jun 29 17:28:24 UTC 2019


Obvious change given the previous patch, so ACK.

I do wonder if we should make the notify parameter mandatory (and
therefore avoid the duplicate functions).

Another trick you might do if feeling really keen is to
programmatically generate the notify variants of commands, something
like this:

let make_notify_variant_of_call ({ args; longdesc } as call) =
  let args = List.rev args in
  let flags, args = List.hd args, List.tl args in
  assert (flags = Flags "flags");
  let args = flags :: CallbackPersist ("notify", [ etc ]) :: args in
  let args = List.rev args in
  let longdesc = longdesc ^ "\nThe C<notify> callback blah blah ..." in
  { call with args; longdesc }

let aio_pwrite_call = {
  default_call with
  args = [ BytesPersistIn ("buf", "count"); UInt64 "offset"; Flags "flags" ]; ]
  (* etc copy the definition of aio_pwrite *)
}

let aio_pwrite_notify_call = make_notify_variant_of_call aio_pwrite_call

let handle_calls = [
  ...
  "aio_pwrite", aio_pwrite_call;
  "aio_pwrite_notify", aio_pwrite_notify_call;
  ...
]

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list