Commit Graph

62 Commits

Author SHA1 Message Date
Richard W.M. Jones
a706ecb8f7 Make sure every *.ml file has a corresponding *.mli file. 2017-09-21 18:05:07 +01:00
Richard W.M. Jones
290e4608f4 daemon: Remove vestigial daemon/types.ml file.
This file was empty and unused, likely left over from refactorings
while the daemon inspection code was being written.

Fixes commit d5b6f1df5f.
2017-09-21 18:05:07 +01:00
Richard W.M. Jones
d5b6f1df5f daemon: Allow parts of the daemon and APIs to be written in OCaml.
This change allows parts of the daemon to be written in the OCaml
programming language.  I am using the ‘Main Program in C’ method along
with ‘-output-obj’ to create an object file from the OCaml code /
runtime, as described here:
https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html

Furthermore, change the generator to allow individual APIs to be
implemented in OCaml.  This is picked by setting:

  impl = OCaml <ocaml_function>;

The generator creates ‘do_function’ (the same one you would have to
write by hand in C), with the function calling the named
‘ocaml_function’ and dealing with marshalling/unmarshalling the OCaml
parameters.
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
f5f7f00a46 gobject: Remove gtk-doc (RHBZ#1465665).
The gobject bindings are adequately covered in the usual manual pages:
guestfs(3).  There is no need for separate generation of gtk-doc.
Also generating gtk documentation is the slowest part of the build,
and the tooling around gtk-doc is broken
(https://bugzilla.redhat.com/show_bug.cgi?id=1465665).

Note this removes the configure ‘--enable-gtk-doc’ option.  Using this
option now gives a warning, but is otherwise ignored:

  configure: WARNING: unrecognized options: --enable-gtk-doc
2017-07-10 17:03:19 +01:00
Richard W.M. Jones
5efebd8c7e utils: Split out structs cleanups and printing into common/structs.
These won't be used by the daemon, so interferes with us using
common/utils in the daemon, so they are moved to a different library.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
7489d22843 common/utils: Move ‘uefi.c’ to ‘lib/’.
This was only used inside the library, so move it there.
2017-07-10 17:01:59 +01:00
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
34755dd86a generator, p2v: Generate AUTHORS and p2v/about-authors.c from a single place.
This also improves the "Credits" box in virt-p2v.  With Gtk >= 3.4
this can now show all contributors organized by the nature of their
contribution.
2017-03-25 14:04:44 +00:00
Pino Toscano
509adede7b generator: open Common_utils where needed
This makes it possible to use the operators from Common_utils that do
not exist in older OCaml versions (e.g. < 4.00).

Thanks to: John Sucaet.
2017-03-15 16:45:41 +01:00
Pino Toscano
32f0f9b032 daemon: generate cleanup handlers for structs
This way it is possible to cleanup properly structs in the daemon, when
using them within other daemon functions.
2017-03-13 08:53:49 +01: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
Richard W.M. Jones
f161c9ea57 Rename src/ to lib/ 2017-01-26 15:05:46 +00:00
Richard W.M. Jones
b53cec584d lib: Move utilities to new directory common/utils.
Just code motion.

This commit makes it clearer what is a utility and what is part of the
library.  It also makes it clear that we should rename:

  guestfs-internal-frontend.h -> utils.h
  guestfs-internal-frontend-cleanups.h -> cleanups.h (?)

but this commit does not make that change.
2017-01-26 15:05:46 +00:00
Richard W.M. Jones
88c0ce2397 lib: Share common protocol and errnostring libraries with the library and daemon.
This commit, which is just code motion, moves the common XDR protocol
code (libprotocol) and the common errno handling (liberrnostring) into
libraries which are each built once and shared between the library and
daemon.
2017-01-26 15:05:46 +00:00
Pino Toscano
55bf7de97c Update copyright dates for 2017
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2016/$1-2017/g' `git ls-files`

(Thanks Rich for the perl snippet, as used in past years.)
2017-01-03 16:48:21 +01:00
Richard W.M. Jones
c4b7b5d615 erlang: Split up large Erlang extension into smaller C files.
Reduce build times in this directory from about 10s to about 2s.
2016-09-02 23:14:08 +01:00
Richard W.M. Jones
76eee79a65 java: Split up large Java extension into smaller C files. 2016-09-02 23:14:08 +01:00
Richard W.M. Jones
63db9ae81f python: Split up large Python extension into smaller C files.
Reduces build time in this directory from 11s to 3s.
2016-09-02 23:14:08 +01:00
Richard W.M. Jones
20aa0f6496 ruby: Split up large Ruby extension into smaller C files. 2016-09-02 23:14:08 +01:00
Richard W.M. Jones
20f190617a daemon: Split up very large daemon/stubs.c file. 2016-09-02 23:14:08 +01:00
Richard W.M. Jones
a749b5d93a fish: Split up the very large fish/cmds.c file.
Make parallel compiles faster in this directory (about 8s down to 3s).
2016-09-02 23:14:08 +01:00
Richard W.M. Jones
4730f4a918 generator: Generalize the code used to split actions across files.
Previously we used an awkward hack to split up the large src/actions.c
into smaller files (which can benefit from being compiled in
parallel).  This commit generalizes that code, so that we pass a
subsetted actions list to certain generator functions.

The output of the generator is identical after this commit and the
previous commit, except for the UUID encoded into tests/c-api/tests.c
since that is derived from the MD5 hash of generator/actions.ml.
2016-09-02 23:14:08 +01:00
Richard W.M. Jones
f8978239e3 generator: Move all actions into a single list and add filter functions.
This mostly mechanical change moves all of the libguestfs API
lists of functions into a struct in the Actions module.

It also adds filter functions to be used elsewhere to get
subsets of these functions.

Original code         Replacement

all_functions         actions

daemon_functions      actions |> daemon_functions
non_daemon_functions  actions |> non_daemon_functions
external_functions    actions |> external_functions
internal_functions    actions |> internal_functions
documented_functions  actions |> documented_functions
fish_functions        actions |> fish_functions

*_functions_sorted    ... replacement as above ... |> sort
2016-09-02 23:14:08 +01:00
Richard W.M. Jones
0c396650b0 Generate the lists of UEFI firmware paths.
Previously we had a list of UEFI paths in src/uefi.c, which was
accessed in virt-v2v using a private (guestfs_int_*) API and some C
binding code.  This was clumsy and required the paths to be replicated
in the virt-v2v unit tests.

Instead just generate the list of paths from the generator, creating
src/uefi.c and v2v/uefi.ml with the same content.

Remove the C bindings and the virt-v2v unit tests associated with UEFI
paths.
2016-08-18 14:48:51 +01:00
Pino Toscano
1c9e808eee fish: generate test-prep.sh with generator
Generate test-prep.sh using the generator, so the prepared disk types
tested are the same as the ones configured in prepopts.ml.
2016-05-19 19:06:00 +02:00
Pino Toscano
2c0d16e82e src: generate code for printing contents of structs
Extend the generator to generate a source (and the header for it) with
functions that print the content of a guestfs struct.  The code is
modelled after the code for it in fish.ml, although made a bit more
generic (destination FILE*, line separator) so it can be used also in
the library, when tracing.

This just introduces the new code and builds it as part of the helper
libutils.la.
2016-02-24 13:47:18 +01:00
Richard W.M. Jones
9eb26a1748 generator: gobject: Remove parameters which are not used.
Revealed by adding typed interfaces in the previous commit.
2016-02-23 10:40:05 +00:00
Pino Toscano
7a598a0c02 php: restructure and expand tests
Rename the existing tests according to the naming/numbering described in
guestfs-hacking(1), and improve the current ones:
- guestfs_php_001.phpt: rename to guestfs_020_create.phpt
- guestfs_php_003.phpt: rename to guestfs_070_optargs.phpt
- guestfs_php_bindtests.phpt: rename to guestfs_090_bindtests.phpt
- guestfs_090_version.phpt: new, checks taken from the former
  guestfs_php_002.phpt
- guestfs_100_launch.phpt: new, modelled after the equivalent in e.g.
  OCaml/Perl/Python
- guestfs_php_002.phpt: remove, as what it did is now covered by
  090_version and 100_launch
2016-02-12 15:10:07 +01:00
Richard W.M. Jones
2a48a6591f java: Stop using the safe_malloc, etc. functions. 2016-02-05 13:16:22 +00:00
Richard W.M. Jones
307c83177c Update copyright dates for 2016.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2015/$1-2016/g' `git ls-files`
2016-01-02 21:19:51 +00:00
Richard W.M. Jones
f98e0f115b perl: Switch to using Module::Build.
Replace ExtUtils::MakeMaker with Module::Build.

'perllocal.pod' and 'bindtests.pl' are no longer incorrectly
installed.

This change also removes the following phony deps: appliance src_deps
test_images.  No other language binding needs explicit dependencies
for their tests, they just rely on the top level build order being
correct (ie. SUBDIRS in /Makefile.am).
2015-10-24 12:36:28 +01:00
Pino Toscano
649f439cb7 ocaml: dynamically generate the content of Guestfs.Errno
Put in a list the errnos to expose, filling the content of the
Guestfs.Errno submodule from that.
Also, generate a separate guestfs-c-errnos.c with the implementations of
the functions returning the errno codes.

Only code motion and refactoring, no actual changes on the content of
the ocaml Guestfs module.
2015-08-24 17:57:10 +02:00
Richard W.M. Jones
9c773962c5 Remove src/api-support and generate this information from actions added field. 2015-05-26 21:13:44 +01:00
Pino Toscano
3b8d56d491 php: add a simple bindtests test
Generate a simple bindtests test for the PHP binding, so it is possible
to easily test all the argument types.

Unlike the bindtests for other languages, optional arguments are not
tested, due to the limitations of optional arguments in PHP (or maybe
they way we implement them).
2015-02-11 15:02:57 +01:00
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Richard W.M. Jones
3562a81683 generator: Change type of 'tests' to 'c_api_tests'.
Just a code refactoring, has no functional effect.
2014-09-17 17:31:50 +01:00
Richard W.M. Jones
4b0b3589e8 customize: Move virt-customize-related code to a separate directory.
Split virt-builder into build and customize steps, so that we can spin
off a separate tool called 'virt-customize'.  This commit does not in
fact create such a tool, but it moves all the common code into a
library, in the customize/ subdirectory of the source.

Although this is mostly refactoring, it does change the order in which
virt-builder command line arguments are processed, so they are now
processed in the order they appear, not the inflexible fixed order
used before.
2014-03-25 12:41:04 +00:00
Richard W.M. Jones
6cc521dc45 generator: Sort most output.
Look for use of external_functions and fish_functions and replace with
use of external_functions_sorted and fish_functions_sorted where
possible.  This ensures that the output of the generator is sorted as
far as possible.

I also checked for uses of internal_functions and documented_functions
but those are not used.  The *_sorted versions are always used
instead.
2014-02-15 20:27:12 +00:00
Richard W.M. Jones
6c971faecf Update copyright dates for 2014. 2014-01-02 16:53:34 +00:00
Richard W.M. Jones
78b9229bc8 lib: Export guestfs_compare_* functions for comparing structs and lists of structs. 2013-12-18 15:15:52 +00:00
Richard W.M. Jones
3d398687be lib: Export guestfs_copy_* functions for copying structs and lists of structs.
These complement the guestfs_free_* functions.
2013-12-18 15:15:52 +00:00
Richard W.M. Jones
0f3489ba6b lib: Rename cleanup-structs.c -> structs-cleanup.c and free-structs.c -> structs-free.c.
Just renaming generated files, no other effects.
2013-12-18 15:15:52 +00:00
Richard W.M. Jones
58b51f5921 golang: Add bindtests. 2013-07-04 14:01:27 +01:00
Richard W.M. Jones
b6f01f3260 Add Go (language) bindings. 2013-07-03 15:02:57 +01:00
Richard W.M. Jones
e72855e4fa generator: Make stamp-generator in the Makefile.
Since stamp-generator is a Makefile thing, make it in the Makefile,
not in the generator itself.

Also this ensures stamp-generator is created in the builddir, not in
the source directory (fixing separated builds).
2013-04-25 12:22:31 +01:00
Richard W.M. Jones
1a06ac25f5 fish: Add help for prepared disk images to the man page.
Also the long description for each prepared disk image can now contain
Perl POD markup.
2013-04-10 12:28:14 +01:00
Richard W.M. Jones
04723b4dd1 lib: Create libutils convenience library.
The libutils convenience library is a place for code shared between
the main library, language bindings and virt tools.  Note that the
code is statically linked into both the library, each binding and each
tool, but this is an improvement because (a) the source is shared and
(b) libguestfs.so can export fewer private functions.

Currently it contains the cleanup functions, and the functions
guestfs___free_string_list function and guestfs___for_each_disk.

guestfs___for_each_disk has changed so that it no longer
unconditionally sets the error in the guestfs handle.  Instead callers
can control error handling.
2013-02-20 19:15:05 +00:00
Richard W.M. Jones
b793fafcb7 New C only API: guestfs_event_to_string. 2013-02-19 13:41:57 +00:00
Richard W.M. Jones
5f54da6fdf lib: Add CLEANUP_FREE_<struct>, CLEANUP_FREE_<struct>_LIST macros for API structs.
For example:

 {
   CLEANUP_FREE_STAT struct guestfs_stat *stat = guestfs_stat (g, "/foo");

   // stat is freed automatically when we leave the scope.
 }

The new header file "guestfs-internal-frontend-cleanups.h"
includes definitions for these.  It should not be included
directly.
2013-02-08 16:12:04 +00:00
Matthew Booth
ca056d53bd generator: Add visibility to action struct
The visibility field in action replaces in_fish, in_docs and internal.
The defined types are:

VPublic:
  A public API. This is exported and documented in all language
  bindings, and in guestfish.

VStateTest:
  A public API which queries the library state machine. It is exported
  and documented in all language bindings, but not guestfish.

VBindTest:
  An internal API used only for testing language bindings. It is
  guarded by GUESTFS_PRIVATE in the C api, but exported by all other
  language bindings as it is required for testing. If language
  bindings offer any way to guard use of these apis, that mechanism
  should be used. It is not documented anywhere.

VDebug:
  A debugging API. It is exported by all language bindings, and in
  guestfish, but is not documented anywhere.

VInternal:
  An internal-only API. It is guarded by GUESTFS_PRIVATE in the C api,
  and not exported at all in any other language binding. It is not
  documented anywhere.
2013-02-06 13:53:28 +00:00