[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH 4 of 9] PoC: ocaml: add bindings for get_runstate_info



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1294742832 0
# Node ID ed965d81449dfc17452ca8eeea515bc7d073e404
# Parent  89a18365bb0c1296444bcfdac3bd0df23696d9e6
PoC: ocaml: add bindings for get_runstate_info

Required by xapi.

Taken from xen-api-libs.hg/xc and adjusted for upstream libxc+ocaml.

(should be folded into domain-runstates-ocaml)
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 89a18365bb0c -r ed965d81449d tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   Tue Jan 11 10:47:11 2011 +0000
+++ b/tools/libxc/xc_domain.c   Tue Jan 11 10:47:12 2011 +0000
@@ -933,6 +933,24 @@ int xc_vcpu_getinfo(xc_interface *xch,
     return rc;
 }
 
+int xc_get_runstate_info(xc_interface *xch, uint32_t domid, xc_runstate_info_t 
*info)
+{
+    int ret = -EBADF;
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_get_runstate_info;
+    domctl.domain = domid;
+
+    ret = do_domctl(xch, &domctl);
+    if (ret < 0) {
+        ERROR("get runstate info");
+        return ret;
+    }
+
+    memcpy(info, &domctl.u.domain_runstate, sizeof(*info));
+    return ret;
+}
+
 int xc_domain_ioport_permission(xc_interface *xch,
                                 uint32_t domid,
                                 uint32_t first_port,
diff -r 89a18365bb0c -r ed965d81449d tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Tue Jan 11 10:47:11 2011 +0000
+++ b/tools/libxc/xenctrl.h     Tue Jan 11 10:47:12 2011 +0000
@@ -354,6 +354,7 @@ typedef struct xc_dominfo {
 } xc_dominfo_t;
 
 typedef xen_domctl_getdomaininfo_t xc_domaininfo_t;
+typedef xen_domctl_runstate_info_t xc_runstate_info_t;
 
 typedef union 
 {
@@ -1049,6 +1050,10 @@ int xc_domain_get_pod_target(xc_interfac
                              uint64_t *pod_cache_pages,
                              uint64_t *pod_entries);
 
+int xc_get_runstate_info(xc_interface *xch,
+                        uint32_t domid,
+                        xc_runstate_info_t *info);
+
 int xc_domain_ioport_permission(xc_interface *xch,
                                 uint32_t domid,
                                 uint32_t first_port,
diff -r 89a18365bb0c -r ed965d81449d tools/ocaml/libs/xc/xc.ml
--- a/tools/ocaml/libs/xc/xc.ml Tue Jan 11 10:47:11 2011 +0000
+++ b/tools/ocaml/libs/xc/xc.ml Tue Jan 11 10:47:12 2011 +0000
@@ -28,6 +28,18 @@ type vcpuinfo =
        cpumap: int32;
 }
 
+type runstateinfo = {
+  state : int32;
+  missed_changes: int32;
+  state_entry_time : int64;
+  time0 : int64;
+  time1 : int64;
+  time2 : int64;
+  time3 : int64;
+  time4 : int64;
+  time5 : int64;
+}
+
 type domaininfo =
 {
        domid             : domid;
@@ -154,6 +166,8 @@ external domain_getinfo: handle -> domid
 
 external domain_get_vcpuinfo: handle -> int -> int -> vcpuinfo
        = "stub_xc_vcpu_getinfo"
+external domain_get_runstate_info : handle -> int -> runstateinfo
+  = "stub_xc_get_runstate_info"
 
 external domain_ioport_permission: handle -> domid -> int -> int -> bool -> 
unit
        = "stub_xc_domain_ioport_permission"
diff -r 89a18365bb0c -r ed965d81449d tools/ocaml/libs/xc/xc.mli
--- a/tools/ocaml/libs/xc/xc.mli        Tue Jan 11 10:47:11 2011 +0000
+++ b/tools/ocaml/libs/xc/xc.mli        Tue Jan 11 10:47:12 2011 +0000
@@ -22,6 +22,17 @@ type vcpuinfo = {
   cputime : int64;
   cpumap : int32;
 }
+type runstateinfo = {
+  state : int32;
+  missed_changes: int32;
+  state_entry_time : int64;
+  time0 : int64;
+  time1 : int64;
+  time2 : int64;
+  time3 : int64;
+  time4 : int64;
+  time5 : int64;
+}
 type domaininfo = {
   domid : domid;
   dying : bool;
@@ -96,6 +107,8 @@ external domain_getinfo : handle -> domi
   = "stub_xc_domain_getinfo"
 external domain_get_vcpuinfo : handle -> int -> int -> vcpuinfo
   = "stub_xc_vcpu_getinfo"
+external domain_get_runstate_info : handle -> int -> runstateinfo
+  = "stub_xc_get_runstate_info"
 external domain_ioport_permission: handle -> domid -> int -> int -> bool -> 
unit
        = "stub_xc_domain_ioport_permission"
 external domain_iomem_permission: handle -> domid -> nativeint -> nativeint -> 
bool -> unit
diff -r 89a18365bb0c -r ed965d81449d tools/ocaml/libs/xc/xc_stubs.c
--- a/tools/ocaml/libs/xc/xc_stubs.c    Tue Jan 11 10:47:11 2011 +0000
+++ b/tools/ocaml/libs/xc/xc_stubs.c    Tue Jan 11 10:47:12 2011 +0000
@@ -389,6 +389,37 @@ CAMLprim value stub_xc_vcpu_getinfo(valu
        CAMLreturn(result);
 }
 
+CAMLprim value stub_xc_get_runstate_info(value xch, value domid)
+{
+        CAMLparam2(xch, domid);
+        CAMLlocal1(result);
+        xc_runstate_info_t info;
+        int retval;
+
+        retval = xc_get_runstate_info(_H(xch), _D(domid), &info);
+        if (retval < 0)
+                failwith_xc(_H(xch));
+
+        /* Store
+           0 : state (int32)
+           1 : missed_changes (int32)
+           2 : state_entry_time (int64)
+           3-8 : times (int64s)
+        */
+        result = caml_alloc_tuple(9);
+        Store_field(result, 0, caml_copy_int32(info.state));
+        Store_field(result, 1, caml_copy_int32(info.missed_changes));
+        Store_field(result, 2, caml_copy_int64(info.state_entry_time));
+        Store_field(result, 3, caml_copy_int64(info.time[0]));
+        Store_field(result, 4, caml_copy_int64(info.time[1]));
+        Store_field(result, 5, caml_copy_int64(info.time[2]));
+        Store_field(result, 6, caml_copy_int64(info.time[3]));
+        Store_field(result, 7, caml_copy_int64(info.time[4]));
+        Store_field(result, 8, caml_copy_int64(info.time[5]));
+
+        CAMLreturn(result);
+}
+
 CAMLprim value stub_xc_vcpu_context_get(value xch, value domid,
                                         value cpu)
 {

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.