Commit Graph

274 Commits

Author SHA1 Message Date
Richard W.M. Jones
f30b2065a2 gobject: Add outline guestfs-gobject(3) manual page.
Since we removed gtk doc, we might as well replace it with a
manual page explaining the basics of how to run gjs.
2017-07-10 17:03:19 +01:00
Richard W.M. Jones
e6c89f9631 utils: Rename ‘guestfs-internal-frontend.h’ to ‘guestfs-utils.h’.
The reason it's not just ‘utils.h’ is because Pino is worried that we
might pick up /usr/include/utils.h from a rogue library.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
b2469a6d96 common/utils: Refactor stdlib, gnulib and libxml2 cleanup functions.
This refactoring change just moves the cleanup functions around in the
common/utils directory.

libxml2 cleanups are moved to a separate object file, so that we can
still link to libutils even if the main program is not using libxml2
anywhere.  Similarly gnulib cleanups.

cleanup.c is renamed to cleanups.c.

A new header file cleanups.h is introduced which will replace
guestfs-internal-frontend-cleanups.h (fully replaced in a later commit).
2017-07-10 17:01:59 +01:00
Pino Toscano
64e1101631 ocaml: do not try to malloc 0 elements in get_all_event_callbacks
In case there are no event handlers registered with the handle,
get_all_event_callbacks will count 0 elements, trying to malloc a buffer
of that size.  POSIX says that this can result in either a null pointer,
or an unusable pointer.

Short-circuit get_all_event_callbacks to allocate nothing when there are
no events, making sure to use its results only when there were events.
2017-03-06 09:02:02 +01: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
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
76c0a67d30 build: Add common CLEANFILES and DISTCLEANFILES to common-rules.mk.
By adding common CLEANFILES and DISTCLEANFILES variables to
common-rules.mk, we can remove these from most other Makefiles, and
also clean files more consistently.

Note that bin_PROGRAMS are already cleaned by 'make clean', so I
removed cases where these were unnecessarily added to CLEANFILES.
2016-08-25 16:54:34 +01:00
Pino Toscano
0b94c4d3bb build: add simple custom silent rules for automake
Add makefile variables to enable silent rules for simple command
invocations, such as ocamlc, ocamlopt, javac, and erlc.

This reduces the log output when building with silent rules, still
showing the full command lines otherwise.
2016-08-04 16:18:33 +02:00
Richard W.M. Jones
d5a8f82887 Use 'const' for stack integers where possible.
May improve optimization possibilities in a few cases.
2016-07-26 10:43:45 +01:00
Richard W.M. Jones
1beab198b9 ocaml: Add LDFLAGS to mlguestfs.cma/mlguestfs.cmxa.
Encode the build LDFLAGS into the OCaml library.
2016-04-30 12:49:28 +01:00
Richard W.M. Jones
b9a97718f7 tests: Use LOG_COMPILER to run valgrind. 2016-02-22 17:55:13 +00:00
Richard W.M. Jones
85b1815e7b tests: Make '080' be an official test of the guestfs_version API.
Useful because it tests returning a single structure.
2016-02-12 15:41:42 +00:00
Richard W.M. Jones
0445284dfb ocaml: Stop using the safe_malloc, etc. functions. 2016-02-05 13:15:48 +00:00
Richard W.M. Jones
53403fbdef ocaml, virt tools: More consistent naming for C functions.
For functions linked to virt tools, make sure the name of the function
actually matches the virt tool.  Because of the history of moving
functions across tools, some names no longer matched.

For mllib, use `guestfs_int_mllib_' prefix.

For OCaml bindings, use `guestfs_int_ocaml_' prefix.

This commit is by no means complete.  There are many other C functions
in other language bindings which could do with being more consistently
named.

There is no functional change, this is just refactoring.
2016-01-28 21:30:20 +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
a2edda266e build: Make 'make clean' remove more files.
Remove man pages and other pages which 'make clean' did not remove
before.

To evaluate which pages could be removed, I did a full build and
check, and then ran 'make clean' followed by 'git clean -xdf'.  By
examining the output of the git clean command I could see which files
were being missed.

Files that are _not_ removed by make clean or make distclean:

 - generator-built files

 - Makefile, Makefile.in, .deps, .depend

 - any ./configure output files (maybe they should be?)
2015-11-03 13:53:37 +00:00
Richard W.M. Jones
47b095b928 website: Put website into a separate directory.
Move the random set of HTML files we build from html/ into
the website/ directory.

Also in the website/ directory, put the index.html file from
http://libguestfs.org, which was previously not under version control.
It is generated from index.html.in so we can automatically add the
current version and release date.

Also in the website/ directory, put various CSS file, images, etc.
which are required by the website and were also previously not under
version control.

Change the 'make website' rule to 'make maintainer-upload-website'.
As the name suggests, it is only useful for the maintainer, and will
fail with an error for anyone else.
2015-10-31 17:09:29 +00:00
Richard W.M. Jones
1c506aa960 ocaml: Allow 'make install' to be run twice.
'ocamlfind install' doesn't like to install the same package if it is
already installed.  It will give errors like:

  ocamlfind: Package guestfs is already installed

