ocaml-libvirt.git
5 years agoAvoid VLAs with size depending on user input
Pino Toscano [Thu, 30 Aug 2018 10:13:41 +0000 (12:13 +0200)]
Avoid VLAs with size depending on user input

Do not use var-length arrays with sizes from user input (like
parameters), since they may grow the stack too much.

Instead, allocate the memory on the heap.

5 years agoWorkaround lack of constness in custom_operations::identifier
Pino Toscano [Thu, 30 Aug 2018 10:13:40 +0000 (12:13 +0200)]
Workaround lack of constness in custom_operations::identifier

Sadly the custom_operations struct of the OCaml C API uses char* for the
'identifier' member, even though it does not change it.

To avoid getting warnings when building with stricter CFLAGS, apply ugly
casts.

5 years agoAdd an helper CHECK_ERROR_CLEANUP macro
Pino Toscano [Thu, 30 Aug 2018 10:13:39 +0000 (12:13 +0200)]
Add an helper CHECK_ERROR_CLEANUP macro

Extend the existing CHECK_ERROR macro to allow some code to be executed
right before raising Virterror.  Rework CHECK_ERROR to use
CHECK_ERROR_CLEANUP.

5 years agoAdd Domain.get_xml_desc_flags
Pino Toscano [Thu, 30 Aug 2018 10:13:38 +0000 (12:13 +0200)]
Add Domain.get_xml_desc_flags

Much like Domain.get_xml_desc with the possibility to specify flags for
the XML description.  The function is marked with a [`W] phantom because
some of the flags (e.g. XmlSecure) require a read/write connection.

5 years agoSynchronize Virterror with libvirt 4.6.0
Pino Toscano [Thu, 30 Aug 2018 10:13:37 +0000 (12:13 +0200)]
Synchronize Virterror with libvirt 4.6.0

In particular, add all the various error codes, and error domains.
Also, add an older domain that was previously skipped.

5 years agoConnect: add auth/credential handling for connect
Pino Toscano [Thu, 30 Aug 2018 10:13:36 +0000 (12:13 +0200)]
Connect: add auth/credential handling for connect

Add OCaml versions of virConnectCredential & virConnectAuth structs,
using them to implement proper connect_auth & connect_auth_readonly.

This makes it possible to properly supply credentials when opening a
connection.

5 years agoAdd Val_opt_const & Val_const_ptr_t
Pino Toscano [Thu, 30 Aug 2018 10:13:35 +0000 (12:13 +0200)]
Add Val_opt_const & Val_const_ptr_t

Counterparts of Val_opt & Val_ptr_t, but with constness for the pointer.

6 years agoUse -safe-string and fix the library.
Richard W.M. Jones [Wed, 8 Nov 2017 16:52:58 +0000 (16:52 +0000)]
Use -safe-string and fix the library.

Note this changes the type of the cpumap from string to bytes,
since (by the design of the API) it must be mutated.

7 years agoChange binding of virConnectGetAllDomainStats to return dom UUID.
Richard W.M. Jones [Tue, 28 Mar 2017 12:52:51 +0000 (13:52 +0100)]
Change binding of virConnectGetAllDomainStats to return dom UUID.

The virDomainPtr object returned by this binding isn't a reliable
virDomainPtr object.  The only thing we can safely do with it is to
get its UUID.  Modify the API correspondingly.

Updates commit 380f1e05b244ae4750ca5101b5b5a182dcd0d1fd.

7 years agoexamples: Print more stats in the get_all_domain_stats.ml example.
Richard W.M. Jones [Tue, 28 Mar 2017 12:11:09 +0000 (13:11 +0100)]
examples: Print more stats in the get_all_domain_stats.ml example.

Updates commit 380f1e05b244ae4750ca5101b5b5a182dcd0d1fd.

7 years agoAdd a binding for virConnectGetAllDomainStats (RHBZ#1390171).
Richard W.M. Jones [Tue, 28 Mar 2017 09:08:06 +0000 (10:08 +0100)]
Add a binding for virConnectGetAllDomainStats (RHBZ#1390171).

7 years agoUpdate dependencies.
Richard W.M. Jones [Mon, 27 Mar 2017 13:13:47 +0000 (14:13 +0100)]
Update dependencies.

7 years agoUse -g -warn-error.
Richard W.M. Jones [Mon, 27 Mar 2017 13:12:50 +0000 (14:12 +0100)]
Use -g -warn-error.

Use -g for ocamlopt.  ocamlopt has supported generating DWARF
information for quite a long time.

Also use -warn-error with the same set of warnings as is used
by libguestfs.

Fix a warning in examples/get_cpu_stats.ml found by enabling
-warn-error.

8 years agoRemove unused 'not_supported' function.
Richard W.M. Jones [Fri, 5 Feb 2016 16:28:34 +0000 (16:28 +0000)]
Remove unused 'not_supported' function.

Found by compiling under GCC 6.  The warning was:

In file included from libvirt_c.c:2058:0:
libvirt_c_epilogue.c:89:1: error: 'not_supported' defined but not used [-Werror=unused-function]
 not_supported (const char *fn)
 ^~~~~~~~~~~~~

9 years agoDon't bother checking return from virInitialize.
Richard W.M. Jones [Tue, 17 Mar 2015 12:53:29 +0000 (12:53 +0000)]
Don't bother checking return from virInitialize.

The Perl bindings don't do this, and it seems that the call can never
fail, or if it does we don't care.

9 years agoSuppress errors to stderr and use thread-local virErrorPtr
Richard W.M. Jones [Tue, 17 Mar 2015 12:51:50 +0000 (12:51 +0000)]
Suppress errors to stderr and use thread-local virErrorPtr

This allows us to capture errors that happen during virConnectOpen,
without spewing error messages on stderr.

The patch is rather large, only because we don't need to pass the
virConnectPtr argument to CHECK_ERROR/_raise_virterror any longer.

9 years agoAdd a binding for virDomainCreateXML.
Richard W.M. Jones [Fri, 6 Mar 2015 15:35:46 +0000 (15:35 +0000)]
Add a binding for virDomainCreateXML.

This is more modern than the ancient virDomainCreateLinux API,
and crucially allows you to pass flags such as AUTODESTROY.

9 years agoUse C99 standard int64_t instead of OCaml defined (and soon to go) int64.
Richard W.M. Jones [Sat, 30 Aug 2014 18:10:19 +0000 (19:10 +0100)]
Use C99 standard int64_t instead of OCaml defined (and soon to go) int64.

9 years agoKill broken NSIS support.
Richard W.M. Jones [Tue, 26 Aug 2014 14:38:10 +0000 (15:38 +0100)]
Kill broken NSIS support.

9 years agoVersion 0.6.1.4. 0.6.1.4
Richard W.M. Jones [Mon, 25 Aug 2014 19:48:02 +0000 (20:48 +0100)]
Version 0.6.1.4.

9 years agoUpdate MANIFEST.
Richard W.M. Jones [Mon, 25 Aug 2014 19:46:13 +0000 (20:46 +0100)]
Update MANIFEST.

9 years agoVersion 0.6.1.3. 0.6.1.3
Richard W.M. Jones [Mon, 25 Aug 2014 19:44:12 +0000 (20:44 +0100)]
Version 0.6.1.3.

10 years agoUpdate dependencies.
Richard W.M. Jones [Wed, 8 May 2013 11:31:26 +0000 (12:31 +0100)]
Update dependencies.

10 years agoAdd a simple example to show how to receive event callbacks
David Scott [Wed, 24 Apr 2013 10:39:06 +0000 (11:39 +0100)]
Add a simple example to show how to receive event callbacks

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
10 years agoAdd event callback implementation based on virConnectDomainEventRegisterAny
David Scott [Wed, 24 Apr 2013 10:39:05 +0000 (11:39 +0100)]
Add event callback implementation based on virConnectDomainEventRegisterAny

A client may register a callback as follows:

    E.register_default_impl ();

    let conn = C.connect_readonly ?name () in

    let id = E.register_any conn (E.Lifecycle (fun dom e ->
        printd dom "Lifecycle %s" (E.Lifecycle.to_string e)
    )) in

Internally this will:
  1. generate a unique int64 used to identify the specific callback
  2. add the callback to an OCaml hashtable based on the signature
     (there is a distinct hashtable per callback signature)
  3. call virConnectDomainEventRegisterAny which registers a
     generic C callback in the stubs (one distinct callback per
     signature) and supply the int64 as the "opaque" data

The client must enter the event loop with:

    while true do
        E.run_default_impl ()
    done

When an event is triggered, the C callback will upcall into an OCaml
function (having re-acquired the heap lock) supplying the int64 value.
The OCaml function can then find the right callback in the Hashtbl
and call it.

The client can deregister the callback with:

  E.deregister_any conn id;

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
10 years agoAdd binding for virConnectSetKeepAlive
David Scott [Wed, 24 Apr 2013 10:39:04 +0000 (11:39 +0100)]
Add binding for virConnectSetKeepAlive

This one is a 'one-off' but it ought to be possible to use the generator
to create the function (it has signature 'conn, int, int : int')

This function first appeared in libvirt version 0.9.8.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
10 years agoRemove backwards compatability logic to simplify the bindings
David Scott [Wed, 24 Apr 2013 10:39:03 +0000 (11:39 +0100)]
Remove backwards compatability logic to simplify the bindings

Rather than compile against old versions of libvirt and resort
to throwing 'not supported' exceptions at runtime, we instead
require all symbols and definitions to be available at compile-time
i.e. we require a much more recent libvirt.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
11 years agoFix typo in ocaml_libvirt_storage_vol_get_info
David Scott [Wed, 17 Apr 2013 10:23:00 +0000 (11:23 +0100)]
Fix typo in ocaml_libvirt_storage_vol_get_info

The info.capacity was being overwritten with the info.allocation.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
11 years agoUpdate dependencies.
Richard W.M. Jones [Wed, 6 Mar 2013 17:00:43 +0000 (17:00 +0000)]
Update dependencies.

11 years agoFunctions returning "unit" correspond to C fns which use -1 for failure
David Scott [Wed, 6 Mar 2013 16:18:05 +0000 (16:18 +0000)]
Functions returning "unit" correspond to C fns which use -1 for failure

This affects the following functions:
  virStoragePoolBuild
  virStoragePoolDelete
  virStorageVolDelete

Previously a call to virStorageVolDelete would succeed returning 0, which
was interpreted as false, causing us to raise an exception with
VIR_ERR_NONE.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
11 years agoVolume.delete takes a flags parameter
David Scott [Wed, 6 Mar 2013 16:18:04 +0000 (16:18 +0000)]
Volume.delete takes a flags parameter

This corrects a mismatch between the generated C stubs and the .ml
interface.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
11 years agoCorrect typos in the storage interface's phantom types
David Scott [Wed, 6 Mar 2013 16:18:03 +0000 (16:18 +0000)]
Correct typos in the storage interface's phantom types

A connection is either read/write (type rw = [`R|`W]) or read/only
(type ro = [`R]). A function which requires the ability to write
needs to take a parameter [> `W] rather than [`W] (which would
correspond to a write-only connection).

