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

Re: [Xen-devel] [PATCH 2 of 2] RFC: libxl: move definition of libxl_domain_config into the IDL



On Wed, 2012-04-04 at 11:36 +0100, Ian Campbell wrote:
> # HG changeset patch
> # User Ian Campbell <ian.campbell@xxxxxxxxxx>
> # Date 1333535720 -3600
> # Node ID dc3241cf1ed1b8e5709cc71c9ec8a93b2374cbd5
> # Parent  ac6f863df8f8c86dcc58df15f94333e6088e0bf4
> RFC: libxl: move definition of libxl_domain_config into the IDL
> 
> This requires adding a new Array type to the IDL.
> 
I've finally decided to take node distances into account for my NUMA
series for 4.2, so I'm trying to use this patch for it (just the IDL
array part, I'm leaving libxl_domain_config out... although that can of
course be included as well if we want).

Therefore, I'll include this very own patch as a part of my series
(almost ready, will post next week) with the following proposed
modifications:

> Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
> 
Tested-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>

> diff -r ac6f863df8f8 -r dc3241cf1ed1 tools/libxl/gentypes.py
> --- a/tools/libxl/gentypes.py Wed Apr 04 10:51:11 2012 +0100
> +++ b/tools/libxl/gentypes.py Wed Apr 04 11:35:20 2012 +0100
>
> ...
>
> @@ -66,6 +70,17 @@ def libxl_C_type_dispose(ty, v, indent =
>              s += libxl_C_type_dispose(f.type, fexpr, indent + "    ", 
> nparent)
>              s += "    break;\n"
>          s += "}\n"
> +    elif isinstance(ty, idl.Array):
> +        if parent is None:
> +            raise Exception("Array type must have a parent")
> +        s += "{\n"
> +        s += "    int i;\n"
> +        s += "    for (i=0; i<%s; i++)\n" % (parent + ty.lenvar.name)
> +        s += libxl_C_type_dispose(ty.elem_type, v+"[i]",
> +                                  indent + "        ", parent)
> +        if ty.dispose_fn is not None:
> +            s += "    %s(%s);\n" % (ty.dispose_fn, ty.pass_arg(v, parent is 
> None))
> +        s += "}\n"
>
        if ty.elem_type.dispose_fn is not None:
            s += "    int i;\n"
            s += "    for (i=0; i<%s; i++)\n" % (parent + ty.lenvar.name)
            s += libxl_C_type_dispose(ty.elem_type, v+"[i]",

Otherwise I get something like the below, when creating an array of,
say, uint32_t-s:

    int i;
    for (i=0; i<p->num_dists; i++)
    free(p->dists);

Instead of just the free() part, which is what I need in this case.

> diff -r ac6f863df8f8 -r dc3241cf1ed1 tools/libxl/idl.py
> --- a/tools/libxl/idl.py      Wed Apr 04 10:51:11 2012 +0100
> +++ b/tools/libxl/idl.py      Wed Apr 04 11:35:20 2012 +0100
> @@ -251,6 +251,17 @@ string = Builtin("char *", namespace = N
>                   json_fn = "libxl__string_gen_json",
>                   autogenerate_json = False)
>  
> +class Array(Type):
> +    """An array of the same type"""
> +    def __init__(self, elem_type, lenvar_name, **kwargs):
> +        kwargs.setdefault('dispose_fn', 'free')
> +        Type.__init__(self, typename=elem_type.rawname + " *", **kwargs)
>
        Type.__init__(self, namespace=elem_type.namespace, 
typename=elem_type.rawname + " *", **kwargs)

As suggested by you (IanC) on IRC, to avoid getting stuff like
`libxl_uint32_t' and alike.

Does that make sense?

Regards,
Dario

-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://retis.sssup.it/people/faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

Attachment: signature.asc
Description: This is a digitally signed message part

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

 


Rackspace

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