or:

  ocamlfind: Conflict with file: /usr/lib64/ocaml/guestfs/mlguestfs.cmxa

Fix this by removing the old installed files before running
'ocamlfind install'.  An alternative would be to use
'ocamlfind uninstall', but this seems more direct.
2015-10-24 12:36:28 +01:00
Richard W.M. Jones
b1f11ef75b ocaml/examples: Fix use of event_callback in debug_logging.ml.
This fixes commit 8bbc5e73cb.
2015-10-07 14:16:00 +01:00
Richard W.M. Jones
a332e23dde ocaml/examples: Remove all programs in 'make clean'.
Previously the debug_logging program was not being deleted.
2015-10-07 14:15:05 +01:00
Richard W.M. Jones
585a7e1f3e ocaml: Add regression test for failure of implicit close. 2015-10-06 22:28:54 +01:00
Richard W.M. Jones
8bbc5e73cb ocaml: Allow Guestfs.t handle to be garbage collected.
** NB: This is an API break for OCaml programs using Guestfs.event_callback. **

Because of the way I implemented Guestfs.event_callback which had the
Guestfs.t handle as the first parameter, we had to store the (OCaml)
Guestfs.t handle in the C handle's private data area.  To do that, we
had to create a global root pointing to the handle.

This of course meant that the handle could not be garbage collected
(thanks Roman Kagan for spotting this).

This changes the API of Guestfs.event_callback so that a handle is no
longer passed.  The OCaml handle can now be garbage collected again.

For programs that need the Guestfs.t handle in the callback function
(which turns out to be *none* of the OCaml programs we have written),
you can do:

  g#set_event_callback (callback_fn g) [Guestfs.EVENT_FOO];

In this case, since the closure passed to Guestfs.set_event_callback
is still registered as a global root, that will capture a reference to
the handle, so the handle won't be able to be garbage collected until
you delete the callback.
2015-10-06 22:28:27 +01:00
Richard W.M. Jones
3858db9d58 ocaml: Use generational global roots.
These are considerably more efficient than ordinary global roots, but
with the caveat that the program is not allowed to modify them without
calling a special function.  We don't modify them, so this change is
safe.

This requires OCaml >= 3.11, but we have that on RHEL 6
(since we dropped support for RHEL 5).

See also:
http://caml.inria.fr/pub/ml-archives/caml-list/2008/03/c3bf86990088236ceeb9a0f0f4c35390.en.html
2015-10-06 15:53:31 +01:00
Richard W.M. Jones
677c721e85 Fix whitespace.
Because of previous automated commits, such as changing 'guestfs___'
-> 'guestfs_int_', several function calls no longer lined up with
their parameters, and some lines were too long.

The bulk of this commit was done using emacs batch mode and the
technique described here:

  http://www.cslab.pepperdine.edu/warford/BatchIndentationEmacs.html

The changes suggested by emacs were then reviewed by hand.
2015-10-05 14:28:33 +01:00
Richard W.M. Jones
4414de775a ocaml: Conditionally remove bindtests.* when doing 'make install'.
Commit f6a790b67d changed the Makefile
so it only builds the tests when you run 'make check'.

If you didn't run 'make check' then (in particular) bindtests won't be
built, and so when you install it cannot be removed.

The simple fix for this is to make the removal of bindtests.*
conditional.

This fixes commit f6a790b67d.
2015-10-01 14:17:52 +01:00
Richard W.M. Jones
b482593a07 ocaml: Use ocamlfind to run ocamldoc.
Using 'ocamlfind ocamldoc' is much faster than running 'ocamldoc'
directly, because ocamlfind will run the native code program
'ocamldoc.opt' if it is available.

This change approximately halves the time taken to compile the ocaml
bindings.
2015-09-30 13:33:39 +01:00
Richard W.M. Jones
f6a790b67d ocaml: Only build the tests when running 'make check'.
Make the tests 'check_DATA' so they only get built when running the
tests.  This saves a couple of seconds on the build time.
2015-09-30 13:33:39 +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
94ea635fb1 ocaml: Add handling for errno EINVAL. 2015-06-18 10:26:53 +01:00
Richard W.M. Jones
6297534091 ocaml: Add Guestfs.Errno.errno_EPERM. 2015-03-26 09:16:44 +00:00
Richard W.M. Jones
e6445e982a ocaml: Don't run check-valgrind on run-bindtests (bash script).
Fix the 'make check-valgrind' rule in the ocaml subdirectory so it
doesn't run '$VG run-bindtests', effectively running valgrind on bash.

Bash in Fedora Rawhide has added a new memory leak, resulting in a
failure, but we don't want to test bash anyway.
2015-03-02 17:46:06 +00:00
Richard W.M. Jones
bfbcc01403 Change guestfs___* to guestfs_int_*
libguestfs has used double and triple underscores in identifiers.
These aren't valid for global names in C++.

The first step is to replace all guestfs___* (3 underscores) with
guestfs_int_*.  We've used guestfs_int_* elsewhere already as a prefix
for internal identifiers.