We can now use a read/write connection to call:
  Pool.set_autostart
  Volume.create_xml
  Volume.delete

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
11 years agoAdd contrib directory, and non-upstream patch to add Domain.get_cpu_stats_total.
Richard W.M. Jones [Fri, 12 Oct 2012 10:48:17 +0000 (11:48 +0100)]
Add contrib directory, and non-upstream patch to add Domain.get_cpu_stats_total.

This patch needs more thorough review.

11 years agoremove parameter nr_pcpus of Libvirt.Domain.get_cpu_stats
Hu Tao [Wed, 9 May 2012 08:48:30 +0000 (16:48 +0800)]
remove parameter nr_pcpus of Libvirt.Domain.get_cpu_stats

remove the value because we can get it from the libvirt API

12 years agoVersion 0.6.1.2. 0.6.1.2
Richard W.M. Jones [Fri, 23 Mar 2012 12:39:31 +0000 (12:39 +0000)]
Version 0.6.1.2.

12 years agoDomain.get_cpu_stats: get number of params correctly (thanks Eric Blake).
Richard W.M. Jones [Fri, 23 Mar 2012 12:38:25 +0000 (12:38 +0000)]
Domain.get_cpu_stats: get number of params correctly (thanks Eric Blake).

See:
https://www.redhat.com/archives/libvir-list/2012-March/msg00306.html

