Commit Graph

7 Commits

Author SHA1 Message Date
Richard W.M. Jones
61d4891ef4 mllib: Split ‘Common_utils’ into ‘Std_utils’ + ‘Common_utils’.
The new module ‘Std_utils’ contains only functions which are pure
OCaml and depend only on the OCaml stdlib.  Therefore these functions
may be used by the generator.

The new module is moved to ‘common/mlstdutils’.

This also removes the "<stdlib>" hack, and the code which copied the
library around.

Also ‘Guestfs_config’, ‘Libdir’ and ‘StringMap’ modules are moved
since these are essentially the same.

The bulk of this change is just updating files which use
‘open Common_utils’ to add ‘open Std_utils’ where necessary.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
b4728fd004 generator: Annotate returned strings which are devices or mountables.
Previously the generator did not change any string returned from the
daemon.  Thus guestfs_list_devices (for example) might return internal
device names like /dev/vda (if virtio-blk was in use).

This changes calls to the daemon so that returned strings are
annotated as plain strings, devices or mountables:

    old               --->     new
  RString "uuid"             RString (RPlainString "uuid")
  RString "device"           RString (RDevice "device")
  RString "fs"               RString (RMountable "fs")

For hash tables, keys and values must be annotated separately.  For
example a hash table of mountables (keys) -> plain strings (values)
would be annotated like this:

    old               --->     new
  RHashtable "fses"          RHashtable (RMountable, RPlainString, "fses")

The daemon calls reverse_device_name_translation (currently a no-op)
for devices and mountables.

Note that this has no effect for calls which are handled on the
library side.

(cherry picked from commit 6b77cc196ecb8d7e1d73592ef65a189a7412c97c)
2017-05-08 11:14:45 +01:00
Richard W.M. Jones
30411ef623 generator: Simplify the handling of string parameters.
Previously we had lots of types like String, Device, StringList,
DeviceList, etc. where Device was just a String with magical
properties (but only inside the daemon), and DeviceList was just a
list of Device strings.

Replace these with some simple top-level types:

  String
  StringList

and move the magic into a subtype.

The change is mechanical, for example:

    old                     --->    new
  FileIn "filename"               String (FileIn, "filename")
  DeviceList "devices"            StringList (Device, "devices")

Handling BufferIn is sufficiently different from a plain String
throughout all the bindings that it still uses a top-level type.
(Compare with FileIn/FileOut where the only difference is in the
protocol, but the bindings can uniformly treat it as a plain String.)

There is no semantic change, and the generated files are identical
except for a minor change in the (deprecated) Perl
%guestfs_introspection table.
2017-05-03 19:26:18 +01:00
Richard W.M. Jones
4bbb1f7490 lib: Prefer tirpc for XDR, and rationalise how we search for alternatives.
glibc in Fedora is currently configured with `--enable-obsolete-rpc',
so I guess we can see which way the wind is blowing.

(1) This changes our configure script to prefer libtirpc if it is
available.

If libtirpc is _not_ available then:

(a) Headers must be located in <rpc/xdr.h>, or the user must supply
the right CFLAGS.

(b) XDR functions must be located in one of -lportablexdr, -lrpc,
-lxdr, -lnsl or no library at all (ie. -lc), and the user must set
LDFLAGS if needed.

(2) We no longer add these paths automatically to $(CFLAGS)/$(LIBS).
Any part of libguestfs which needs <rpc/*.h> or the xdr_* functions
must use $(RPC_CFLAGS)/$(RPC_LIBS) explicitly.

(3) Previously Mac OS X had a workaround for the broken 64 bit support
in the supplied rpcgen.  This workaround "activates" all the time if
you use tirpc, so breaking Linux after the above changes.  tirpc is
supported on OS X, so I think it's just better to use that rather than
the broken rpcgen.  For that reason I removed the workaround
completely.

Thanks: Roy Keene
2017-03-07 12:54:17 +00:00
Richard W.M. Jones
3a4a491712 generator: Put all the daemon procedure numbers (proc_nr) into a single table.
Daemon 'proc_nr's have to be assigned monotonically and uniquely to
each daemon function.  However in practice it can be difficult to work
out which is the next free proc_nr.  Placing all of them into a single
table in a new file (proc_nr.ml) should make this easier.
2017-02-21 17:23:21 +00:00
Richard W.M. Jones
18777adf31 generator: Stablise output of common/protocol/*, daemon/*, lib/* and tests/c-api/tests.c
Sort the functions so the output is stable.

This changes the order in which the C API tests run.  Previously we
ran the newest tests first, which was useful when we were frequently
adding new APIs.  Now we run them in sorted order.
2017-02-21 17:23:21 +00:00
Richard W.M. Jones
e79a2af219 generator: Make 'main.ml' clearer.
- Make module name explicit, so it's more obvious which module a
  function is defined in.

- Group lines of code by feature.

- Capitalize some module names properly.

Just code motion, no functional change.
2017-01-29 17:32:22 +00:00