WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [Patch] support of cpu pools in xl

To: Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
Subject: [Xen-devel] Re: [Patch] support of cpu pools in xl
From: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>
Date: Fri, 17 Sep 2010 10:46:48 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 17 Sep 2010 02:47:23 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4C930642.3080802@xxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <4C930642.3080802@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
> On Fri, 2010-09-17 at 07:10 +0100, Juergen Gross wrote:
> 
> attached patch adds support of cpu pools in xl/libxl.
> Ian, I didn't split up this patch, because the updated libxl_cpumask
> structure requires changes to xl in any case.

That's fine.

> BTW: I realized that libxlu_cfg_l.c seems to be in the repository.
> Isn't this file generated by make? I think it should be removed there.

In an ideal world, yes. I think this was a workaround for buggy versions
of flex observed in the field or something.

> Signed-off-by: juergen.gross@xxxxxxxxxxxxxx
> 
> Support of cpu pools in xl:
>   library functions
>   xl pool-create
>   xl pool-list
>   xl pool-destroy
>   xl pool-cpu-add
>   xl pool-cpu-remove
>   xl pool-migrate
> 
> diff -r d978675f3d53 tools/libxl/libxl.c
> --- a/tools/libxl/libxl.c       Thu Sep 16 18:29:26 2010 +0100
> +++ b/tools/libxl/libxl.c       Fri Sep 17 07:42:30 2010 +0200
> @@ -609,9 +609,17 @@ libxl_poolinfo * libxl_list_pool(libxl_c
>  libxl_poolinfo * libxl_list_pool(libxl_ctx *ctx, int *nb_pool)
>  {
>      libxl_poolinfo *ptr;
> -    int i, ret;
> -    xc_cpupoolinfo_t info[256];
> -    int size = 256;
> +    int i, m;
> +    xc_cpupoolinfo_t *info;
> +    int size;
> +    uint32_t poolid;
> +    libxl_physinfo physinfo;
> +
> +    if (libxl_get_physinfo(ctx, &physinfo) != 0) {
> +        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting phys info");
> +        return NULL;
> +    }
> +    size = physinfo.max_cpu_id + 32;

Where does the number 32 come from?

>      ptr = calloc(size, sizeof(libxl_poolinfo));

>      if (!ptr) {
> @@ -619,16 +627,23 @@ libxl_poolinfo * libxl_list_pool(libxl_c
>          return NULL;
>      }
>  
> -    ret = xc_cpupool_getinfo(ctx->xch, 0, 256, info);
> -    if (ret<0) {
> -        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting cpupool info");
> -        return NULL;
> +    poolid = 0;
> +    for (i = 0; i < size; i++) {
> +        info = xc_cpupool_getinfo(ctx->xch, poolid);
> +        if (info == NULL)
> +            break;
> +        ptr[i].poolid = info->cpupool_id;
> +        ptr[i].sched_id = info->sched_id;
> +        ptr[i].n_dom = info->n_dom;
> +        if (libxl_cpumap_alloc(&ptr[i].cpumap, physinfo.max_cpu_id + 1))
> +            break;
> +        for (m = 0; m < ptr[i].cpumap.size / sizeof(*ptr[i].cpumap.map); m++)
> +            ptr[i].cpumap.map[m] = info->cpumap[m];

I guess if "physinfo.max_cpu_id + 1" does not correspond to
info->cpumap_size then that is a serious error but if it does happen
then you may run over the end of either ptr[i].cpumap.map or
info->cpumap.

Ian.


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel