summaryrefslogtreecommitdiffstats
path: root/libvirt
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2007-11-14 12:08:49 +0000
committerRichard W.M. Jones <rjones@redhat.com>2007-11-14 12:08:49 +0000
commita09aae02dad075562f880fafaddd966f70342729 (patch)
tree2419d57165db80edd9d65f404d71360767bb17aa /libvirt
parentbbbb071cc29af9bb70a7e5657c96ff4eb55662dd (diff)
downloadvirt-top-a09aae02dad075562f880fafaddd966f70342729.tar.gz
virt-top-a09aae02dad075562f880fafaddd966f70342729.tar.xz
virt-top-a09aae02dad075562f880fafaddd966f70342729.zip
Added support for new API calls:
- virNodeGetFreeMemory - virNodeGetCellsFreeMemory Release of 0.3.3.1.
Diffstat (limited to 'libvirt')
-rw-r--r--libvirt/libvirt.ml2
-rw-r--r--libvirt/libvirt.mli16
-rw-r--r--libvirt/libvirt_c.c59
3 files changed, 77 insertions, 0 deletions
diff --git a/libvirt/libvirt.ml b/libvirt/libvirt.ml
index 2447f16..7b75eb8 100644
--- a/libvirt/libvirt.ml
+++ b/libvirt/libvirt.ml
@@ -63,6 +63,8 @@ struct
external num_of_defined_networks : [>`R] t -> int = "ocaml_libvirt_connect_num_of_defined_networks"
external list_defined_networks : [>`R] t -> int -> string array = "ocaml_libvirt_connect_list_defined_networks"
external get_node_info : [>`R] t -> node_info = "ocaml_libvirt_connect_get_node_info"
+ external node_get_free_memory : [> `R] t -> int64 = "ocaml_libvirt_connect_node_get_free_memory"
+ external node_get_cells_free_memory : [> `R] t -> int -> int -> int64 array = "ocaml_libvirt_connect_node_get_cells_free_memory"
(* See VIR_NODEINFO_MAXCPUS macro defined in <libvirt.h>. *)
let maxcpus_of_node_info { nodes = nodes; sockets = sockets;
diff --git a/libvirt/libvirt.mli b/libvirt/libvirt.mli
index ffe21fb..73bfcb5 100644
--- a/libvirt/libvirt.mli
+++ b/libvirt/libvirt.mli
@@ -105,6 +105,22 @@ sig
*)
val get_node_info : [>`R] t -> node_info
+ val node_get_free_memory : [> `R] t -> int64
+ (**
+ [node_get_free_memory conn]
+ returns the amount of free memory (not allocated to any guest)
+ in the machine.
+ *)
+
+ val node_get_cells_free_memory : [> `R] t -> int -> int -> int64 array
+ (**
+ [node_get_cells_free_memory conn start max]
+ returns the amount of free memory on each NUMA cell in kilobytes.
+ [start] is the first cell for which we return free memory.
+ [max] is the maximum number of cells for which we return free memory.
+ Returns an array of up to [max] entries in length.
+ *)
+
val maxcpus_of_node_info : node_info -> int
(** Calculate the total number of CPUs supported (but not necessarily
active) in the host.
diff --git a/libvirt/libvirt_c.c b/libvirt/libvirt_c.c
index 0fdcbac..9e2182b 100644
--- a/libvirt/libvirt_c.c
+++ b/libvirt/libvirt_c.c
@@ -116,6 +116,16 @@ extern int virDomainSetSchedulerParameters (virDomainPtr domain,
int nparams)
__attribute__((weak));
#endif
+#ifdef HAVE_VIRNODEGETFREEMEMORY
+extern unsigned long long virNodeGetFreeMemory (virConnectPtr conn)
+ __attribute__((weak));
+#endif
+#ifdef HAVE_VIRNODEGETCELLSFREEMEMORY
+extern int virNodeGetCellsFreeMemory (virConnectPtr conn,
+ unsigned long long *freeMems,
+ int startCell, int maxCells)
+ __attribute__((weak));
+#endif
#endif /* HAVE_WEAK_SYMBOLS */
/*----------------------------------------------------------------------*/
@@ -534,6 +544,55 @@ ocaml_libvirt_connect_get_node_info (value connv)
}
CAMLprim value
+ocaml_libvirt_connect_node_get_free_memory (value connv)
+{
+#ifdef HAVE_VIRNODEGETFREEMEMORY
+ CAMLparam1 (connv);
+ CAMLlocal1 (rv);
+ virConnectPtr conn = Connect_val (connv);
+ unsigned long long r;
+
+ WEAK_SYMBOL_CHECK (virNodeGetFreeMemory);
+ r = virNodeGetFreeMemory (conn);
+ CHECK_ERROR (r == 0, conn, "virNodeGetFreeMemory");
+
+ rv = caml_copy_int64 ((int64) r);
+ CAMLreturn (rv);
+#else
+ NOT_SUPPORTED ("virNodeGetFreeMemory");
+#endif
+}
+
+CAMLprim value
+ocaml_libvirt_connect_node_get_cells_free_memory (value connv,
+ value startv, value maxv)
+{
+#ifdef HAVE_VIRNODEGETCELLSFREEMEMORY
+ CAMLparam3 (connv, startv, maxv);
+ CAMLlocal2 (rv, iv);
+ virConnectPtr conn = Connect_val (connv);
+ int start = Int_val (startv);
+ int max = Int_val (maxv);
+ int r, i;
+ unsigned long long freemems[max];
+
+ WEAK_SYMBOL_CHECK (virNodeGetCellsFreeMemory);
+ r = virNodeGetCellsFreeMemory (conn, freemems, start, max);
+ CHECK_ERROR (r == -1, conn, "virNodeGetCellsFreeMemory");
+
+ rv = caml_alloc (r, 0);
+ for (i = 0; i < r; ++i) {
+ iv = caml_copy_int64 ((int64) freemems[i]);
+ Store_field (rv, i, iv);
+ }
+
+ CAMLreturn (rv);
+#else
+ NOT_SUPPORTED ("virNodeGetCellsFreeMemory");
+#endif
+}
+
+CAMLprim value
ocaml_libvirt_domain_create_linux (value connv, value xmlv)
{
CAMLparam2 (connv, xmlv);