This is an entirely mechanical change done using:
  git ls-files | xargs perl -pi.bak -e 's/guestfs___/guestfs_int_/g'

Reference: http://stackoverflow.com/a/228797
2015-02-14 18:46:04 +00:00
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Richard W.M. Jones
378ed3be5e ocaml: Convert debug_logging example from C to OCaml.
Continue gradual conversion of C examples to other languages.
2015-01-17 07:14:33 +00:00
Richard W.M. Jones
f421c7cae8 ocaml: Remove *.annot files when doing 'make clean'.
Commit fd70cdc3c5 passes the -annot flag
to the compiler, generating *.annot files (containing type information
used by emacs and IDEs).  Remove these files when doing 'make clean'.
2014-11-15 17:39:01 +00:00
Pino Toscano
a5426cce5f build: check for libintl, and use it
Look for libint/gettext and link to it; this properly detects whether
libint is part of libc.
2014-11-05 13:45:17 +01:00
Richard W.M. Jones
90dc8942bf ocaml: Factor out flags into configure script.
No change, just refactoring.
2014-10-23 15:41:49 +01:00
Hilko Bengen
7039d0e7f6 Generate *.cmx targets only if a native OCaml compiler exists 2014-09-14 21:21:25 +02:00
Richard W.M. Jones
a18c2aca14 Revert "Use ocamldep -all option."
This reverts commit a3881445ef.

See discussion on the mailing list:

https://www.redhat.com/archives/libguestfs/2014-September/msg00069.html
2014-09-14 18:46:49 +01:00
Richard W.M. Jones
a3881445ef Use ocamldep -all option.
In v2v, 'stringMap.ml' has no corresponding *.mli file.  ocamldep does
not generate a *.cmi dependency for such modules, and this can result
in parallel builds failing rarely because:

 (1) stringMap.ml is built (which has the side-effect of generating
     stringMap.cmi)

 (2) at the same time, types.mli is compiled.  types.mli depends on
     stringMap.cmi, but it is half way through being created by (1).

There is no dependency to serialize (1) and (2).

The resulting error is:

  File "types.mli", line 1:
  Error: Corrupted compiled interface
  stringMap.cmi

Using 'ocamldep -all' generates extra deps for the *.cmi files, and
otherwise appears to be safe, so use it.

There are currently a few upstream OCaml bugs with dependencies and
parallel builds:

http://caml.inria.fr/mantis/view.php?id=3190
http://caml.inria.fr/mantis/view.php?id=4991
http://caml.inria.fr/mantis/view.php?id=5000

It's not clear which of these apply here.
2014-09-01 22:24:14 +01:00
Richard W.M. Jones
fe9d3f7a90 ocaml: Ignore Warning 3: deprecated feature: String.* functions.
In OCaml 4.02, the 'string' type can be made immutable.  All String.*
functions that are concerned with creating or mutating strings now
give a warning like this:

  Warning 3: deprecated feature: String.unsafe_set

Disable this warning since we don't want to turn on immutable strings
yet.
2014-07-15 17:51:52 +01:00
Richard W.M. Jones
5d4e4e7eca ocaml: Add ESRCH to Guestfs.Errno module. 2014-03-31 14:21:45 +01:00
Richard W.M. Jones
26599da373 ocaml: Enable parallel builds.
Commit f75142c577 disabled parallel
builds in the ocaml subdirectory (which was the correct thing to do).
This made building the OCaml tests in particular very slow.  Therefore
fix things so that parallel builds can be used again.

See also discussion here about different approaches:

https://www.redhat.com/archives/libguestfs/2014-March/thread.html#00223

This reintroduces commit dce94f3e26.
2014-03-23 18:35:35 +00:00
Richard W.M. Jones
c4dc70f8c4 podwrapper: Remove =encoding from input files and add it back in podwrapper.
This changes podwrapper so that the input (POD) files should not
contain an =encoding directive.  However they must be UTF-8.
Podwrapper then adds the '=encoding utf8' directive back during final
generation.

This in particular avoids problems with nested =encoding directives in
fragments.  These break POD, and are undesirable anyway.
2014-03-20 13:47:19 +00:00
Richard W.M. Jones
0563405d2e ocaml: Add Guestfs.Errno submodule exposing useful raw errno numbers.
For use when calling G.last_errno.
2014-03-17 12:22:50 +00:00
Hilko Bengen
876983365a More fixes for situations where ocamlopt is not available
- run bindtests.opt only if available
- use ocamlc -custom
- Don't try to install native code if it hasn't been built (Thanks to Olaf Hering)
2014-03-04 00:06:07 +01:00
Hilko Bengen
f75142c577 Fix building on architectures where ocamlopt is not available 2014-02-28 14:01:25 +00:00
Richard W.M. Jones
d60e6a23a6 examples: Update various examples to use new disk-create API. 2014-01-28 21:02:11 +00:00
Richard W.M. Jones
6c971faecf Update copyright dates for 2014. 2014-01-02 16:53:34 +00:00