WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

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

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH 4 of 9] PoC: ocaml: add bindings for get_runstate_info
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Tue, 11 Jan 2011 10:55:52 +0000
Cc: gianni.tedesco@xxxxxxxxxx, zheng.li@xxxxxxxxxxxxx
Delivery-date: Tue, 11 Jan 2011 03:45:20 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1294743348@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1294743348@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.5.2
# 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

<Prev in Thread] Current Thread [Next in Thread>