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

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



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

    libxl: ocaml: add NIC 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       |    5 +++-
 tools/ocaml/libs/xl/xenlight_stubs.c |   39 ++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py
index 7a22b20..3d4a866 100644
--- a/tools/ocaml/libs/xl/genwrap.py
+++ b/tools/ocaml/libs/xl/genwrap.py
@@ -31,7 +31,10 @@ functions = { # ( name , [type1,type2,....] )
     "device_vfb":     DEVICE_FUNCTIONS,
     "device_vkb":     DEVICE_FUNCTIONS,
     "device_disk":    DEVICE_FUNCTIONS,
-    "device_nic":     DEVICE_FUNCTIONS,
+    "device_nic":     DEVICE_FUNCTIONS +
+                      [ ("list",           ["ctx", "domid", "t list"]),
+                        ("of_devid",       ["ctx", "domid", "int", "t"]),
+                      ],
     "device_pci":     DEVICE_FUNCTIONS,
     "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 a6b4294..3f41935 100644
--- a/tools/ocaml/libs/xl/xenlight_stubs.c
+++ b/tools/ocaml/libs/xl/xenlight_stubs.c
@@ -403,6 +403,45 @@ DEVICE_ADDREMOVE(vfb)
 DEVICE_ADDREMOVE(vkb)
 DEVICE_ADDREMOVE(pci)
 
+value stub_xl_device_nic_of_devid(value ctx, value domid, value devid)
+{
+       CAMLparam3(ctx, domid, devid);
+       CAMLlocal1(nic);
+       libxl_device_nic c_nic;
+       libxl_devid_to_device_nic(CTX, Int_val(domid), Int_val(devid), &c_nic);
+       nic = Val_device_nic(&c_nic);
+       libxl_device_nic_dispose(&c_nic);
+       CAMLreturn(nic);
+}
+
+value stub_xl_device_nic_list(value ctx, value domid)
+{
+       CAMLparam2(ctx, domid);
+       CAMLlocal2(list, temp);
+       libxl_device_nic *c_list;
+       int i, nb;
+       uint32_t c_domid;
+
+       c_domid = Int_val(domid);
+
+       c_list = libxl_device_nic_list(CTX, c_domid, &nb);
+       if (!c_list)
+               failwith_xl(ERROR_FAIL, "nic_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_nic(&c_list[i]));
+               libxl_device_nic_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®.