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

[Xen-devel] [PATCH v3 22/28] libxl: ocaml: add PCI device helper functions



Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>
---
 tools/ocaml/libs/xl/genwrap.py       |    7 ++-
 tools/ocaml/libs/xl/xenlight_stubs.c |   90 ++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+), 1 deletion(-)

diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py
index c037515..819df3a 100644
--- a/tools/ocaml/libs/xl/genwrap.py
+++ b/tools/ocaml/libs/xl/genwrap.py
@@ -35,7 +35,12 @@ functions = { # ( name , [type1,type2,....] )
                       [ ("list",           ["ctx", "domid", "t list"]),
                         ("of_devid",       ["ctx", "domid", "int", "t"]),
                       ],
-    "device_pci":     DEVICE_FUNCTIONS,
+    "device_pci":     DEVICE_FUNCTIONS +
+                      [ ("list",              ["ctx", "domid", "t list"]),
+                        ("assignable_add",    ["ctx", "t", "bool", "unit"]),
+                        ("assignable_remove", ["ctx", "t", "bool", "unit"]),
+                        ("assignable_list",   ["ctx", "t list"]),
+                      ],
     "dominfo":        [ ("list",           ["ctx", "t list"]),
                         ("get",            ["ctx", "domid", "t"]),
                       ],
diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c 
b/tools/ocaml/libs/xl/xenlight_stubs.c
index c79de79..0890fd1 100644
--- a/tools/ocaml/libs/xl/xenlight_stubs.c
+++ b/tools/ocaml/libs/xl/xenlight_stubs.c
@@ -469,6 +469,96 @@ value stub_xl_device_nic_list(value ctx, value domid)
        CAMLreturn(list);
 }
 
+value stub_xl_device_pci_list(value ctx, value domid)
+{
+       CAMLparam2(ctx, domid);
+       CAMLlocal2(list, temp);
+       libxl_device_pci *c_list;
+       int i, nb;
+       uint32_t c_domid;
+
+       c_domid = Int_val(domid);
+
+       c_list = libxl_device_pci_list(CTX, c_domid, &nb);
+       if (!c_list)
+               failwith_xl(ERROR_FAIL, "pci_list");
+
+       list = temp = Val_emptylist;
+       for (i = 0; i < nb; i++) {
+               list = caml_alloc_small(2, Tag_cons);
+               Field(list, 0) = Val_int(0);
+               Field(list, 1) = temp;
+               temp = list;
+               Store_field(list, 0, Val_device_pci(&c_list[i]));
+               libxl_device_pci_dispose(&c_list[i]);
+       }
+       free(c_list);
+
+       CAMLreturn(list);
+}
+
+value stub_xl_device_pci_assignable_add(value ctx, value info, value rebind)
+{
+       CAMLparam3(ctx, info, rebind);
+       libxl_device_pci c_info;
+       int ret, marker_var;
+
+       device_pci_val(CTX, &c_info, info);
+
+       ret = libxl_device_pci_assignable_add(CTX, &c_info, (int) 
Bool_val(rebind));
+
+       libxl_device_pci_dispose(&c_info);
+
+       if (ret != 0)
+               failwith_xl(ret, "pci_assignable_add");
+
+       CAMLreturn(Val_unit);
+}
+
+value stub_xl_device_pci_assignable_remove(value ctx, value info, value rebind)
+{
+       CAMLparam3(ctx, info, rebind);
+       libxl_device_pci c_info;
+       int ret, marker_var;
+
+       device_pci_val(CTX, &c_info, info);
+
+       ret = libxl_device_pci_assignable_remove(CTX, &c_info, (int) 
Bool_val(rebind));
+
+       libxl_device_pci_dispose(&c_info);
+
+       if (ret != 0)
+               failwith_xl(ret, "pci_assignable_remove");
+
+       CAMLreturn(Val_unit);
+}
+
+value stub_xl_device_pci_assignable_list(value ctx)
+{
+       CAMLparam1(ctx);
+       CAMLlocal2(list, temp);
+       libxl_device_pci *c_list;
+       int i, nb;
+       uint32_t c_domid;
+
+       c_list = libxl_device_pci_assignable_list(CTX, &nb);
+       if (!c_list)
+               failwith_xl(ERROR_FAIL, "pci_assignable_list");
+
+       list = temp = Val_emptylist;
+       for (i = 0; i < nb; i++) {
+               list = caml_alloc_small(2, Tag_cons);
+               Field(list, 0) = Val_int(0);
+               Field(list, 1) = temp;
+               temp = list;
+               Store_field(list, 0, Val_device_pci(&c_list[i]));
+               libxl_device_pci_dispose(&c_list[i]);
+       }
+       free(c_list);
+
+       CAMLreturn(list);
+}
+
 value stub_xl_physinfo_get(value ctx)
 {
        CAMLparam1(ctx);
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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