122 Commits

Author SHA1 Message Date
Richard W.M. Jones
c37c8e770d daemon: Reimplement ‘findfs_uuid’ and ‘findfs_label’ APIs in OCaml.
This also reimplements the lv_canonical function in OCaml.  We cannot
call the original C function because it calls reply_with_perror which
would break the OCaml bindings.
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
4052f613d2 daemon: Reimplement ‘list_filesystems’ API in the daemon, in OCaml.
Move the list_filesystems API into the daemon, reimplementing it in
OCaml.  Since this API makes many other API calls, it runs a lot
faster in the daemon.
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
b48da89dd6 daemon: Reimplement ‘file_architecture’ API in OCaml.
The previously library-side ‘file_architecture’ API is reimplemented
in the daemon, in OCaml.

There are some significant differences compared to the C
implementation:

 - The C code used libmagic.  That is replaced by calling the ‘file’
   command (because that is simpler than using the library).

 - The C code had extra cases to deal with compressed files.  This is
   not necessary since the ‘file’ command supports the ‘-z’ option
   which transparently looks inside compressed content (this is a
   consequence of the change above).

This commit demonstrates a number of techniques which will be useful
for moving inspection code to the daemon:

 - Moving an API from the C library to the OCaml daemon.

 - Calling from one OCaml API inside the daemon to another (from
   ‘Filearch.file_architecture’ to ‘File.file’).  This can be done and
   is done with C daemon APIs but correct reply_with_error handling is
   more difficult in C.

 - Use of Str for regular expression matching within the appliance.
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
7a084269ef daemon: Add unit tests of the ‘Utils’ module. 2017-07-27 22:31:22 +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
f60f8c47cc lib: Move implementation of ‘hivex_value_utf8’ to new file ‘lib/hivex.c’.
Just a code movement, no change.
2017-07-14 14:35:37 +01:00
Richard W.M. Jones
09b14a6076 Version 1.37.17. 2017-07-10 22:06:45 +01:00
Richard W.M. Jones
707f5bcfe0 daemon: Link guestfsd with libutils.
After the previous refactoring, we are able to link the daemon to
common/utils, and also remove some of the "duplicate" functions that
the daemon carried ("duplicate" in quotes because they were often not
exact duplicates).

Also this removes the duplicate reimplementation of (most) cleanup
functions in the daemon, since those are provided by libutils now.

It also allows us in future (but not in this commit) to move utility
functions from the daemon into libutils.
2017-07-10 17:01:59 +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
8be72935dc mllib, v2v: Split out OCaml utils bindings ‘common/mlutils’.
Create a module ‘C_utils’ containing functions like ‘drive_name’ and
‘shell_unquote’ which come from the C utilities.

The new directory ‘common/mlutils’ also contains the ‘Unix_utils’
wrappers around POSIX functions missing from the OCaml stdlib.
2017-07-10 17:01:59 +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
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
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
989292c146 mllib: Move Xml (libxml2) OCaml bindings to common/mlxml.
The ‘Xml’ module is a self-contained library of bindings for libxml2,
with no other dependencies.

Move it to a separate ‘common/mlxml’ directory.

This is not pure refactoring.  For unclear reasons, the previous
version of ‘Xml.parse_file’ read the whole file into memory and then
called ‘xmlReadMemory’.  This was quite inefficient, and unnecessary
because we could use ‘xmlReadFile’ to read and parse the file
efficiently.  Changing the code to use ‘xmlReadFile’ also removes the
unnecessary dependency on ‘Common_utils.read_whole_file’.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
9254c8f152 mllib: Move Progress OCaml bindings to common/mlprogress.
The ‘Progress’ module is a self-contained library with the only
dependencies being:

 - the C ‘progress’ implementation

Move it to a separate ‘common/mlprogress’ directory.

This change is pure code refactoring.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
746a87cbf8 mllib: Move Visit OCaml bindings to common/mlvisit.
The ‘Visit’ module is a self-contained library with the only
dependencies being:

 - the C ‘visit’ implementation

 - the guestfs OCaml bindings

Move it to a separate ‘common/mlvisit’ directory.

This change is not entirely refactoring.  Two other fixes are made:

 - remove unsafe use of CLEANUP_FREE from a function which could
   raise an OCaml exception (cleanup handlers would not be called
   correctly if the exception is thrown)

 - don't link directly to common/visit/visit.c, but instead use
   the library (common/visit/libvisit.la)
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
613c6fb900 Version 1.37.13. 2017-05-08 14:08:12 +01:00
Matteo Cafasso
e7a0face42 New API: yara_scan
The yara_scan API parses the file generated by the daemon counterpart
function and returns the list of yara_detection structs to the user.

It writes the daemon's command output on a temporary file and parses it,
deserialising the XDR formatted yara_detection structs.

It returns to the caller the list of yara_detection structs generated by
the internal_yara_scan command.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2017-05-02 13:34:43 +01:00
Matteo Cafasso
27f175b717 New API: yara_load
The yara_load API allows to load a set of Yara rules contained within a
file on the host.

Rules can be in binary format, as when compiled with yarac command, or
in source code format. In the latter case, the rules will be first
compiled and then loaded.

