[Libguestfs] [libnbd PATCH 2/4] api: Rearrange flags argument to block_status

Richard W.M. Jones rjones at redhat.com
Tue May 28 09:24:25 UTC 2019


Patches 1 & 2 are fine, ACK.  I have a separate comment about patch 4
coming up.

In libguestfs we handle optional args by putting them in a
separate list (so instead of { args; ret } we have we have
{ args; optargs; ret }).

This gets translated into a language like Python in the natural
way.  However for C it's translated into a varargs list with
a rather complex system of flags, see:

  http://libguestfs.org/guestfs.3.html#calls-with-optional-arguments

This has the advantage of supporting optional arguments that can be
nullable (or non-zero default value for ints) vs. not present.

On the other hand this may be overkill for libnbd.  If the only
optional argument we support we care about is a non-zero int (or say a
non-nullable string where NULL = not present) then mixing the optional
args into the same list could be fine.

Do we have a good idea about what optional arguments apart from
non-zero ints we might need in future?

Also, does Python really require optional arguments to be last in the
list?  (OCaml can have them anywhere in the list)

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the Libguestfs mailing list