libxl: ocaml: add dominfo_list and dominfo_get
authorRob Hoes <rob.hoes@citrix.com>
Wed, 6 Nov 2013 17:49:54 +0000 (17:49 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 11 Nov 2013 15:39:39 +0000 (15:39 +0000)
Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: David Scott <dave.scott@eu.citrix.com>
tools/ocaml/libs/xl/genwrap.py
tools/ocaml/libs/xl/xenlight_stubs.c

index 3d939d618cd4f3ed1ab0b7f1aa69de9586db3249..7a22b207da114d896e7058f251a750cd0c009111 100644 (file)
@@ -33,6 +33,9 @@ functions = { # ( name , [type1,type2,....] )
     "device_disk":    DEVICE_FUNCTIONS,
     "device_nic":     DEVICE_FUNCTIONS,
     "device_pci":     DEVICE_FUNCTIONS,
+    "dominfo":        [ ("list",           ["ctx", "t list"]),
+                        ("get",            ["ctx", "domid", "t"]),
+                      ],
     "physinfo":       [ ("get",            ["ctx", "t"]),
                       ],
     "cputopology":    [ ("get",            ["ctx", "t array"]),
index 372ce8f18236b96e9227bcaa92d80957e61fecbc..a6b42940bc9fe5e9205c0d420fcc985d820cb4d4 100644 (file)
@@ -450,6 +450,47 @@ value stub_xl_cputopology_get(value ctx)
        CAMLreturn(topology);
 }
 
+value stub_xl_dominfo_list(value ctx)
+{
+       CAMLparam1(ctx);
+       CAMLlocal2(domlist, temp);
+       libxl_dominfo *c_domlist;
+       int i, nb;
+
+       c_domlist = libxl_list_domain(CTX, &nb);
+       if (!c_domlist)
+               failwith_xl(ERROR_FAIL, "dominfo_list");
+
+       domlist = temp = Val_emptylist;
+       for (i = nb - 1; i >= 0; i--) {
+               domlist = caml_alloc_small(2, Tag_cons);
+               Field(domlist, 0) = Val_int(0);
+               Field(domlist, 1) = temp;
+               temp = domlist;
+
+               Store_field(domlist, 0, Val_dominfo(&c_domlist[i]));
+       }
+
+       libxl_dominfo_list_free(c_domlist, nb);
+
+       CAMLreturn(domlist);
+}
+
+value stub_xl_dominfo_get(value ctx, value domid)
+{
+       CAMLparam2(ctx, domid);
+       CAMLlocal1(dominfo);
+       libxl_dominfo c_dominfo;
+       int ret;
+
+       ret = libxl_domain_info(CTX, &c_dominfo, Int_val(domid));
+       if (ret != 0)
+               failwith_xl(ERROR_FAIL, "domain_info");
+       dominfo = Val_dominfo(&c_dominfo);
+
+       CAMLreturn(dominfo);
+}
+
 value stub_xl_domain_sched_params_get(value ctx, value domid)
 {
        CAMLparam2(ctx, domid);