Subsequent calls of the yara_load API will result in the discard of the
previously loaded rules.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2017-05-02 13:34:42 +01:00
Richard W.M. Jones
311eb4c7e1 Version 1.37.12. 2017-04-25 22:52:47 +01:00
Pino Toscano
5810e03023 p2v: move the license text to gui.c
It is used only for the about dialog, and this way it will be easier
to disable.
2017-03-30 16:29:45 +02:00
Richard W.M. Jones
00375a6b4a Version 1.37.7. 2017-03-24 14:58:32 +00:00
Richard W.M. Jones
b6adf66628 Version 1.37.3. 2017-03-17 15:22:42 +00:00
Richard W.M. Jones
b8817417b8 Version 1.37.2. 2017-03-13 18:11:28 +00:00
Richard W.M. Jones
0cd83760f8 Version 1.37.1. 2017-03-07 15:37:15 +00:00
Richard W.M. Jones
ad9e9c98b5 v2v: Rename Domainxml -> Libvirt_utils.
The name 'Domainxml' made no sense.
2017-02-24 09:05:30 +00:00
Richard W.M. Jones
4b6a482bc8 mllib: Combine small Unix library call bindings into Unix_utils module.
Concatenate six small modules containing Unix/POSIX library call
bindings into a single module called Unix_utils.

The previous modules and the library functions bound were:

 - Dev_t:   makedev(3), major(3), minor(3)
 - Exit:    _exit(2)
 - Fnmatch: fnmatch(3)
 - Fsync:   sync(2)
 - Mkdtemp: mkdtemp(3)
 - StatVFS: statvfs(2)
2017-02-22 14:55:12 +00:00
Richard W.M. Jones
462cc4a502 docs/C_SOURCE_FILES, po/POTFILES, po/POTFILES-ml: Update these files. 2017-02-15 15:37:21 +00:00
Cédric Bosdonnat
2fe2e17f7d Move xml and xpath_helpers OCAML code to mllib
To allow other pieces of code to process XML files easily, move the
xml.ml* and xpath_helpers.ml* from v2v to mllib.
2017-02-14 15:25:25 +00:00
Richard W.M. Jones
6ec23eeac0 Version 1.35.21. 2017-02-07 22:01:07 +00:00
Richard W.M. Jones
8ee97b8859 p2v: Move miniexpect library to common/miniexpect.
No change, just code motion.
2017-01-26 15:05:47 +00:00
Richard W.M. Jones
db48870cf3 df: Move framework for processing domains in parallel to common/parallel.
Just code motion.
2017-01-26 15:05:47 +00:00
Richard W.M. Jones
a8c5739fd2 fish: Move edit, progress, windows under common/
Three more pieces of common code are moved under the common/
subdirectory.  This is just code motion.

Note that windows.[ch] wasn't even being used by guestfish.  That code
was only used in other virt tools.
2017-01-26 15:05:47 +00:00
Richard W.M. Jones
a9199a46b1 fish: Move fishcommon library to common/options.
This is mostly code motion but:

(1) I had to remove the compile-time COMPILING_GUESTFISH and
COMPILING_VIRT_RESCUE macros and replace them with runtime constants
and checks.

(2) I moved the fish/config.c file into this library.
2017-01-26 15:05:47 +00:00
Richard W.M. Jones
779bc1de23 cat: Move visit library to new directory common/visit.
Just code motion.
2017-01-26 15:05:46 +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
c90baa812a p2v: gtk: Update docs/C_SOURCE_FILES.
Updates commit 17cc502d9b.
2017-01-25 12:30:25 +00:00
Richard W.M. Jones
dd519e8a8e lib: Move some appliance functions around.
Move some appliance functions out of src/appliance.c and src/launch.c
into separate files.

No functional change, just code movement.
2016-12-24 16:00:07 +00:00
Richard W.M. Jones
adb6a85bf9 Version 1.35.18. 2016-12-14 18:16:16 +00:00
Richard W.M. Jones
e73763de1f docs: Ignore ruby/ext/guestfs/extconf.h
Updates commit bd21993d77.
2016-10-25 22:30:30 +01:00
Richard W.M. Jones
67cc867da8 docs: Ignore php/extension/config.h.
Updates commit bd21993d77.
2016-10-25 21:59:19 +01:00
Richard W.M. Jones
4f3269ac23 docs: Ignore java/com_redhat_et_libguestfs_GuestFS.h
Updates commit bd21993d77.
2016-10-25 21:37:37 +01:00
Richard W.M. Jones
0875989384 docs: Ignore more generated headers.
Updates commit bd21993d77.
2016-10-25 21:12:56 +01:00
Richard W.M. Jones
959ed964b8 Version 1.35.11. 2016-10-25 20:49:21 +01:00
Richard W.M. Jones
f68388eec5 Version 1.35.10. 2016-10-25 20:02:59 +01:00
Richard W.M. Jones
bd21993d77 docs: Remove builder/index-parse.h from documented files.
Breaks things when building from clean.
2016-10-25 19:14:06 +01:00
Richard W.M. Jones
4d535c7038 docs: internal: Allow headers and structs to be documented.
This makes a number of small changes to how the internal documentation
is generated and what can be documented.

Header files are now permitted to contain internal documentation.
This works in the same wasy as .c files.

Also documentation can be added for structs as well as functions.

This commit also adds documentation to some header files and structs,
and fixes a few places which contained broken header documentation.
2016-10-25 13:38:01 +01:00
Richard W.M. Jones
1d5cd15e3a Version 1.35.9. 2016-10-20 18:27:02 +01:00