57 Commits

Author SHA1 Message Date
Richard W.M. Jones
75abec1f70 include: Move lib/guestfs.h to include/guestfs.h
This brings libguestfs into line with other projects which have a
separate include/ directory for the public header.

It's also the case that <guestfs.h> has never particularly belonged in
the lib/ subdirectory.  Some tools add -Ilib/ but they only need
<guestfs.h> and not any other headers from that directory, and
separating out the public header allows us to clean those up.  This is
certainly the case for examples, and some language bindings and some
tests.

In future I'm hopeful we can use this as the basis to tease out other
dependencies, as a prelude to separating them out from the repo.
2020-09-21 18:38:28 +01:00
Sergei Golovan
987734fcca erlang: Port to libei for Erlang 23
Replace the use of liberl_interface, which is removed in Erlang 23,
by libei. The implementation uses the ei_decode_iodata() function
which has been introduces only for Erlang 23, so it doesnt work with
earlier Erlang versions.
2020-06-04 13:49:35 +01:00
Richard W.M. Jones
0e17236d7d Update copyright dates to 2020. 2020-03-06 19:32:32 +00:00
Richard W.M. Jones
7050f4a6a6 erlang: Avoid deprecation warnings.
According to the Erlang website:

  The old legacy erl_interface library (functions with prefix erl_) is
  deprecated as of OTP 22, and will be removed in OTP 23. This does
  not apply to the ei library. Reasonably new gcc compilers will issue
  deprecation warnings. In order to disable these warnings, define the
  macro EI_NO_DEPR_WARN.

That's a shame and probably means we will have to drop the Erlang
bindings soon unless someone ports them to this new API (stable APIs
FTW people!).  In the meantime add the flag to prevent warn-errors
about deprecation.
2019-09-20 10:34:45 +01:00
Richard W.M. Jones
05d4fcb64d Update copyright dates for 2019.
This command run over the source:

perl -pi.bak -e 's/(20[01][0-9])-2018/$1-2019/g' `git ls-files`
2019-01-08 11:58:30 +00:00
Richard W.M. Jones
212762c593 Update copyright dates for 2018.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2017/$1-2018/g' `git ls-files`
2018-01-04 15:30:10 +00:00
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
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
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
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
07c496c53c Use less stack.
GCC has two warnings related to large stack frames.  We were already
using the -Wframe-larger-than warning, but this reduces the threshold
from 10000 to 5000 bytes.

However that warning only covers the static part of frames (not
alloca).  So this change also enables -Wstack-usage=10000 which covers
both the static and dynamic usage (alloca and variable length arrays).

Multiple changes are made throughout the code to reduce frames to fit
within these new limits.

Note that stack allocation of large strings can be a security issue.
For example, we had code like:

 size_t len = strlen (fs->windows_systemroot) + 64;
 char software[len];
 snprintf (software, len, "%s/system32/config/software",
           fs->windows_systemroot);

where fs->windows_systemroot is guest controlled.  It's not clear what
the effects might be of allowing the guest to allocate potentially
very large stack frames, but at best it allows the guest to cause
libguestfs to segfault.  It turns out we are very lucky that
fs->windows_systemroot cannot be set arbitrarily large (see checks in
is_systemroot).

This commit changes those to large heap allocations instead.
2016-03-07 17:36:24 +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
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +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
ffffe71c16 build: Remove code coverage and code profiling options.
This reverts commit 5a2e320ec9.
2014-04-09 14:51:59 +01: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
6c971faecf Update copyright dates for 2014. 2014-01-02 16:53:34 +00:00
Richard W.M. Jones
4180abcc1f tests: Use unique or temporary names for temporary files.
Review every test(!) to ensure that it:

 - Doesn't use a generic name (eg. "test1.img", "test.out") for any
   temporary file it needs.

 - Does instead use a unique name or a temporary name (eg. a name like
   "name-of-the-test.img", or a scratch disk).

 - Does not use 'rm -f' to clean up its temporary files (so we can
   detect errors if the wrong temporary file is created or removed).

This allows tests to be run in parallel, so they don't stomp on each
other's temporary files.
2013-07-23 10:16:00 +01:00
Richard W.M. Jones
06f2c1ad70 golang: Add examples and guestfs-golang(3) man page. 2013-07-04 15:48:47 +01:00
Richard W.M. Jones
49bdaabc7d build: Add common-rules.mk, common rules for all Makefiles.
This file is mainly a central place to:

 - include localenv if it exists, and

 - define the RHEL 5 backwards compatibility macros, instead of
   spreading them over every other file.
2013-06-04 12:41:11 +01:00
Richard W.M. Jones
a787d2565f syntax-check: Use newline before EOF in these text files. 2013-05-24 14:20:51 +01:00
Richard W.M. Jones
1623f540b1 erlang: Make separated builds work correctly.
Set ERL_LIBS and also create a phony 'ebin' directory for the
guestfs.beam (library) so that the tests run against the local copy
not the installed version, and so that separated builds work.
2013-04-30 13:54:15 +01:00
Richard W.M. Jones
327403f3ac erlang: Add a CLEANFILES rule. 2013-04-30 13:54:15 +01:00
Richard W.M. Jones
e29a130d8f erlang: Use $(ERLANG_LIB_DIR) to get Erlang libdir.
Instead of previous custom hack which didn't work properly on Debian.

