On 09/17/10 11:46, Ian Campbell wrote:
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.
How nice ;-)
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?
I just wanted to be able to support some (inactive) cpupools without any
cpu allocated. It's just a number which should normally be large enough.
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.
Changed (introducing '0' when info->cpumap_size is too small).
Juergen
--
Juergen Gross Principal Developer Operating Systems
TSP ES&S SWE OS6 Telephone: +49 (0) 89 3222 2967
Fujitsu Technology Solutions e-mail: juergen.gross@xxxxxxxxxxxxxx
Domagkstr. 28 Internet: ts.fujitsu.com
D-80807 Muenchen Company details: ts.fujitsu.com/imprint.html
cpupools-xl.patch
Description: Text Data
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|