From: Ian Campbell Subject: Re: [PATCH 25/28] libxl: ocaml: add PCI device helper functions Date: Thu, 11 Apr 2013 13:56:56 +0100 Message-ID: <1365685016.8036.113.camel@zakaz.uk.xensource.com> References: <1364222729-6982-1-git-send-email-rob.hoes@citrix.com> <1364222729-6982-26-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: <1364222729-6982-26-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: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Mon, 2013-03-25 at 14:45 +0000, Rob Hoes wrote: Same comments here as on the previous patch I think, and I imagine the next one too... > Signed-off-by: Rob Hoes > --- > 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 827fdb6..becdef8 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 ecc26ff..7be5dd4 100644 > --- a/tools/ocaml/libs/xl/xenlight_stubs.c > +++ b/tools/ocaml/libs/xl/xenlight_stubs.c > @@ -416,6 +416,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 && nb > 0) > + 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 && nb > 0) > + 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);