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

Re: [Xen-devel] [PATCH v3 03/11] libxl: add generic function to get and free device list



On Tue, Jun 27, 2017 at 01:03:19PM +0300, Oleksandr Grytsov wrote:
> From: Oleksandr Grytsov <oleksandr_grytsov@xxxxxxxx>
> 
> Add libxl__device_list, libxl__device_list_free.
> Device list is created from libxl xen store entries.
> In order to fill libxl device structure from xen store,
> the device handling framework extended with from_xenstore callback.
> On this callback libxl_device shall be filled with data from
> be xen store directory.
> 
> Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@xxxxxxxx>
> ---
>  tools/libxl/libxl_device.c   | 76 
> ++++++++++++++++++++++++++++++++++++++++++++
>  tools/libxl/libxl_internal.h |  8 +++++
>  tools/libxl/libxl_vdispl.c   | 17 ++++++++--
>  3 files changed, 98 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
> index 00356af..8bcfa2b 100644
> --- a/tools/libxl/libxl_device.c
> +++ b/tools/libxl/libxl_device.c
> @@ -1793,6 +1793,82 @@ out:
>      return AO_CREATE_FAIL(rc);
>  }
>  
> +void* libxl__device_list(const struct libxl_device_type *dt,
> +                         libxl_ctx *ctx, uint32_t domid, int *num)

It should probably take a libxl__gc *gc here.

> +{
> +    GC_INIT(ctx);
> +

And omit the GC_INIT and GC_FREE.

> +    void *r = NULL;
> +    void *list = NULL;
> +    void *item = NULL;
> +    char *libxl_path;
> +    char *be_path;
> +    char** dir = NULL;
> +    unsigned int ndirs = 0;
> +    int rc;
> +
> +    *num = 0;
> +
> +    libxl_path = GCSPRINTF("%s/device/%s",
> +                           libxl__xs_libxl_path(gc, domid), dt->type);
> +
> +    dir = libxl__xs_directory(gc, XBT_NULL, libxl_path, &ndirs);
> +
> +    if (dir && ndirs) {
> +        list = malloc(dt->dev_elem_size * ndirs);

Also please use libxl__malloc here.

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

 


Rackspace

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