Commit Graph

39 Commits

Author SHA1 Message Date
Richard W.M. Jones
cd00157efc ocaml: Generate ocamldoc.
Also includes improvements to the OCaml documentation.
2011-07-17 11:23:47 +01:00
Richard W.M. Jones
7e51cc94dd New event API - OCaml bindings (RHBZ#664558).
The functions set_progress_callback and clear_progress_callback have
been removed, and replaced with a complete mechanism for setting and
deleting general-purpose events.
2011-03-15 12:16:50 +00:00
Richard W.M. Jones
13af3835cd ocaml: Combine tests together to reduce number of launches.
Combine launch, lvcreate and readdir tests together into a
single 'basic' test, so that we don't launch the appliance
so often when testing in this subdirectory.
2010-11-30 13:56:33 +00:00
Richard W.M. Jones
f6c4026f85 build: xml-light is no longer required (thanks Maxim Koltsov).
At some point we removed the last thing that required
xml-light, but were still testing for it at various places
in the build.  This removes all traces.
2010-11-11 18:03:12 +00:00
Richard W.M. Jones
14490c3e1a generator: Optional arguments, add-drive-opts (RHBZ#642934,CVE-2010-3851).
This large commit changes the generator so that optional arguments
can be supported for functions.

The model for arguments (known as the "style") is changed from
(ret, args) to (ret, args, optargs) where optargs is a more limited
list of arguments.

One function has been added which takes optional arguments, it is
"add-drive-opts", modelled as:

  (RErr, [String "filename"], #required
         [Bool "readonly"; String "format"; String "iface"]) #optional

Note that this function is processed in the library (does not go over
the RPC protocol to the daemon).  This has allowed us to simplify
the current implementation by omitting changes related to RPC or the
daemon, although we plan to add these at some point in the future.

From C this function can be called in 3 different ways as in these
examples:

  guestfs_add_drive_opts (g, filename,
                          GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,
			  GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
                          -1);

(the argument(s) between 'filename' and '-1' are the optional ones).

  guestfs_add_drive_opts_va (g, filename, args);

where 'args' is a va_list.  This works like the first version.

  struct guestfs_add_drive_opts_argv optargs = {
    .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK,
    .readonly = 1,
  }
  guestfs_add_drive_opts_argv (g, filename, &optargs);

This last form lets you construct lists of optional arguments, and
is used by guestfish and the language bindings.

In guestfish optional arguments are used like this:

  add-drive-opts filename readonly:true

In OCaml these are mapped naturally to OCaml optional arguments, eg:

  g#add_drive_opts ~readonly:true filename;

In Perl these are mapped to extra arguments, eg:

  $g->add_drive_opts ($filename, readonly => 1);

In Python these are mapped to optional arguments, eg:

  g.add_drive_opts ("file", readonly = 1, format = "qcow2")

In Ruby these are mapped to a final hash argument, eg:

  g.add_drive_opts("file", {})
  g.add_drive_opts("file", :readonly => 1)
  g.add_drive_opts("file", :readonly => 1, :iface => "virtio")

In PHP these are mapped to extra parameters.  This is not quite
accurate since you cannot omit arbitrary optional parameters, but
there's not much than can be done within the limitations of PHP
as a language.

Unimplemented in: Haskell, C#, Java.
2010-10-22 17:45:00 +01:00
Richard Jones
d1485e02f5 ocaml: Add test for progress notification callbacks. 2010-09-01 17:12:15 +01:00
Richard Jones
ad373a4d6c Remove old ocaml-inspector code.
Not used by anyone, didn't work well, and replaced now by the
C inspection APIs.
2010-08-17 14:09:26 +01:00
Richard Jones
1079f74704 ocaml: Fix thread safety of strings in bindings (RHBZ#604691).
There's a thread safety issue with the current OCaml bindings which
is well explained in the bug report:

https://bugzilla.redhat.com/show_bug.cgi?id=604691

This commit fixes the safety issue by copying strings temporarily
before releasing the thread lock.  Updated code looks like this:

  char *filename = guestfs_safe_strdup (g, String_val (filenamev));
  int r;

  caml_enter_blocking_section ();
  r = guestfs_add_drive_ro (g, filename);
  caml_leave_blocking_section ();
  free (filename);
  if (r == -1)
    ocaml_guestfs_raise_error (g, "add_drive_ro");

Also included is a regression test.
2010-06-16 15:32:20 +01:00
Richard Jones
2e2eb15df0 Remove separate inspector_generator.ml, combine this with generator.ml.
This commit combines the previously separate "inspector_generator.ml"
program which generated bindings for virt-inspector.

Having two separate programs caused no end of troubles for developers,
so we now combine them into a single program.

NOTE: OCaml xml-light is now *required* in order to rebuild the
generated code.
2009-12-31 11:20:56 +00:00
Matthew Booth
c477e2fb78 build: Fix inter-directory dependencies
This change adds an explicit dependency on generator.ml for every file it
generates, except java files. Java is left for another time because it's
considerably trickier.

It also adds a build rule for src/libguestfs.la so it can be rebuilt as required
from other directories.

It does this by creating a top level make file, subdir-rules.mk, which can be
included from sub-directories. sub-directories need to define 'generator_built'
to include local files which are built by generator.ml, and they will be updated
automatically.

This fixes parallel make, and will automatically re-create generated files when
make is run from any directory.

It also fixes the problem which efad4f53 was targetting. Specifically,
src/guestfs_protocol.(c|h) had an erroneous dependency on stamp-generator, and
therefore generator.ml, despite not being directly created by it. This caused
them to be recreated every time generator.ml ran rather than only when
src/guestfs_protocol.x was updated, which cascaded into a daemon and therefore
appliance update.

This patch also changes the contents of the distribution tarball by including
files created by rpcgen.
2009-11-19 16:40:22 +00:00
Richard W.M. Jones
c0465ca3ae ocaml: Sort the dependencies so they are stable between machines. 2009-11-06 12:33:27 +00:00
Richard Jones
d37f697953 inspector: Generate language bindings for OCaml.
This commit adds a generic mechanism for deriving language bindings
for virt-inspector, and implements one concrete binding, for OCaml.

The bindings are generated from the RELAX NG schema (virt-inspector.rng)
which is supposed to be a correct and always up to date description
of the XML that the virt-inspector program can generate.

From the RNG we generate a set of types to describe the output of
virt-inspector for the language, plus an XML parser, plus some
glue code to actually run an external instance of virt-inspector
and parse the resulting XML.

At runtime, an external 'virt-inspector --xml <name>' command runs
and the XML is parsed into language-specific structures.

This has been tested on the four example files (inspector/example?.xml)

The only particular difficulty about the OCaml binding is the use of
Obj.magic, which is naughty but works because of the isomorphism
between the representation of tuples and records in OCaml.  This
seems to cause no problems in my test program.  Apart from this, the
OCaml binding is straightforward and could be adapted easily for any
other languages that want type-safe virt-inspector bindings.

It's important to keep virt-inspector.rng up to date with changes
to virt-inspector's XML output format.
2009-10-13 17:53:20 +01:00
Jim Meyering
c6b8db6493 build: avoid parallel ocaml/... build failure
A parallel build could fail due to the use in ocaml/examples
of ocaml/guestfs.cmi before it was built.
* Makefile.am (SUBDIRS): Add both ocaml and ocaml/examples,
to ensure they're built in this order, and not in parallel.
* ocaml/Makefile.am (SUBDIRS): Don't define.
2009-10-05 14:16:46 +02:00
Jim Meyering
e933691fd1 build: enable gcc warnings in capitests/ and ocaml/
* capitests/Makefile.am: Use $(WARN_CFLAGS) and $(WERROR_CFLAGS).
* ocaml/Makefile.am:: Likewise.
2009-08-27 13:23:52 +02:00
Jim Meyering
dc3d0e3b8e build: don't emit trailing blanks, remove generated file
* ocaml/Makefile.am (.depend): Don't redirect directly to $@.
Filter out trailing blanks.
* ocaml/.depend: Regenerate.
2009-08-04 14:26:28 +02:00
Jim Meyering
d39310d108 build: add -I option to get config.h.
* ocaml/Makefile.am (AM_CPPFLAGS): Define.
(guestfs_c.o, guestfs_c_actions.o): Use it.
2009-08-03 15:14:30 +02:00
Richard Jones
2d5b0e7599 ocaml: Rebuild the tests from source if the main library changes. 2009-07-29 12:45:11 +01:00
Richard Jones
4c54721ad4 Fix non-srcdir builds: further fixes to OCaml build rules. 2009-07-17 09:36:28 +01:00
Richard Jones
0c4ec8c09a Fix non-srcdir builds: fix OCaml build rules. 2009-07-16 19:27:16 +01:00
Richard Jones
fd6fecea05 Miscellaneous fixes for non-srcdir builds. 2009-07-16 17:15:40 +01:00
Matthew Booth
349814e9d9 Make it possible to build in a separate directory
This patch allows you to do:
mkdir build
cd build
../configure ...
make

This will output all generated files to the build directory. Given that
autogen automatically runs configure, you can also do:

BUILDDIR=./build ./autogen.sh

which will do the right thing.

Also:

* Fix a dependency bug which means that guestfs_protocol.h
  isn't automatically rebuilt.
* Re-running autogen.sh with no arguments won't blow away your previous
  configure arguments.
2009-07-03 16:16:51 +01:00
Richard W.M. Jones
5186251f8f Add 'readdir' call.
This adds a readdir call (mostly intended for programs).  The
return value is a list of guestfs_dirent structures.

This adds the new types 'struct guestfs_dirent' and
'struct guestfs_dirent_list', along with all the code to
return these in the different language bindings.

Also includes additional tests for OCaml and Perl bindings
to test this.
2009-07-02 10:11:55 +01:00
Richard Jones
76711b7e91 No parallel make in ocaml/ directory (RHBZ#502309). 2009-06-02 15:50:50 +01:00
Richard W.M. Jones
babc0846cc Add tests for bindings parameters, fix several broken bindings. 2009-05-28 20:15:51 +01:00
Richard W.M. Jones
a1e8cdf2a2 Move the appliance and build scripts into new appliance/ subdirectory. 2009-05-28 13:00:31 +01:00
Richard Jones
6b66862068 abs_top_builddir doesn't exist in old RHEL 5 automake, use top_builddir instead. 2009-05-27 16:12:52 +01:00
Richard Jones
c419731e3a Add 'make valgrind' target to run tests under valgrind. 2009-05-09 13:40:31 +01:00
Jim Meyering
41b959fd9b build: don't tell "make clean" to remove my '~' backup files
Hi Rich,

automake's policy on what to remove via "make clean" is reasonable:
if running build rules creates it, then "make clean" can and should remove it.
However, even if build rules happen
to create backup files, please remove only the specific ones
they can create, not all of the ones in a directory.  Just in case
someone relies on those and expect them to hang around...

>From 1e8be391ac17b4ddcf9671e8413d2660844e6993 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Thu, 30 Apr 2009 15:47:52 +0200
Subject: [PATCH] build: don't tell "make clean" to remove my '~' backup files

* Makefile.am (CLEANFILES): Don't remove '~' backup files.
* daemon/Makefile.am: Ditto.
* examples/Makefile.am: Ditto.
* fish/Makefile.am: Ditto.
* images/Makefile.am: Ditto.
* inspector/Makefile.am: Ditto.
* java/Makefile.am: Ditto.
* ocaml/Makefile.am: Ditto.
* ocaml/examples/Makefile.am: Ditto.
* perl/Makefile.am: Ditto.
* python/Makefile.am: Ditto.
* ruby/Makefile.am: Ditto.
* src/Makefile.am: Ditto.
2009-04-30 16:13:06 +01:00
Richard Jones
f286a81cab Missing dependency. 2009-04-13 19:40:50 +01:00
Richard Jones
adcf5dc6aa Extra CLEANFILES. 2009-04-13 19:15:12 +01:00
Richard Jones
70c2ffc396 Additional test programs for Perl, Python, OCaml bindings. 2009-04-13 19:10:10 +01:00
Richard Jones
b6722e6313 OCaml bindings build using the installed, not built, library. 2009-04-13 10:27:20 +01:00
Richard Jones
d19ceb226c Remove *~ files when doing 'make clean'. 2009-04-09 19:47:22 +01:00
Richard Jones
bf26360e5e Added OCaml examples. 2009-04-08 23:06:51 +01:00
Richard Jones
13339826ea OCaml bindings compile. 2009-04-08 22:52:11 +01:00
Richard Jones
b5ff6816fa Version 0.5: Numerous small fixes to make rpmbuild work again. 2009-04-08 17:19:09 +01:00
Richard Jones
5828e17afd Need to distribute OCaml bits even if OCaml not found. 2009-04-08 13:44:46 +01:00
Richard Jones
4144e2106c Outline OCaml bindings. 2009-04-07 16:52:25 +01:00
Richard Jones
acf9000252 Added framework for the language bindings. 2009-04-07 13:08:50 +01:00