This fixes commit c96c3a119b44d3321dddc5e189dcba991aaff677.

12 years agoVersion 0.6.1.1. 0.6.1.1
Richard W.M. Jones [Mon, 5 Mar 2012 16:29:21 +0000 (16:29 +0000)]
Version 0.6.1.1.

12 years agoocaml-libvirt: add D.get_cpu_stats() API to ocaml-libvirt
Lai Jiangshan [Wed, 8 Feb 2012 08:59:45 +0000 (16:59 +0800)]
ocaml-libvirt: add D.get_cpu_stats() API to ocaml-libvirt

Changed from V3:
use new virDomainGetCPUStats() libvirt-API.
use C code to construct the typed_param list array

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
12 years agoRemove virConnectListAllDomains.
Richard W.M. Jones [Mon, 5 Mar 2012 16:19:14 +0000 (16:19 +0000)]
Remove virConnectListAllDomains.

This was never in a released libvirt.

12 years agoAdd header to Make.rules.in.
Richard W.M. Jones [Mon, 5 Mar 2012 16:15:56 +0000 (16:15 +0000)]
Add header to Make.rules.in.

12 years agoRemove obsolete: mlvirsh, gettext support, Windows installer.
Richard W.M. Jones [Mon, 5 Mar 2012 16:12:27 +0000 (16:12 +0000)]
Remove obsolete: mlvirsh, gettext support, Windows installer.

12 years agoRemove .hgignore.
Richard W.M. Jones [Mon, 5 Mar 2012 16:05:51 +0000 (16:05 +0000)]
Remove .hgignore.

12 years agoRemove jobs API.
Richard W.M. Jones [Mon, 5 Mar 2012 16:04:53 +0000 (16:04 +0000)]
Remove jobs API.

This was never in a released libvirt.

14 years agoAdd .gitignore file.
Richard Jones [Mon, 16 Nov 2009 13:47:02 +0000 (13:47 +0000)]
Add .gitignore file.

15 years agoCorrect to-do list.
Richard W.M. Jones [Tue, 10 Mar 2009 11:10:09 +0000 (11:10 +0000)]
Correct to-do list.

15 years agoVersion 0.6.1.0 for release.
Richard W.M. Jones [Tue, 10 Mar 2009 10:32:48 +0000 (10:32 +0000)]
Version 0.6.1.0 for release.

15 years agoCorrect mlvirsh for new read-write connection.
Richard W.M. Jones [Tue, 10 Mar 2009 10:32:33 +0000 (10:32 +0000)]
Correct mlvirsh for new read-write connection.

15 years agovirDomainBlockPeek and virDomainMemoryPeek need a read/write connection
Richard W.M. Jones [Tue, 10 Mar 2009 10:31:56 +0000 (10:31 +0000)]
virDomainBlockPeek and virDomainMemoryPeek need a read/write connection
(CVE-2008-5086) (found by David Lutterkort).

