From: Ian Campbell Subject: Re: [PATCH v3-RESEND 21/28] libxl: ocaml: add NIC helper functions Date: Thu, 31 Oct 2013 18:23:16 +0000 Message-ID: <1383243796.5436.60.camel@dagon.hellion.org.uk> References: <1382362365-6645-1-git-send-email-rob.hoes@citrix.com> <1382362365-6645-22-git-send-email-rob.hoes@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1382362365-6645-22-git-send-email-rob.hoes@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Rob Hoes Cc: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Mon, 2013-10-21 at 14:32 +0100, Rob Hoes wrote: > Signed-off-by: Rob Hoes > --- > tools/ocaml/libs/xl/genwrap.py | 5 ++++- > tools/ocaml/libs/xl/xenlight_stubs.c | 36 ++++++++++++++++++++++++++++++++++ > 2 files changed, 40 insertions(+), 1 deletion(-) > > diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py > index 721a336..c037515 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 7e56db9..b921229 100644 > --- a/tools/ocaml/libs/xl/xenlight_stubs.c > +++ b/tools/ocaml/libs/xl/xenlight_stubs.c > @@ -433,6 +433,42 @@ 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); > + libxl_device_nic nic; > + libxl_devid_to_device_nic(CTX, Int_val(domid), Int_val(devid), &nic); > + CAMLreturn(Val_device_nic(&nic)); You need to libxl_device_nic_dispose(&nic) I think. > +} > + > +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);