Commit Graph

148 Commits

Author SHA1 Message Date
Pino Toscano
4fc85f27c4 ruby: 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
9fbdea695b ruby: Simplify and fix regression test.
This test failed on ppc64le with:

  Failure:
    </wrong argument type Fixnum \(expected Array\)/> was expected to be =~
    <"wrong argument type Integer (expected Array)">.

In addition the test generated a warning:

  tc_800_rhbz507346.rb:29: warning: ambiguous first argument; put parentheses or a space even after `/' operator

This commit fixes both of these and also makes it simpler and faster
by not bothering to launch the appliance.

Fixes commit 227b1eea90.
2017-03-01 15:07:00 +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
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
20aa0f6496 ruby: Split up large Ruby extension into smaller C files. 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
Richard W.M. Jones
4ed70d558a ruby: tests: Give each test class and method a unique name.
'tc_410_close_event.rb' was not being run.  You could prove this by
simply inserting "exit 1" into that test.

The reason is unclear, but by renaming every class and method in the
tests to be unique, this ensures the tests are run.
2016-06-10 14:25:38 +01:00
Pino Toscano
b1ae32416e ruby: tests: use more asserts instead of manual checks
Make more use of assert_equal/refute_equal instead of manually checking
values and raising errors.
2016-02-23 11:50:35 +01:00
Pino Toscano
3c2bc20250 Revert "ruby: Run tests one at a time, instead of in parallel."
It seems the default behaviour of rake is to run tests sequentially, and
not in parallel (there are separate gems to achieve that behaviour).

Hence just invoke "rake test" to run all the available tests at once.

This reverts commit 8f30c3c3f8.
2016-02-23 11:50:35 +01:00
Pino Toscano
f7765ea6e4 Start adding return values tests for bindings
Introduce a new kind of bindings tests, 090-retvalues, to check all the
possible return values in bindings; start implementing them for
scripting languages such as GObject introspection, Perl, PHP, Python,
and Ruby, reusing existing implementations where existing.
2016-02-15 18:32:07 +01: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
8554dbbc03 Remove multiple hacks that only apply to RHEL 5.
We don't support RHEL 5 upstream (see the 'oldlinux' branch for a
version that works with RHEL 5).  Therefore remove a bunch of hacks
that were only needed on RHEL 5.
2015-10-05 14:32:28 +01:00
Richard W.M. Jones
5c65b9108d ruby: Only rebuild rdoc when absolutely necessary.
Rebuilding the ruby documentation takes 51 seconds on my laptop, and
that's a significant fraction of the entire build.  Make sure we only
rebuild the documentation when necessary.
2015-03-28 18:08:21 +00:00
Margaret Lewicka
eaae0b614c macosx: ruby: Use correct dllib extension instead of assuming '.so'. 2015-02-06 09:53:45 +00:00
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Pino Toscano
2f5e9066db ruby: tests: convert from Test::Unit to MiniTest (RHBZ#1085029)
Convert the tests to the MiniTest test framework, but keeping the usage
of the old Test::Unit as fallback in case MiniTest is not available.
In the latter case, use a bit of "glue" to make the old API look like
the new API, so we can just rely on the newer MiniTest API.
2014-04-22 14:02:35 +02:00
Pino Toscano
fbae7f3e69 ruby: tests: isolate boilerplate in common file
Isolate in a common file all the standard boilerplate in tests, i.e. the
import of the test framework and the guestfs module (including the
import path hack needed for the latter).

Thanks to Vít Ondruch for the precious hints and suggestions.
2014-04-22 14:02:29 +02: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
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
Richard W.M. Jones
ee4ce2a029 ruby: Fix .new method (RHBZ#1046509).
The .new method was unintentionally broken in
commit 9466060201.

This fixes the .new method and allows it to be called with multiple
parameters, so you can use:

  Guestfs::Guestfs.new
  Guestfs::Guestfs.new()
  Guestfs::Guestfs.new(:close_on_exit => false)
  etc.

For backwards compatibility, Guestfs::create may still be used.

This commit also adds regression tests:

 - Use .new method in regular tests.  (Because this was not done
   before, we didn't catch the breakage.)

 - Test that ::create still works.

 - Test that args can be passed to .new method.
2013-12-27 13:22:20 +00:00
Richard W.M. Jones
480bd3a6d8 RHEL 6: ruby: Fix fallback to rake/rdoctask for old rake. 2013-12-27 13:22:20 +00:00
Richard W.M. Jones
92e1864913 events: Add a warning event and direct all warning messages through it.
This also causes warnings to be printed even in non-verbose mode,
which is useful.
2013-10-11 15:34:23 +01:00
Richard W.M. Jones
14fabcd88e tests: Use new guestfs_add_drive_scratch API where possible in tests.
Replaces code such as:

  fd = open "test1.img"
  ftruncate fd, size
  close fd
  g.add_drive "test1.img"

with the shorter and simpler:

  g.add_drive_scratch size
2013-07-20 16:31:42 +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
3c43019f8d ruby: Standardize test names and numbering. 2013-04-30 17:47:11 +01:00
Richard W.M. Jones
2ea9d82a23 ruby: Fix optargs test. 2013-04-25 20:10:34 +01:00
Richard W.M. Jones
a1e51676fd Remove many uses of $(builddir).
"$(builddir)" is always "."

Therefore most uses of $(builddir) are suspect and should be
removed or replaced with "."
2013-04-25 12:22:31 +01:00
Richard W.M. Jones
87c9ec881c ruby: Support 'make INSTALLDIRS=vendor install' for Ruby as well as Perl.
As with Perl, you can now set INSTALLDIRS to control where Ruby places
its files (ie. in the site dir, which is the default, or in the vendor
dir).

The difference in file layout between 'make install' and
'make INSTALLDIRS=vendor install' is shown below (for Fedora 18).

--- /tmp/site	2013-03-14 12:14:35.740015694 +0000
+++ /tmp/vendor	2013-03-14 12:14:13.668093944 +0000
@@ -119,21 +119,20 @@
 ./usr/lib64/ocaml/guestfs/mlguestfs.cmxa
 ./usr/lib64/ocaml/stublibs/dllmlguestfs.so
 ./usr/lib64/ocaml/stublibs/dllmlguestfs.so.owner
-./usr/lib64/perl5/auto/Sys/Guestfs/Guestfs.bs
-./usr/lib64/perl5/auto/Sys/Guestfs/Guestfs.so
-./usr/lib64/perl5/auto/Sys/Guestfs/.packlist
 ./usr/lib64/perl5/perllocal.pod
-./usr/lib64/perl5/Sys/bindtests.pl
-./usr/lib64/perl5/Sys/Guestfs/Lib.pm
-./usr/lib64/perl5/Sys/Guestfs.pm
+./usr/lib64/perl5/vendor_perl/auto/Sys/Guestfs/Guestfs.bs
+./usr/lib64/perl5/vendor_perl/auto/Sys/Guestfs/Guestfs.so
+./usr/lib64/perl5/vendor_perl/auto/Sys/Guestfs/.packlist
+./usr/lib64/perl5/vendor_perl/Sys/bindtests.pl
+./usr/lib64/perl5/vendor_perl/Sys/Guestfs/Lib.pm
+./usr/lib64/perl5/vendor_perl/Sys/Guestfs.pm
 ./usr/lib64/php/modules/guestfs_php.so
 ./usr/lib64/pkgconfig/libguestfs-gobject-1.0.pc
 ./usr/lib64/pkgconfig/libguestfs.pc
 ./usr/lib64/python2.7/site-packages/guestfs.py
 ./usr/lib64/python2.7/site-packages/libguestfsmod.la
 ./usr/lib64/python2.7/site-packages/libguestfsmod.so
-./usr/local/lib64/ruby/site_ruby/_guestfs.so
-./usr/local/share/ruby/site_ruby/guestfs.rb
+./usr/lib64/ruby/vendor_ruby/_guestfs.so
 ./usr/sbin/libguestfs-make-fixed-appliance
 ./usr/share/doc/libguestfs/example-debian-netinst-cd.xml
 ./usr/share/doc/libguestfs/example-debian.xml
@@ -406,3 +405,4 @@
 ./usr/share/man/uk/man3/guestfs-perl.3
 ./usr/share/man/uk/man3/guestfs-python.3
 ./usr/share/man/uk/man3/guestfs-ruby.3
+./usr/share/ruby/vendor_ruby/guestfs.rb

For prompting me to fix this, thanks: Hilko Bengen.
2013-03-14 12:19:22 +00:00
Hilko Bengen
0ee24ccf8a Move Ruby-related checks from autoconf to extconf.rb; add extra check for rb_alloc_func_t
Ruby ships its own config.h which may or may not define the same
relevant constants as our autoconf-generated config.h. Instead of
trying to specify the exact path to the wanted header file we may just
as well simply use Ruby's autoconf-inspired checks and macros.
2013-03-08 12:47:24 +00:00
Hilko Bengen
0a50e64435 out-of-tree build: don't distribute extconf.rb.in template, use generated exconf.rb
Apparently, the file will only be autogenerated in $(builddir) if it
is not already present in $(srcdir).
2013-03-07 21:14:11 +00:00
Richard W.M. Jones
70514c7f7e ruby: Add binding for guestfs_event_to_string. 2013-02-19 13:41:58 +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
Richard W.M. Jones
a0e9d310d1 ruby: Use updated package names, but allow fallback to the old names (RHBZ#894545).
Thanks Dominic Cleal.
2013-01-16 14:33:49 +00:00
Richard W.M. Jones
448a02373d ruby: Enable C compiler warnings.
This has the desirable side effect that the correct CFLAGS get passed
to the C compiler when building the Ruby extension.
2012-12-15 19:42:02 +00:00
Richard W.M. Jones
ff8bfd3e92 Add Lua bindings.
These are relatively complete, although only lightly tested.  Missing:

 - events
 - last_errno
 - user_cancel
2012-11-17 20:02:42 +00:00
Richard W.M. Jones
2cac8d490e syntax: Remove trailing whitespace.
Found by 'make syntax-check'.
2012-09-15 13:36:02 +01: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
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
Richard W.M. Jones
ffbf1475f7 New API: guestfs_shutdown: Cleanly shutdown the backend.
The new API splits orderly close into a two-step process:

  if (guestfs_shutdown (g) == -1) {
    /* handle the error, eg. qemu error */
  }
  guestfs_close (g);

Note that the explicit shutdown step is only necessary in the case
where you have made changes to the disk image and want to handle write
errors.  Read the documentation for further information.

This change also:

 - deprecates guestfs_kill_subprocess

 - turns guestfs_kill_subprocess into the same as guestfs_shutdown

 - changes guestfish and other tools to call shutdown + close
   where necessary (not for read-only tools)

 - updates documentation

 - updates examples
2012-07-03 21:27:29 +01:00
Richard W.M. Jones
27ebf517fa perl, python, ruby: Fix comments on call to close method.
Make the comments consistent.

Also make the Perl example call $g->close explicitly so it is
consistent with the other examples.
2012-07-03 14:45:42 +01:00