15 years agoD.get_id returns -1 for inactive domains instead of throwing an error.
Richard W.M. Jones [Wed, 3 Sep 2008 16:36:20 +0000 (17:36 +0100)]
D.get_id returns -1 for inactive domains instead of throwing an error.

15 years agoDon't duplicate unnecessary call to D.get_info.
Richard W.M. Jones [Wed, 3 Sep 2008 16:36:04 +0000 (17:36 +0100)]
Don't duplicate unnecessary call to D.get_info.

15 years agoImplement version 3 of virConnectListAllDomains.
Richard W.M. Jones [Wed, 3 Sep 2008 15:27:43 +0000 (16:27 +0100)]
Implement version 3 of virConnectListAllDomains.

15 years agoAdd support for virConnectListAllDomains call.
Richard W.M. Jones [Mon, 1 Sep 2008 14:54:45 +0000 (15:54 +0100)]
Add support for virConnectListAllDomains call.

15 years agoRevert previous change.
Richard W.M. Jones [Fri, 29 Aug 2008 16:39:44 +0000 (17:39 +0100)]
Revert previous change.

15 years agoUse CAMLreturn0 to avoid a warning.
Richard W.M. Jones [Fri, 29 Aug 2008 16:38:12 +0000 (17:38 +0100)]
Use CAMLreturn0 to avoid a warning.

15 years agoAllow destdir options to be passed to 'make install' (Guillaume Rousse).
Richard W.M. Jones [Thu, 14 Aug 2008 08:45:34 +0000 (09:45 +0100)]
Allow destdir options to be passed to 'make install' (Guillaume Rousse).

15 years agoSplit peek requests into maximum-sized chunks.
Richard W.M. Jones [Wed, 9 Jul 2008 19:55:26 +0000 (20:55 +0100)]
Split peek requests into maximum-sized chunks.

15 years agoAdd Domain.max_peek function to determine maximum size of
Richard W.M. Jones [Wed, 9 Jul 2008 19:55:15 +0000 (20:55 +0100)]
Add Domain.max_peek function to determine maximum size of
peek requests.

15 years agoDon't pass -destdir parameter to ocamlfind. Version 0.4.4.2.
Richard W.M. Jones [Wed, 9 Jul 2008 11:52:12 +0000 (12:52 +0100)]
Don't pass -destdir parameter to ocamlfind.  Version 0.4.4.2.

15 years agoVersion 0.4.4.1 for release.
Richard W.M. Jones [Mon, 7 Jul 2008 13:03:21 +0000 (14:03 +0100)]
Version 0.4.4.1 for release.

15 years agoChanged INRIA to Red Hat (for Debian)
Richard W.M. Jones [Mon, 7 Jul 2008 13:03:04 +0000 (14:03 +0100)]
Changed INRIA to Red Hat (for Debian)

15 years agoFiles missed by 'make distclean' (for Debian)
Richard W.M. Jones [Mon, 7 Jul 2008 11:19:37 +0000 (12:19 +0100)]
Files missed by 'make distclean' (for Debian)

15 years agoRemoved old ChangeLog file.
Richard W.M. Jones [Mon, 7 Jul 2008 10:37:04 +0000 (11:37 +0100)]
Removed old ChangeLog file.

15 years agoClarify the license again for Debian.
Richard W.M. Jones [Mon, 7 Jul 2008 10:30:20 +0000 (11:30 +0100)]
Clarify the license again for Debian.

15 years agoRevert previous commit.
Richard W.M. Jones [Mon, 7 Jul 2008 10:27:13 +0000 (11:27 +0100)]
Revert previous commit.

15 years agoReference the license from LGPL files (for Debian).
Richard W.M. Jones [Mon, 7 Jul 2008 09:57:00 +0000 (10:57 +0100)]
Reference the license from LGPL files (for Debian).

