[virt-tools-list] [PATCH 1/2] add parameter flags to D.get_cpu_stats()

Hu Tao hutao at cn.fujitsu.com
Thu Apr 26 08:09:05 UTC 2012


---
 examples/get_cpu_stats.ml   |    2 +-
 libvirt/libvirt.ml          |    2 +-
 libvirt/libvirt.mli         |    2 +-
 libvirt/libvirt_c_oneoffs.c |    9 +++++----
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/examples/get_cpu_stats.ml b/examples/get_cpu_stats.ml
index 79d5c3c..3541720 100644
--- a/examples/get_cpu_stats.ml
+++ b/examples/get_cpu_stats.ml
@@ -25,7 +25,7 @@ let () =
 
     let stats =
       let dom = D.lookup_by_name conn domname in
-      D.get_cpu_stats dom nr_pcpus in
+      D.get_cpu_stats dom nr_pcpus 0 in
 
     Array.iteri (
       fun n params ->
diff --git a/libvirt/libvirt.ml b/libvirt/libvirt.ml
index 53c5bb4..7a32071 100644
--- a/libvirt/libvirt.ml
+++ b/libvirt/libvirt.ml
@@ -417,7 +417,7 @@ struct
   external set_vcpus : [>`W] t -> int -> unit = "ocaml_libvirt_domain_set_vcpus"
   external pin_vcpu : [>`W] t -> int -> string -> unit = "ocaml_libvirt_domain_pin_vcpu"
   external get_vcpus : [>`R] t -> int -> int -> int * vcpu_info array * string = "ocaml_libvirt_domain_get_vcpus"
-  external get_cpu_stats : [>`R] t -> int -> typed_param list array = "ocaml_libvirt_domain_get_cpu_stats"
+  external get_cpu_stats : [>`R] t -> int -> int -> typed_param list array = "ocaml_libvirt_domain_get_cpu_stats"
   external get_max_vcpus : [>`R] t -> int = "ocaml_libvirt_domain_get_max_vcpus"
   external attach_device : [>`W] t -> xml -> unit = "ocaml_libvirt_domain_attach_device"
   external detach_device : [>`W] t -> xml -> unit = "ocaml_libvirt_domain_detach_device"
diff --git a/libvirt/libvirt.mli b/libvirt/libvirt.mli
index 0913a63..9782406 100644
--- a/libvirt/libvirt.mli
+++ b/libvirt/libvirt.mli
@@ -559,7 +559,7 @@ sig
 	for a domain.  See the libvirt documentation for details
 	of the array and bitmap returned from this function.
     *)
-  val get_cpu_stats : [>`R] t -> int -> typed_param list array
+  val get_cpu_stats : [>`R] t -> int -> int -> typed_param list array
     (** [get_pcpu_stats dom nr_pcpu] returns the physical CPU stats
 	for a domain.  See the libvirt documentation for details.
     *)
diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c
index 3d42b73..135b934 100644
--- a/libvirt/libvirt_c_oneoffs.c
+++ b/libvirt/libvirt_c_oneoffs.c
@@ -532,20 +532,21 @@ extern int virDomainGetCPUStats (virDomainPtr domain,
 #endif
 
 CAMLprim value
-ocaml_libvirt_domain_get_cpu_stats (value domv, value nr_pcpusv)
+ocaml_libvirt_domain_get_cpu_stats (value domv, value nr_pcpusv, value flagsv)
 {
 #ifdef HAVE_VIRDOMAINGETCPUSTATS
-  CAMLparam2 (domv, nr_pcpusv);
+  CAMLparam3 (domv, nr_pcpusv, flagsv);
   CAMLlocal5 (cpustats, param_head, param_node, typed_param, typed_param_value);
   CAMLlocal1 (v);
   virDomainPtr dom = Domain_val (domv);
   virConnectPtr conn = Connect_domv (domv);
   int nr_pcpus = Int_val (nr_pcpusv);
+  int flags = Int_val (flagsv);
   virTypedParameterPtr params;
   int r, cpu, ncpus, nparams, i, j, pos;
 
   /* get percpu information */
-  NONBLOCKING (nparams = virDomainGetCPUStats(dom, NULL, 0, 0, 1, 0));
+  NONBLOCKING (nparams = virDomainGetCPUStats(dom, NULL, 0, 0, 1, flags));
   CHECK_ERROR (nparams < 0, conn, "virDomainGetCPUStats");
 
   if ((params = malloc(sizeof(*params) * nparams * 128)) == NULL)
@@ -556,7 +557,7 @@ ocaml_libvirt_domain_get_cpu_stats (value domv, value nr_pcpusv)
   while (cpu < nr_pcpus) {
     ncpus = nr_pcpus - cpu > 128 ? 128 : nr_pcpus - cpu;
 
-    NONBLOCKING (r = virDomainGetCPUStats(dom, params, nparams, cpu, ncpus, 0));
+    NONBLOCKING (r = virDomainGetCPUStats(dom, params, nparams, cpu, ncpus, flags));
     CHECK_ERROR (r < 0, conn, "virDomainGetCPUStats");
 
     for (i = 0; i < ncpus; i++) {
-- 
1.7.1




More information about the virt-tools-list mailing list