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

[Xen-changelog] [xen master] libxl: ocaml: add PCI device helper functions



commit fc5c2d5971299f23d88a0a68813ab3e8d7bece45
Author:     Rob Hoes <rob.hoes@xxxxxxxxxx>
AuthorDate: Wed Nov 6 17:49:59 2013 +0000
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Mon Nov 11 15:39:47 2013 +0000

    libxl: ocaml: add PCI device helper functions
    
    Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>
    Acked-by: David Scott <dave.scott@xxxxxxxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 tools/ocaml/libs/xl/genwrap.py       |    7 ++-
 tools/ocaml/libs/xl/xenlight_stubs.c |   90 ++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+), 1 deletions(-)

diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py
index 3d4a866..edadd14 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 3f41935..be8a3e8 100644
--- a/tools/ocaml/libs/xl/xenlight_stubs.c
+++ b/tools/ocaml/libs/xl/xenlight_stubs.c
@@ -442,6 +442,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);
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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