15 years agoClarify the license for Debian.
Richard W.M. Jones [Mon, 7 Jul 2008 09:32:32 +0000 (10:32 +0100)]
Clarify the license for Debian.

15 years agoSplit 'make install' into separate 'make install-opt' and 'make install-byte' (Sylvai...
Richard W.M. Jones [Fri, 4 Jul 2008 14:28:44 +0000 (15:28 +0100)]
Split 'make install' into separate 'make install-opt' and 'make install-byte' (Sylvain Le Gall, via Debian)

15 years agoRemove some old virt-top stuff.
Richard W.M. Jones [Tue, 10 Jun 2008 11:51:22 +0000 (12:51 +0100)]
Remove some old virt-top stuff.

15 years agoAuto-generate ChangeLog.
Richard W.M. Jones [Tue, 10 Jun 2008 11:50:55 +0000 (12:50 +0100)]
Auto-generate ChangeLog.

15 years agoDeprecate ChangeLog file.
Richard W.M. Jones [Tue, 10 Jun 2008 11:49:08 +0000 (12:49 +0100)]
Deprecate ChangeLog file.

15 years agoVersion 0.4.2.4 for release.
Richard W.M. Jones [Tue, 10 Jun 2008 11:24:54 +0000 (12:24 +0100)]
Version 0.4.2.4 for release.

15 years agoMissing dependencies.
Richard W.M. Jones [Tue, 10 Jun 2008 11:24:39 +0000 (12:24 +0100)]
Missing dependencies.

15 years agoList* functions throw exceptions if maxids = 0, so bypass this case.
Richard W.M. Jones [Tue, 10 Jun 2008 11:24:22 +0000 (12:24 +0100)]
List* functions throw exceptions if maxids = 0, so bypass this case.

15 years agoVersion 0.4.2.3.
Richard W.M. Jones [Mon, 9 Jun 2008 12:25:33 +0000 (13:25 +0100)]
Version 0.4.2.3.

15 years agoFix some bugs in the implementation of virDomainMemoryPeek
Richard W.M. Jones [Thu, 5 Jun 2008 21:37:55 +0000 (22:37 +0100)]
Fix some bugs in the implementation of virDomainMemoryPeek

15 years agoUpdated MANIFEST
Richard W.M. Jones [Thu, 5 Jun 2008 19:25:56 +0000 (20:25 +0100)]
Updated MANIFEST

15 years agoAdd domblkpeek, dommempeek commands and
Richard W.M. Jones [Thu, 5 Jun 2008 18:46:12 +0000 (19:46 +0100)]
Add domblkpeek, dommempeek commands and
add per-argument help.

15 years agoAdd support for virDomainBlockPeek, virDomainMemoryPeek and
Richard W.M. Jones [Thu, 5 Jun 2008 18:45:52 +0000 (19:45 +0100)]
Add support for virDomainBlockPeek, virDomainMemoryPeek and
remove the deprecated conn/dom/net fields in virterror.

15 years agoRemove Windows cruft from when it was lacking ocamlfind.
Richard W.M. Jones [Thu, 5 Jun 2008 18:45:03 +0000 (19:45 +0100)]
Remove Windows cruft from when it was lacking ocamlfind.

15 years agoBrazilian Portuguese translation by Herli Joaquim de Menezes and revised by Igor...
Richard W.M. Jones [Tue, 27 May 2008 11:34:41 +0000 (12:34 +0100)]
Brazilian Portuguese translation by Herli Joaquim de Menezes and revised by Igor Pires Soares.

16 years agoJust the OCaml bindings (C library).
Richard W.M. Jones [Wed, 16 Apr 2008 13:24:40 +0000 (14:24 +0100)]
Just the OCaml bindings (C library).

16 years agoInitial import from old virt-top repository.
Richard W.M. Jones [Wed, 16 Apr 2008 12:43:00 +0000 (13:43 +0100)]
Initial import from old virt-top repository.