Thanks: Hilko Bengen.
2013-03-14 12:47:40 +00:00
Richard W.M. Jones
7ef461948e erlang: Use guestfs___free_string_list from libutils, instead of custom version. 2013-02-20 19:16:47 +00:00
Richard W.M. Jones
09c4f94c9d build: Separate out *_CPPFLAGS from *_CFLAGS.
This is pretty pointless.
2013-02-11 21:36:27 +00:00
Richard W.M. Jones
59b296fecc tools, tests: Use "guestfs-internal-frontend.h" header.
Instead of redefining STREQ, etc.
2013-02-08 16:15:25 +00:00
Richard W.M. Jones
0d18a8b407 Update copyright dates for 2013. 2013-02-02 13:56:19 +00:00
Matthew Booth
27b995c841 Make internal-only functions and structures private
Certain functions are intended to be internal only, but we currently
export them anyway. This change moves them into a separate section of
guestfs.h protected by a GUESTFS_PRIVATE variable. This change also
enables private structs, but doesn't implement any.

This change only affects the C api. Language bindings aren't affected,
but probably should be in the future.
2013-01-30 17:27:01 +00:00
Hilko Bengen
9637bddc33 erlang: fix bindtests for out-of-tree build 2013-01-18 07:01:07 +00:00
Richard W.M. Jones
82344085aa erlang: Add more tests.
Since I made lots of changes to the Erlang bindings (prompted by
Coverity), I wasn't confident that something didn't break because
there were no real tests before.
2012-12-10 13:21:06 +00:00
Richard W.M. Jones
bc05e91f0e ./run: Add Erlang support to run script. 2012-12-10 12:41:47 +00:00
Richard W.M. Jones
0c6bc2f42f erlang: Avoid unintentional sign extension (found by Coverity).
Comment from Coverity:

  libguestfs-1.19.66/erlang/erl-guestfs-proto.c:115: sign_extension:
  Suspicious implicit sign extension: "buf[0]" with type "unsigned char"
  (8 bits, unsigned) is promoted in "(buf[0] << 24) | (buf[1] << 16) |
  (buf[2] << 8) | buf[3]" to type "int" (32 bits, signed), then
  sign-extended to type "unsigned long" (64 bits, unsigned).  If
  "(buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]" is greater
  than 0x7FFFFFFF, the upper bits of the result will all be 1.
2012-12-08 16:42:38 +00:00
Richard W.M. Jones
5a2e320ec9 configure: Add --enable-code-profiling and --enable-code-coverage flags.
These configure flags enable code profiling (with gprof) and code
coverage (with gcov) respectively.

Although this is a nice idea, it's not currently very useful.

Libtool mangles filenames in such a way that gcov cannot locate its
datafiles.

Profiling is of dubious utility with libguestfs which is not CPU-bound
and relies extensively on running external programs (oprofile-like
system profiling that took into account libguestfs + qemu or
libguestfs + qemu + the appliance + filesystem tools *would* be
useful).

Also neither flag will help in capturing data from the appliance.
2012-12-04 14:11:14 +00:00
Richard W.M. Jones
e866ee7c79 erlang, lua: Fix links in man pages. 2012-11-19 18:16:08 +00:00
Richard W.M. Jones
2f97bf873b podwrapper: Add --license parameter, which is required.
This adds standard LICENSE and BUGS sections to all of the man pages
that are processed by podwrapper.

Modify all the calls to $(PODWRAPPER) to add the right --license
parameter according to the content.  Note that this relaxes the
license on some code example pages, making them effectively BSD-style
licensed.
2012-08-21 20:33:21 +01:00
Richard W.M. Jones
f1d98bbc79 man pages: Ensure consistent copyright/author sections, remove license
section.

Ensure each man page contains consistent COPYRIGHT and AUTHOR
sections.

Remove the LICENSE section.  We will add that back in podwrapper in a
later commit.
2012-08-21 20:16:29 +01:00
Richard W.M. Jones
d67e6ea75d Replace mount-options with mount where appropriate.
Since our minimum supported version is now 1.16 and mount was fixed in
1.13.16, it is now safe to replace mount-options + empty options with
mount wherever it occurs.
2012-08-18 22:08:29 +01:00
Richard W.M. Jones
f6de298d04 erlang: Add tests.
Add bindtests and general tests for Erlang.
2012-08-15 17:49:48 +01:00
Richard W.M. Jones
bd35b3c055 erlang: Fix 64 bit integers in parameters. 2012-08-15 17:49:48 +01:00
Richard W.M. Jones
863168467f examples: Use add_drive_opts function in examples.
In libguestfs 1.20, you will be able to use 'add_drive'
instead of 'add_drive_opts' (except in the C bindings).

However until libguestfs 1.20 is the minimum stable version
people will still be using old versions where you have to use
'add_drive_opts'.  This makes the examples confusing.

Therefore continue to use 'add_drive_opts' in the examples
for now.
2012-08-02 17:21:47 +01:00
Richard W.M. Jones
f2ea617e22 build: Change calls to podwrapper.sh to use $(PODWRAPPER).
This will allow us to easily change the location of this
script in future.
2012-07-16 18:56:57 +01:00
Richard W.M. Jones
7486fc6f43 generator: Rename 'add_drive_opts' API to 'add_drive'.
By using the once_had_no_optargs flag, this change is backwards
compatible for callers (except Haskell, PHP and GObject as discussed
in earlier commit).
2012-07-14 12:42:24 +01:00