support of cpupools in xl
PATCH 1/1 support of cpupools in xl
this is the next version of my patches to support cpupools in xl/libxl. For full functionality it is necessary to change cpumask handling for cpupools in libxc (patch 1). Patch 2 adds the full cpupool support in xl. Patch 3 adds an example configuration file for xm/xl pool-create.
Changes since last version: requests of Ian Campbell
19 files changed, 1020 insertions(+), 238 deletions(-) tools/examples/README | 1 tools/examples/cpupool | 18 + tools/libxc/xc_cpupool.c | 118 +++++--- tools/libxc/xc_misc.c | 14 + tools/libxc/xenctrl.h | 26 - tools/libxl/libxl.c | 252 ++++++++++++++++-- tools/libxl/libxl.h | 13 tools/libxl/libxl.idl | 16 - tools/libxl/libxl_internal.h | 3 tools/libxl/libxl_utils.c | 93 +++++- tools/libxl/libxl_utils.h | 10 tools/libxl/libxltypes.py | 5 tools/libxl/libxlu_cfg_l.c | 30 -- tools/libxl/libxlu_cfg_l.h | 18 - tools/libxl/xl.h | 6 tools/libxl/xl_cmdimpl.c | 494 +++++++++++++++++++++++++++++++++++-- tools/libxl/xl_cmdtable.c | 35 ++ tools/python/xen/lowlevel/xc/xc.c | 96 ++----- tools/python/xen/lowlevel/xl/xl.c | 10
PATCH 1/1 To be able to support arbitrary numbers of physical cpus it was necessary to
include the size of cpumaps in the xc-interfaces for cpu pools. These were:
definition of xc_cpupoolinfo_t
xc_cpupool_getinfo()
xc_cpupool_freeinfo()xc_cpupool_getinfo() and xc_cpupool_freeinfo() are changed to allocate the needed buffer and return it.
7 files changed, 174 insertions(+), 152 deletions(-) tools/libxc/xc_cpupool.c | 118 ++++++++++++++++++++++--------------- tools/libxc/xc_misc.c | 14 ++++ tools/libxc/xenctrl.h | 26 ++++---- tools/libxl/libxl.c | 49 +++++++-------- tools/libxl/libxl_internal.h | 1 tools/libxl/xl_cmdimpl.c | 22 +++--- tools/python/xen/lowlevel/xc/xc.c | 96 ++++++++++++------------------
# HG changeset patch
# User Juergen Gross <[email protected]>
# Date 1286281153 -7200
# Node ID cfce8e7555059a646c657cc678a966e41ad4e4f1
# Parent fe3018c6976deae7556943370e91d448fd096d63
To be able to support arbitrary numbers of physical cpus it was necessary to include the size of cpumaps in the xc-interfaces for cpu pools. These were:
definition of xc_cpupoolinfo_t
xc_cpupool_getinfo()
xc_cpupool_freeinfo()xc_cpupool_getinfo() and xc_cpupool_freeinfo() are changed to allocate the needed buffer and return it.
tools/libxc/xc_cpupool.c +72 -46
@@ -34,6 +34,11 @@return ret; } +static int get_cpumap_size (xc_interface *xch) +{ +return (xc_get_max_cpus (xch) +7 ) /8 ; +} +int xc_cpupool_create (xc_interface *xch,uint32_t *ppoolid,uint32_t sched_id)
@@ -64,50 +69,61 @@return do_sysctl_save (xch, &sysctl); } -int xc_cpupool_getinfo (xc_interface *xch, -uint32_t first_poolid, -uint32_t n_max, -xc_cpupoolinfo_t *info) +xc_cpupoolinfo_t *xc_cpupool_getinfo (xc_interface *xch, +uint32_t poolid) {int err =0 ; -int p; -uint32_t poolid = first_poolid; -uint8_t local[sizeof (info->cpumap)]; +xc_cpupoolinfo_t *info; +uint8_t *local; +int local_size; +int cpumap_size; +int size;DECLARE_SYSCTL ; -memset (info,0 , n_max *sizeof (xc_cpupoolinfo_t)); + local_size =get_cpumap_size (xch); +if (!local_size) + { +PERROR ("Could not get number of cpus" ); +return NULL ; + } + local =alloca (local_size); + cpumap_size = (local_size +sizeof (*info->cpumap) -1 ) /sizeof (*info->cpumap); + size =sizeof (xc_cpupoolinfo_t) + cpumap_size *sizeof (*info->cpumap); + info =malloc (size); +if ( !info ) +return NULL ; -for (p =0 ; p < n_max; p++) +memset (info,0 , size); + info->cpumap_size = local_size *8 ; + info->cpumap = (uint64_t *)(info +1 ); + + sysctl.cmd = XEN_SYSCTL_cpupool_op; + sysctl.u.cpupool_op.op =XEN_SYSCTL_CPUPOOL_OP_INFO ; + sysctl.u.cpupool_op.cpupool_id = poolid; +set_xen_guest_handle (sysctl.u.cpupool_op.cpumap.bitmap, local); + sysctl.u.cpupool_op.cpumap.nr_cpus = local_size *8 ; + +if ( (err =lock_pages (local, local_size)) !=0 ) { - sysctl.cmd = XEN_SYSCTL_cpupool_op; - sysctl.u.cpupool_op.op =XEN_SYSCTL_CPUPOOL_OP_INFO ; - sysctl.u.cpupool_op.cpupool_id = poolid; -set_xen_guest_handle (sysctl.u.cpupool_op.cpumap.bitmap, local); - sysctl.u.cpupool_op.cpumap.nr_cpus =sizeof (info->cpumap) *8 ; +PERROR ("Could not lock memory for Xen hypercall" ); +free (info); +return NULL ; + } + err =do_sysctl_save (xch, &sysctl); +unlock_pages (local, local_size); -if ( (err =lock_pages (local,sizeof (local))) !=0 ) - { -PERROR ("Could not lock memory for Xen hypercall" ); -break ; - } - err =do_sysctl_save (xch, &sysctl); -unlock_pages (local,sizeof (local)); - -if ( err <0 ) -break ; - - info->cpupool_id = sysctl.u.cpupool_op.cpupool_id; - info->sched_id = sysctl.u.cpupool_op.sched_id; - info->n_dom = sysctl.u.cpupool_op.n_dom; -bitmap_byte_to_64 (&(info->cpumap), local,sizeof (local) *8 ); - poolid = sysctl.u.cpupool_op.cpupool_id +1 ; - info++; +if ( err <0 ) + { +free (info); +return NULL ; } -if ( p ==0 ) -return err; + info->cpupool_id = sysctl.u.cpupool_op.cpupool_id; + info->sched_id = sysctl.u.cpupool_op.sched_id; + info->n_dom = sysctl.u.cpupool_op.n_dom; +bitmap_byte_to_64 (info->cpumap, local, local_size *8 ); -return p; +return info; } int xc_cpupool_addcpu(xc_interface *xch,
@@ -149,31 +165,41 @@return do_sysctl_save (xch, &sysctl); } -int xc_cpupool_freeinfo (xc_interface *xch, -uint64_t *cpumap) +uint64_t *xc_cpupool_freeinfo (xc_interface *xch, +int *cpusize) {int err; -uint8_t local[sizeof (*cpumap)]; +uint8_t *local; +uint64_t *cpumap;DECLARE_SYSCTL ; + + *cpusize =get_cpumap_size (xch); +if (*cpusize ==0 ) +return NULL ; + local =alloca (*cpusize); + cpumap =calloc ((*cpusize +sizeof (*cpumap) -1 ) /sizeof (*cpumap),sizeof (*cpumap)); +if (cpumap ==NULL ) +return NULL ; sysctl.cmd = XEN_SYSCTL_cpupool_op; sysctl.u.cpupool_op.op =XEN_SYSCTL_CPUPOOL_OP_FREEINFO ;set_xen_guest_handle (sysctl.u.cpupool_op.cpumap.bitmap, local); - sysctl.u.cpupool_op.cpumap.nr_cpus =sizeof (*cpumap) *8 ; + sysctl.u.cpupool_op.cpumap.nr_cpus = *cpusize *8 ; -if ( (err =lock_pages (local,sizeof (local))) !=0 ) +if ( (err =lock_pages (local, *cpusize)) !=0 ) {PERROR ("Could not lock memory for Xen hypercall" ); -return err; +free (cpumap); +return NULL ; } err =do_sysctl_save (xch, &sysctl); -unlock_pages (local,sizeof (local)); +unlock_pages (local, *cpusize); +bitmap_byte_to_64 (cpumap, local, *cpusize *8 ); -if (err <0 ) -return err; +if (err >=0 ) +return cpumap; -bitmap_byte_to_64 (cpumap, local,sizeof (local) *8 ); - -return 0 ; +free (cpumap); +return NULL ; }
tools/libxc/xc_misc.c +14 -0
@@ -20,6 +20,20 @@#include "xc_private.h" #include <xen/hvm/hvm_op.h> + +int xc_get_max_cpus (xc_interface *xch) +{ +static int max_cpus =0 ; +xc_physinfo_t physinfo; + +if ( max_cpus ) +return max_cpus; + +if ( !xc_physinfo (xch, &physinfo) ) + max_cpus = physinfo.max_cpu_id +1 ; + +return max_cpus; +} int xc_readconsolering(xc_interface *xch, char **pbuffer,
tools/libxc/xenctrl.h +13 -13
@@ -215,6 +215,9 @@start_info_t s; } start_info_any_t; + +/* return maximum number of cpus the hypervisor supports */ +int xc_get_max_cpus (xc_interface *xch); int xc_domain_create(xc_interface *xch, uint32_t ssidref,
@@ -535,7 +538,8 @@uint32_t cpupool_id;uint32_t sched_id;uint32_t n_dom; -uint64_t cpumap; +uint32_t cpumap_size;/* max number of cpus in map */ +uint64_t *cpumap; } xc_cpupoolinfo_t;/**
@@ -564,15 +568,11 @@* Get cpupool info. Returns info for up to the specified number of cpupools * starting at the given id. * @parm xc_handle a handle to an open hypervisor interface -* @parm first_poolid lowest id for which info is returned -* @parm n_max maximum number of cpupools to return info -* @parm info pointer to xc_cpupoolinfo_t array -* return number of cpupool infos +* @parm poolid lowest id for which info is returned +* return cpupool info ptr (obtained by malloc) */ -int xc_cpupool_getinfo (xc_interface *xch, -uint32_t first_poolid, -uint32_t n_max, -xc_cpupoolinfo_t *info); +xc_cpupoolinfo_t *xc_cpupool_getinfo (xc_interface *xch, +uint32_t poolid);/** * Add cpu to a cpupool. cpu may be -1 indicating the first unassigned.
@@ -614,11 +614,11 @@* Return map of cpus not in any cpupool. * * @parm xc_handle a handle to an open hypervisor interface -* @parm cpumap pointer where to store the cpumap -* return 0 on success, -1 on failure +* @parm cpusize where to store array size in bytes +* return cpumap array on success, NULL else */ -int xc_cpupool_freeinfo (xc_interface *xch, -uint64_t *cpumap); +uint64_t *xc_cpupool_freeinfo (xc_interface *xch, +int *cpusize);/*
tools/libxl/libxl.c +24 -25
75 lines not on this page · raw message
tools/libxl/libxl_internal.h +0 -1
@@ -239,7 +239,6 @@ _hidden char *libxl__domid_to_name(libxl__gc *gc, uint32_t domid); _hidden char *libxl__poolid_to_name(libxl__gc *gc, uint32_t poolid); -/* holds the CPUID response for a single CPUID leaf * input contains the value of the EAX and ECX register, * and each policy string contains a filter to apply to
tools/libxl/xl_cmdimpl.c +11 -11
@@ -3616,12 +3616,11 @@static void vcpupin (char *d,const char *vcpu,char *cpu) {libxl_vcpuinfo *vcpuinfo; -libxl_physinfo physinfo;uint64_t *cpumap =NULL ;uint32_t vcpuid, cpuida, cpuidb;char *endptr, *toka, *tokb; -int i, nb_vcpu, cpusize; +int i, nb_vcpu, cpusize, cpumapsize; vcpuid =strtoul (vcpu, &endptr,10 );if (vcpu == endptr) {
@@ -3634,12 +3633,13 @@find_domain (d); -if (libxl_get_physinfo (&ctx, &physinfo) !=0 ) { -fprintf (stderr,"libxl_get_physinfo failed.\n" ); +if ((cpusize =xc_get_max_cpus (ctx.xch)) ==0 ) { +fprintf (stderr,"xc_get_maxcpus failed.\n" ); goto vcpupin_out1; } - - cpumap =calloc (physinfo.max_cpu_id +1 ,sizeof (uint64_t )); + cpumapsize = (cpusize +sizeof (uint64_t ) -1 ) /sizeof (uint64_t ); + + cpumap =calloc (cpumapsize,sizeof (uint64_t ));if (!cpumap) { goto vcpupin_out1; }
@@ -3667,24 +3667,24 @@ } }else { -memset (cpumap,-1 ,sizeof (uint64_t ) * (physinfo.max_cpu_id +1 )); +memset (cpumap,-1 ,sizeof (uint64_t ) * cpumapsize); }if (vcpuid !=-1 ) {if (libxl_set_vcpuaffinity (&ctx, domid, vcpuid, - cpumap, physinfo.max_cpu_id +1 ) ==-1 ) { + cpumap, cpusize) ==-1 ) {fprintf (stderr,"Could not set affinity for vcpu `%u'.\n" , vcpuid); } }else { -if (!(vcpuinfo =libxl_list_vcpu (&ctx, domid, &nb_vcpu, &cpusize))) { +if (!(vcpuinfo =libxl_list_vcpu (&ctx, domid, &nb_vcpu, &i))) {fprintf (stderr,"libxl_list_vcpu failed.\n" ); goto vcpupin_out; }for (; nb_vcpu >0 ; --nb_vcpu, ++vcpuinfo) {if (libxl_set_vcpuaffinity (&ctx, domid, vcpuinfo->vcpuid, - cpumap, physinfo.max_cpu_id +1 ) ==-1 ) { -fprintf (stderr,"libxl_list_vcpu failed on vcpu `%u'.\n" , vcpuinfo->vcpuid); + cpumap, cpusize) ==-1 ) { +fprintf (stderr,"libxl_set_vcpuaffinity failed on vcpu `%u'.\n" , vcpuinfo->vcpuid); } } }
tools/python/xen/lowlevel/xc/xc.c +40 -56
175 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: [PATCH 1 of 3] To be able to support arbitrary numbers of physical cpus it was necessary to
tools/libxl/libxl_internal.h line 244
Quoted 11 lines · Juergen Gross
diff -r
fe3018c6976d-rcfce8e755505tools/libxl/libxl_internal.htools/libxl/libxl_internal.h +0
-1@@ -239,7 +239,6 @@ _hidden char *libxl__domid_to_name(libxl__gc *gc, uint32_t domid); _hidden char *libxl__poolid_to_name(libxl__gc *gc, uint32_t poolid); -/* holds the CPUID response for a single CPUID leaf * input contains the value of the EAX and ECX register, * and each policy string contains a filter to apply to
we don't need this change
Quoted 18 lines
diff -r
fe3018c6976d-rcfce8e755505tools/libxl/xl_cmdimpl.ctools/libxl/xl_cmdimpl.c +1
-2@@ -3616,12 +3616,11 @@static void vcpupin (char *d,const char *vcpu,char *cpu) {libxl_vcpuinfo *vcpuinfo; -libxl_physinfo physinfo;uint64_t *cpumap =NULL ;uint32_t vcpuid, cpuida, cpuidb;char *endptr, *toka, *tokb; -int i, nb_vcpu, cpusize; +int i, nb_vcpu, cpusize, cpumapsize; vcpuid =strtoul (vcpu, &endptr,10 );if (vcpu == endptr) {
tools/libxl/xl_cmdimpl.c line 3639
Quoted 9 lines
tools/libxl/xl_cmdimpl.c +2
-2@@ -3634,12 +3633,13 @@find_domain (d); -if (libxl_get_physinfo (&ctx, &physinfo) !=0 ) { -fprintf (stderr,"libxl_get_physinfo failed.\n" ); +if ((cpusize =xc_get_max_cpus (ctx.xch)) ==0 ) { +fprintf (stderr,"xc_get_maxcpus failed.\n" ); goto vcpupin_out1; }
You shouldn't be calling xc functions directly from xl_cmdimpl.c. The basic rule is: libxl clients (such as xl) shouldn't need to call any library functions other than libxenlight's functions.
You can add a libxl_get_max_cpus function though.
Re: [PATCH 1 of 3] To be able to support arbitrary numbers of physical cpus it was necessary to
Quoted 37 lines · Stefano Stabellini
tools/libxl/libxl_internal.h line 244
Quoted 11 lines · Juergen Gross
diff -r
fe3018c6976d-rcfce8e755505tools/libxl/libxl_internal.htools/libxl/libxl_internal.h +0
-1@@ -239,7 +239,6 @@ _hidden char *libxl__domid_to_name(libxl__gc *gc, uint32_t domid); _hidden char *libxl__poolid_to_name(libxl__gc *gc, uint32_t poolid); -/* holds the CPUID response for a single CPUID leaf * input contains the value of the EAX and ECX register, * and each policy string contains a filter to apply to we don't need this change
Quoted 21 lines
diff -r
fe3018c6976d-rcfce8e755505tools/libxl/xl_cmdimpl.ctools/libxl/xl_cmdimpl.c +1
-2@@ -3616,12 +3616,11 @@static void vcpupin (char *d,const char *vcpu,char *cpu) {libxl_vcpuinfo *vcpuinfo; -libxl_physinfo physinfo;uint64_t *cpumap =NULL ;uint32_t vcpuid, cpuida, cpuidb;char *endptr, *toka, *tokb; -int i, nb_vcpu, cpusize; +int i, nb_vcpu, cpusize, cpumapsize; vcpuid =strtoul (vcpu, &endptr,10 );if (vcpu == endptr) {@@ -3634,12 +3633,13 @@find_domain (d);
Quoted 11 lines
tools/libxl/xl_cmdimpl.c line 3639
Quoted 6 lines
tools/libxl/xl_cmdimpl.c +2
-2-if (libxl_get_physinfo (&ctx, &physinfo) !=0 ) { -fprintf (stderr,"libxl_get_physinfo failed.\n" ); +if ((cpusize =xc_get_max_cpus (ctx.xch)) ==0 ) { +fprintf (stderr,"xc_get_maxcpus failed.\n" ); goto vcpupin_out1; }You shouldn't be calling xc functions directly from
xl_cmdimpl.c. The basic rule is: libxl clients (such as xl) shouldn't need to call any library functions other than libxenlight's functions.
You can add alibxl_get_max_cpusfunction though.
Maybe we should add libxl_cpumap_alloc_phys which returns a libxl_cpumap big enough to hold all physical CPUs, there are a few places within libxl itself which might benefit from this, e.g. libxl_list_cpupool and libxl_list_vcpu both call xc_get_max_cpus and then use the result as a parameter to libxl_cpumap_alloc.
Actually, given that libxl_cpumap is only ever used for PCPUs perhaps alloc should just always return a suitably sized map and there's no need for the size parameter to libxl_cpumap_alloc? Is there any plausible potential use for a libxl_cpumap of nrVCPU rather than nrPCPU ?
Ian.
Re: [PATCH 1 of 3] To be able to support arbitrary numbers of physical cpus it was necessary to
Quoted 56 lines · Ian Campbell
Quoted 37 lines · Stefano Stabellini
tools/libxl/libxl_internal.h line 244
Quoted 11 lines · Juergen Gross
diff -r
fe3018c6976d-rcfce8e755505tools/libxl/libxl_internal.htools/libxl/libxl_internal.h +0
-1@@ -239,7 +239,6 @@ _hidden char *libxl__domid_to_name(libxl__gc *gc, uint32_t domid); _hidden char *libxl__poolid_to_name(libxl__gc *gc, uint32_t poolid); -/* holds the CPUID response for a single CPUID leaf * input contains the value of the EAX and ECX register, * and each policy string contains a filter to apply to we don't need this change
Quoted 21 lines
diff -r
fe3018c6976d-rcfce8e755505tools/libxl/xl_cmdimpl.ctools/libxl/xl_cmdimpl.c +1
-2@@ -3616,12 +3616,11 @@static void vcpupin (char *d,const char *vcpu,char *cpu) {libxl_vcpuinfo *vcpuinfo; -libxl_physinfo physinfo;uint64_t *cpumap =NULL ;uint32_t vcpuid, cpuida, cpuidb;char *endptr, *toka, *tokb; -int i, nb_vcpu, cpusize; +int i, nb_vcpu, cpusize, cpumapsize; vcpuid =strtoul (vcpu,&endptr,10 );if (vcpu == endptr) {@@ -3634,12 +3633,13 @@find_domain (d);Quoted 11 lines
tools/libxl/xl_cmdimpl.c line 3639
Quoted 6 lines
tools/libxl/xl_cmdimpl.c +2
-2-if (libxl_get_physinfo (&ctx,&physinfo) !=0 ) { -fprintf (stderr,"libxl_get_physinfo failed.\n" ); +if ((cpusize =xc_get_max_cpus (ctx.xch)) ==0 ) { +fprintf (stderr,"xc_get_maxcpus failed.\n" ); goto vcpupin_out1; }You shouldn't be calling xc functions directly from
xl_cmdimpl.c. The basic rule is: libxl clients (such as xl) shouldn't need to call any library functions other than libxenlight's functions.
You can add alibxl_get_max_cpusfunction though.Maybe we should add
libxl_cpumap_alloc_physwhich returns alibxl_cpumapbig enough to hold all physical CPUs, there are a few places within libxl itself which might benefit from this, e.g.libxl_list_cpupoolandlibxl_list_vcpuboth callxc_get_max_cpusand then use the result as a parameter tolibxl_cpumap_alloc.
Quoted 4 lines
Actually, given that
libxl_cpumapis only ever used for PCPUs perhaps alloc should just always return a suitably sized map and there's no need for the size parameter tolibxl_cpumap_alloc? Is there any plausible potential use for alibxl_cpumapof nrVCPU rather than nrPCPU ?
Currently there seems to be no demand for cpumasks larger than nrPCPU. Changinf libxl_cpumap_alloc to allocate just the correct size seems appropriate.
I think I'll do this in my planned cpumask rework.
Juergen
Signature · 5 lines
Juergen Gross Principal Developer Operating Systems TSP ES&S SWE OS6 Telephone: +49 (0) 89 3222 2967 Fujitsu Technology Solutions e-mail: [email protected] Domagkstr. 28 Internet: ts.fujitsu.com D-80807 Muenchen Company details: ts.fujitsu.com/imprint.html
Re: [PATCH 1 of 3] To be able to support arbitrary numbers of physical cpus it was necessary to
In reply to Juergen GrossQuoted 9 lines · Juergen Gross
include the size of cpumaps in the xc-interfaces for cpu pools. These were:
definition ofxc_cpupoolinfo_t
xc_cpupool_getinfo()
xc_cpupool_freeinfo()xc_cpupool_getinfo()andxc_cpupool_freeinfo()are changed to allocate the needed buffer and return it.Signed-off-by [email protected]
Other than the comments Stefano made this looks good to me, thanks Juergen.
Ian.
PATCH 1/1 support of cpupools in xl: commands and library changes
In reply to Juergen GrossSupport 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
Renamed all cpu pool related names to *cpupool*
13 files changed, 827 insertions(+), 86 deletions(-) tools/libxl/libxl.c | 203 +++++++++++++++ tools/libxl/libxl.h | 13 - tools/libxl/libxl.idl | 16 - tools/libxl/libxl_internal.h | 2 tools/libxl/libxl_utils.c | 93 ++++++- tools/libxl/libxl_utils.h | 10 tools/libxl/libxltypes.py | 5 tools/libxl/libxlu_cfg_l.c | 30 -- tools/libxl/libxlu_cfg_l.h | 18 - tools/libxl/xl.h | 6 tools/libxl/xl_cmdimpl.c | 472 ++++++++++++++++++++++++++++++++++++- tools/libxl/xl_cmdtable.c | 35 ++ tools/python/xen/lowlevel/xl/xl.c | 10
# HG changeset patch
# User Juergen Gross <[email protected]> # Date 1286285184 -7200
# Node ID baee85a244118f3808082358da3ccc5191d7ffd6 # Parent cfce8e7555059a646c657cc678a966e41ad4e4f1 support of cpupools in xl: commands and library changes
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
Renamed all cpu pool related names to *cpupool*
tools/libxl/libxl.c +193 -10
@@ -607,21 +607,26 @@return 0 ; } -libxl_poolinfo *libxl_list_pool (libxl_ctx *ctx,int *nb_pool) -{ -libxl_poolinfo *ptr, *tmp; -int i; +libxl_cpupoolinfo *libxl_list_cpupool (libxl_ctx *ctx,int *nb_pool) +{ +libxl_cpupoolinfo *ptr, *tmp; +int i, m, ncpu;xc_cpupoolinfo_t *info;uint32_t poolid; ptr =NULL ; + ncpu =xc_get_max_cpus (ctx->xch); +if (!ncpu) { +LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"getting max cpu number" ); +return NULL ; + } poolid =0 ;for (i =0 ;; i++) { info =xc_cpupool_getinfo (ctx->xch, poolid);if (info ==NULL )break ; - tmp =realloc (ptr, (i +1 ) *sizeof (libxl_poolinfo)); + tmp =realloc (ptr, (i +1 ) *sizeof (libxl_cpupoolinfo));if (!tmp) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"allocating cpupool info" );free (ptr);
@@ -629,6 +634,13 @@ } ptr = tmp; 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, ncpu)) +break ; +for (m =0 ; m < ptr[i].cpumap.size /sizeof (*ptr[i].cpumap.map); m++) + ptr[i].cpumap.map[m] = (info->cpumap_size > (m *sizeof (*ptr[i].cpumap.map))) ? + info->cpumap[m] :0 ; poolid = info->cpupool_id +1 ;free (info); }
@@ -3223,7 +3235,6 @@libxl_vcpuinfo *ptr, *ret;xc_domaininfo_t domaininfo;xc_vcpuinfo_t vcpuinfo; -unsigned num_cpuwords;if (xc_domain_getinfolist (ctx->xch, domid,1 , &domaininfo) !=1 ) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"getting infolist" );
@@ -3235,10 +3246,9 @@return NULL ; } - num_cpuwords = ((*nrcpus +63 ) /64 );for (*nb_vcpu =0 ; *nb_vcpu <= domaininfo.max_vcpu_id; ++*nb_vcpu, ++ptr) { - ptr->cpumap =malloc (num_cpuwords *sizeof (*ptr->cpumap)); -if (!ptr->cpumap) { +if (libxl_cpumap_alloc (&ptr->cpumap, *nrcpus)) { +LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"allocating cpumap" );return NULL ; }if (xc_vcpu_getinfo (ctx->xch, domid, *nb_vcpu, &vcpuinfo) ==-1 ) {
@@ -3246,7 +3256,7 @@return NULL ; }if (xc_vcpu_getaffinity (ctx->xch, domid, *nb_vcpu, - ptr->cpumap, ((*nrcpus) +7 ) /8 ) ==-1 ) { + ptr->cpumap.map, ((*nrcpus) +7 ) /8 ) ==-1 ) {LIBXL__LOG_ERRNO (ctx,LIBXL__LOG_ERROR ,"getting vcpu affinity" );return NULL ; }
@@ -3929,3 +3939,176 @@libxl__file_reference_unmap (f);free (f->path); } + +int libxl_get_freecpus (libxl_ctx *ctx,libxl_cpumap *cpumap) +{ +int ncpus; + + cpumap->map =xc_cpupool_freeinfo (ctx->xch, &ncpus); +if (cpumap->map ==NULL ) +return ERROR_FAIL ; + + cpumap->size = (ncpus +7 ) /8 ; + +return 0 ; +} + +int libxl_create_cpupool (libxl_ctx *ctx,char *name,int schedid, +libxl_cpumap cpumap,libxl_uuid *uuid, +uint32_t *poolid) +{ +libxl__gc gc =LIBXL_INIT_GC (ctx); +int rc; +int i; +xs_transaction_t t; +char *uuid_string; + + uuid_string =libxl__uuid2string (&gc, *uuid); +if (!uuid_string) +return ERROR_NOMEM ; + + rc =xc_cpupool_create (ctx->xch, poolid, schedid); +if (rc) { +LIBXL__LOG_ERRNOVAL (ctx,LIBXL__LOG_ERROR , rc, +"Could not create cpupool" ); +return ERROR_FAIL ; + } + +for (i =0 ; i < cpumap.size *8 ; i++) +if (cpumap.map[i /64 ] & (1L << (i %64 ))) { + rc =xc_cpupool_addcpu (ctx->xch, *poolid, i); +if (rc) { +LIBXL__LOG_ERRNOVAL (ctx,LIBXL__LOG_ERROR , rc, +"Error moving cpu to cpupool" ); +libxl_destroy_cpupool (ctx, *poolid); +return ERROR_FAIL ; + } + } + +for (;;) { + t =xs_transaction_start (ctx->xsh); + +xs_mkdir (ctx->xsh, t,libxl__sprintf (&gc,"/local/pool/%d" , *poolid)); +libxl__xs_write (&gc, t,libxl__sprintf (&gc,"/local/pool/%d/uuid" , *poolid), + uuid_string); +libxl__xs_write (&gc, t,libxl__sprintf (&gc,"/local/pool/%d/name" , *poolid), + name); + +if (xs_transaction_end (ctx->xsh, t,0 ) || (errno !=EAGAIN )) +return 0 ; + } +} + +int libxl_destroy_cpupool (libxl_ctx *ctx,uint32_t poolid) +{ +libxl__gc gc =LIBXL_INIT_GC (ctx); +int rc, i; +xc_cpupoolinfo_t *info; +xs_transaction_t t; + + info =xc_cpupool_getinfo (ctx->xch, poolid); +if (info ==NULL ) +return ERROR_NOMEM ; + + rc =ERROR_INVAL ; +if ((info->cpupool_id != poolid) || (info->n_dom)) + goto out; + +for (i =0 ; i < info->cpumap_size; i++) +if (info->cpumap[i /64 ] & (1L << (i %64 ))) { + rc =xc_cpupool_removecpu (ctx->xch, poolid, i); +if (rc) { +LIBXL__LOG_ERRNOVAL (ctx,LIBXL__LOG_ERROR , rc, +"Error removing cpu from cpupool" ); + rc =ERROR_FAIL ; + goto out; + } + } + + rc =xc_cpupool_destroy (ctx->xch, poolid); +if (rc) { +LIBXL__LOG_ERRNOVAL (ctx,LIBXL__LOG_ERROR , rc,"Could not destroy cpupool" ); + rc =ERROR_FAIL ; + goto out; + } + +for (;;) { + t =xs_transaction_start (ctx->xsh); + +xs_rm (ctx->xsh,XBT_NULL ,libxl__sprintf (&gc,"/local/pool/%d" , poolid)); + +if (xs_transaction_end (ctx->xsh, t,0 ) || (errno !=EAGAIN )) +break ; + } + + rc =0 ; + +out: +free (info); + +return rc; +} + +int libxl_cpupool_cpuadd (libxl_ctx *ctx,uint32_t poolid,int cpu) +{ +int rc; + + rc =xc_cpupool_addcpu (ctx->xch, poolid, cpu); +if (rc) { +LIBXL__LOG_ERRNOVAL (ctx,LIBXL__LOG_ERROR , rc, +"Error moving cpu to cpupool" ); +return ERROR_FAIL ; + } +return 0 ; +} + +int libxl_cpupool_cpuremove (libxl_ctx *ctx,uint32_t poolid,int cpu) +{ +int rc; + + rc =xc_cpupool_removecpu (ctx->xch, poolid, cpu); +if (rc) { +LIBXL__LOG_ERRNOVAL (ctx,LIBXL__LOG_ERROR , rc, +"Error removing cpu from cpupool" ); +return ERROR_FAIL ; + } +return 0 ; +} + +int libxl_cpupool_movedomain (libxl_ctx *ctx,uint32_t poolid,uint32_t domid) +{ +libxl__gc gc =LIBXL_INIT_GC (ctx); +int rc; +char *dom_path; +char *vm_path; +char *poolname; +xs_transaction_t t; + + dom_path =libxl__xs_get_dompath (&gc, domid); +if (!dom_path) { +return ERROR_FAIL ; + } + + rc =xc_cpupool_movedomain (ctx->xch, poolid, domid); +if (rc) { +LIBXL__LOG_ERRNOVAL (ctx,LIBXL__LOG_ERROR , rc, +"Error moving domain to cpupool" ); +return ERROR_FAIL ; + } + +for (;;) { + t =xs_transaction_start (ctx->xsh); + + poolname =libxl__cpupoolid_to_name (&gc, poolid); + vm_path =libxl__xs_read (&gc,XBT_NULL ,libxl__sprintf (&gc,"%s/vm" , dom_path)); +if (!vm_path) +break ; + +libxl__xs_write (&gc, t,libxl__sprintf (&gc,"%s/pool_name" , vm_path), poolname); + +if (xs_transaction_end (ctx->xsh, t,0 ) || (errno !=EAGAIN )) +break ; + } + +return 0 ; +}
tools/libxl/libxl.h +10 -3
@@ -140,8 +140,6 @@typedef char **libxl_key_value_list ;void libxl_key_value_list_destroy (libxl_key_value_list *kvl); - -typedef uint64_t *libxl_cpumap ;typedef uint32_t libxl_hwcap [8 ];
@@ -358,7 +356,7 @@int libxl_domain_info (libxl_ctx *,libxl_dominfo *info_r,uint32_t domid);libxl_dominfo *libxl_list_domain (libxl_ctx *,int *nb_domain); -libxl_poolinfo *libxl_list_pool (libxl_ctx *,int *nb_pool); +libxl_cpupoolinfo *libxl_list_cpupool (libxl_ctx *,int *nb_pool);libxl_vminfo *libxl_list_vm (libxl_ctx *ctx,int *nb_vm);typedef struct libxl__device_model_starting libxl_device_model_starting ;
@@ -501,6 +499,15 @@int libxl_device_net2_del (libxl_ctx *ctx,libxl_device_net2 *net2,int wait); +int libxl_get_freecpus (libxl_ctx *ctx,libxl_cpumap *cpumap); +int libxl_create_cpupool (libxl_ctx *ctx,char *name,int schedid, +libxl_cpumap cpumap,libxl_uuid *uuid, +uint32_t *poolid); +int libxl_destroy_cpupool (libxl_ctx *ctx,uint32_t poolid); +int libxl_cpupool_cpuadd (libxl_ctx *ctx,uint32_t poolid,int cpu); +int libxl_cpupool_cpuremove (libxl_ctx *ctx,uint32_t poolid,int cpu); +int libxl_cpupool_movedomain (libxl_ctx *ctx,uint32_t poolid,uint32_t domid); +/* common paths */ const char *libxl_sbindir_path (void );const char *libxl_bindir_path (void );
tools/libxl/libxl.idl +11 -5
@@ -16,8 +16,6 @@ libxl_string_list = Builtin("string_list", destructor_fn="libxl_string_list_destroy", passby=PASS_BY_REFERENCE) libxl_key_value_list = Builtin("key_value_list", destructor_fn="libxl_key_value_list_destroy", passby=PASS_BY_REFERENCE) libxl_file_reference = Builtin("file_reference", destructor_fn="libxl_file_reference_destroy", passby=PASS_BY_REFERENCE) - -libxl_cpumap = Builtin("cpumap", destructor_fn="free") libxl_hwcap = Builtin("hwcap")
@@ -45,9 +43,17 @@ ("vcpu_online", uint32), ], destructor_fn=None) -libxl_poolinfo = Struct("poolinfo", [ - ("poolid", uint32) - ], destructor_fn=None) +libxl_cpumap = Struct("cpumap", [ + ("size", uint32, False, "number of bytes in map"), + ("map", Reference(uint64)), + ]) + +libxl_cpupoolinfo = Struct("cpupoolinfo", [ + ("poolid", uint32), + ("sched_id", uint32), + ("n_dom", uint32), + ("cpumap", libxl_cpumap) + ], destructor_fn="libxl_cpupoolinfo_destroy") libxl_vminfo = Struct("vminfo", [ ("uuid", libxl_uuid),
tools/libxl/libxl_internal.h +1 -1
@@ -237,7 +237,7 @@#define LIBXL__LOG_ERROR XTL_ERROR _hidden char *libxl__domid_to_name(libxl__gc *gc, uint32_t domid); -_hidden char *libxl__poolid_to_name(libxl__gc *gc, uint32_t poolid); +_hidden char *libxl__cpupoolid_to_name(libxl__gc *gc, uint32_t poolid);/* holds the CPUID response for a single CPUID leaf * input contains the value of the EAX and ECX register,
tools/libxl/libxl_utils.c +79 -14
135 lines not on this page · raw message
tools/libxl/libxl_utils.h +8 -2
@@ -21,8 +21,10 @@unsigned long libxl_get_required_shadow_memory (unsigned long maxmem_kb,unsigned int smp_cpus);int libxl_name_to_domid (libxl_ctx *ctx,const char *name,uint32_t *domid);char *libxl_domid_to_name (libxl_ctx *ctx,uint32_t domid); -int libxl_name_to_poolid (libxl_ctx *ctx,const char *name,uint32_t *poolid); -char *libxl_poolid_to_name (libxl_ctx *ctx,uint32_t poolid); +int libxl_name_to_cpupoolid (libxl_ctx *ctx,const char *name,uint32_t *poolid); +char *libxl_cpupoolid_to_name (libxl_ctx *ctx,uint32_t poolid); +int libxl_name_to_schedid (libxl_ctx *ctx,const char *name); +char *libxl_schedid_to_name (libxl_ctx *ctx,int schedid);int libxl_get_stubdom_id (libxl_ctx *ctx,int guest_domid);int libxl_is_stubdom (libxl_ctx *ctx,uint32_t domid,uint32_t *target_domid);int libxl_create_logfile (libxl_ctx *ctx,char *name,char **full_name);
@@ -74,5 +76,9 @@* return -1 if there are an error */ int libxl_check_device_model_version (libxl_ctx *ctx,char *path); +int libxl_cpumap_alloc (libxl_cpumap *cpumap,int max_cpus); +int libxl_cpumap_test (libxl_cpumap *cpumap,int cpu); +void libxl_cpumap_set (libxl_cpumap *cpumap,int cpu); +void libxl_cpumap_reset (libxl_cpumap *cpumap,int cpu);#endif
tools/libxl/libxltypes.py +4 -1
@@ -131,7 +131,10 @@ kwargs.setdefault('passby', PASS_BY_VALUE) kwargs.setdefault('namespace', ty.namespace) - typename = ty.typename[len(kwargs['namespace']):] + + typename = ty.typename + if ty.namespace: + typename = typename[len(kwargs['namespace']):] Type.__init__(self, typename + " *", **kwargs) #
tools/libxl/libxlu_cfg_l.c +8 -22
@@ -54,6 +54,7 @@typedef unsigned char flex_uint8_t ;typedef unsigned short int flex_uint16_t ;typedef unsigned int flex_uint32_t ; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN
@@ -83,8 +84,6 @@#ifndef UINT32_MAX #define UINT32_MAX (4294967295U)#endif - -#endif /* ! C99 */ #endif /* ! FLEXINT_H */
@@ -159,15 +158,7 @@/* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. -* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. -* Ditto for the __ia64__ case accordingly. -*/ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer.
@@ -496,7 +487,7 @@void xlu__cfg_yyset_column (int column_no,yyscan_t yyscanner); -#line 500 "libxlu_cfg_l.c" +#line 491 "libxlu_cfg_l.c"#define INITIAL 0#define lexerr 1
@@ -632,12 +623,7 @@/* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */
@@ -645,7 +631,7 @@/* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO fwrite( yytext, yyleng, 1, yyout )#endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -656,7 +642,7 @@if (YY_CURRENT_BUFFER_LVALUE ->yy_is_interactive ) \ { \int c ='*' ; \ -size_t n; \ +int n; \for ( n =0 ; n < max_size && \ (c =getc ( yyin )) !=EOF && c !='\n' ; ++n ) \ buf[n] = (char ) c; \
@@ -744,7 +730,7 @@#line 37 "libxlu_cfg_l.l" -#line 748 "libxlu_cfg_l.c" +#line 734 "libxlu_cfg_l.c" yylval = yylval_param;
@@ -944,7 +930,7 @@#line 82 "libxlu_cfg_l.l"YY_FATAL_ERROR ("flex scanner jammed" ); YY_BREAK -#line 948 "libxlu_cfg_l.c" +#line 934 "libxlu_cfg_l.c"case YY_STATE_EOF (INITIAL ):case YY_STATE_EOF (lexerr):yyterminate ();
@@ -1687,8 +1673,8 @@/** Setup the input buffer state to scan the given bytes. The next call to xlu__cfg_yylex() will * scan from a @e copy of @a bytes. -* @param yybytes the byte buffer to scan -* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. +* @param bytes the byte buffer to scan +* @param len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */
tools/libxl/libxlu_cfg_l.h +2 -16
@@ -58,6 +58,7 @@typedef unsigned char flex_uint8_t ;typedef unsigned short int flex_uint16_t ;typedef unsigned int flex_uint32_t ; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN
@@ -87,8 +88,6 @@#ifndef UINT32_MAX #define UINT32_MAX (4294967295U)#endif - -#endif /* ! C99 */ #endif /* ! FLEXINT_H */
@@ -132,15 +131,7 @@/* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. -* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. -* Ditto for the __ia64__ case accordingly. -*/ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif #ifndef YY_TYPEDEF_YY_BUFFER_STATE
@@ -310,12 +301,7 @@/* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Number of entries by which start-condition stack grows. */
@@ -352,6 +338,6 @@#line 82 "libxlu_cfg_l.l" -#line 356 "libxlu_cfg_l.h" +#line 342 "libxlu_cfg_l.h"#undef xlu__cfg_yyIN_HEADER#endif /* xlu__cfg_yyHEADER_H */
tools/libxl/xl.h +6 -0
@@ -79,6 +79,12 @@int main_network2attach (int argc,char **argv);int main_network2list (int argc,char **argv);int main_network2detach (int argc,char **argv); +int main_poolcreate (int argc,char **argv); +int main_poollist (int argc,char **argv); +int main_pooldestroy (int argc,char **argv); +int main_poolcpuadd (int argc,char **argv); +int main_poolcpuremove (int argc,char **argv); +int main_poolmigrate (int argc,char **argv);void help (char *command);
tools/libxl/xl_cmdimpl.c +460 -12
529 lines not on this page · raw message
tools/libxl/xl_cmdtable.c +35 -0
@@ -338,6 +338,41 @@ "destroy a domain's version 2 virtual network device", "<Domain> <DevId>", }, + {"pool-create" , + &main_poolcreate, +"Create a CPU pool based an ConfigFile" , +"[options] <ConfigFile> [vars]" , +"-h, --help Print this help.\n" +"-f=FILE, --defconfig=FILE Use the given configuration file.\n" +"-n, --dryrun Dry run - prints the resulting configuration." + }, + { "pool-list", + &main_poollist, +"List CPU pools on host" , +"[-l|--long] [-c|--cpus] [<CPU Pool>]" , +"-l, --long Output all CPU pool details.\n" +"-c, --cpus Output list of CPUs used by a pool" + }, + { "pool-destroy", + &main_pooldestroy, +"Deactivates a CPU pool" , +"<CPU Pool>" , + }, + { "pool-cpu-add", + &main_poolcpuadd, +"Adds a CPU to a CPU pool" , +"<CPU Pool> <CPU nr>" , + }, + { "pool-cpu-remove", + &main_poolcpuremove, +"Removes a CPU from a CPU pool" , +"<CPU Pool> <CPU nr>" , + }, + { "pool-migrate", + &main_poolmigrate, +"Moves a domain into a CPU pool" , + "<Domain> <CPU Pool>", + }, };int cmdtable_len =sizeof (cmd_table)/sizeof (struct cmd_spec );
tools/python/xen/lowlevel/xl/xl.c +10 -0
@@ -208,6 +208,11 @@return -1 ; } +int attrib__uint64_t_ptr_set (PyObject *v,uint64_t * *pptr) +{ +return -1 ; +} +int attrib__libxl_cpumap_set (PyObject *v,libxl_cpumap *pptr) {return -1 ;
@@ -254,6 +259,11 @@ }PyObject *attrib__libxl_cpuid_policy_list_get (libxl_cpuid_policy_list *pptr) +{ +return NULL ; +} + +PyObject *attrib__uint64_t_ptr_get (uint64_t * *pptr) {return NULL ; }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: [PATCH 2 of 3] support of cpupools in xl: commands and library changes
Quoted 11 lines · Juergen Gross
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
Renamed all cpu pool related names to *cpupool*Signed-off-by [email protected]
Quoted 18 lines
13 files changed, 827 insertions(+), 86 deletions(-) tools/libxl/libxl.c | 203 +++++++++++++++ tools/libxl/libxl.h | 13 - tools/libxl/libxl.idl | 16 - tools/libxl/libxl_internal.h | 2 tools/libxl/libxl_utils.c | 93 ++++++- tools/libxl/libxl_utils.h | 10 tools/libxl/libxltypes.py | 5 tools/libxl/libxlu_cfg_l.c | 30 -- tools/libxl/libxlu_cfg_l.h | 18 - tools/libxl/xl.h | 6 tools/libxl/xl_cmdimpl.c | 472 ++++++++++++++++++++++++++++++++++++- tools/libxl/xl_cmdtable.c | 35 ++ tools/python/xen/lowlevel/xl/xl.c | 10
Re: [PATCH 2 of 3] support of cpupools in xl: commands and library changes
In reply to Juergen GrossQuoted 27 lines · Juergen Gross
diff -r
cfce8e755505-rbaee85a24411tools/python/xen/lowlevel/xl/xl.ctools/python/xen/lowlevel/xl/xl.c Tue Oct 05 15:26:24 2010 +0200 renamed from tools/python/xen/lowlevel/xl/xl.c Tue Oct 05 14:19:13 2010 +0200 +10
-0@@ -208,6 +208,11 @@ return -1; } +int attrib__uint64_t_ptr_set(PyObject *v, uint64_t * *pptr) +{ + return -1; +} + int attrib__libxl_cpumap_set(PyObject *v, libxl_cpumap *pptr) { return -1;@@ -254,6 +259,11 @@ } PyObject *attrib__libxl_cpuid_policy_list_get(libxl_cpuid_policy_list *pptr) +{ + return NULL; +} + +PyObject *attrib__uint64_t_ptr_get(uint64_t * *pptr) { return NULL;
Quoted 1 line
}
Because of using Reference(Uint64) directly in the idl - the python bindings autogenerate these type-marshalling functions. It's not quite clear how these are supposed to be implemented in a generic way! :)
There ought to be a builtin type for this ala libxl_uuid and other types to generate correct bindings.
The other chunk to libxltypes then becomes redundant but it's OK with me I think.
NAK'd-by: Gianni Tedesco <[email protected]>
Re: [PATCH 2 of 3] support of cpupools in xl: commands and library changes
Quoted 34 lines · Gianni Tedesco
Quoted 27 lines · Juergen Gross
diff -r
cfce8e755505-rbaee85a24411tools/python/xen/lowlevel/xl/xl.ctools/python/xen/lowlevel/xl/xl.c Tue Oct 05 15:26:24 2010 +0200 renamed from tools/python/xen/lowlevel/xl/xl.c Tue Oct 05 14:19:13 2010 +0200 +10
-0@@ -208,6 +208,11 @@ return -1; } +int attrib__uint64_t_ptr_set(PyObject *v, uint64_t * *pptr) +{ + return -1; +} + int attrib__libxl_cpumap_set(PyObject *v, libxl_cpumap *pptr) { return -1;@@ -254,6 +259,11 @@ } PyObject *attrib__libxl_cpuid_policy_list_get(libxl_cpuid_policy_list *pptr) +{ + return NULL; +} + +PyObject *attrib__uint64_t_ptr_get(uint64_t * *pptr) { return NULL;Quoted 1 line
}Because of using Reference(Uint64) directly in the idl - the python bindings autogenerate these type-marshalling functions. It's not quite clear how these are supposed to be implemented in a generic way! :)
Quoted 2 lines
There ought to be a builtin type for this ala
libxl_uuidand other types to generate correct bindings.
Gianni, I suppose I need a builtin for the complete libxl_cpumap type, not only for the uint64_t array due to the size info which is needed to access the array correctly.
I'm not sure how to translate this into the correct bindings. I think the cpumap should be translated into a python list. Which methods do I need to include in xc.c? Or would it be okay to add just some minimal dummy functions and put in the functionality if needed?
Juergeb
Signature · 5 lines
Juergen Gross Principal Developer Operating Systems TSP ES&S SWE OS6 Telephone: +49 (0) 89 3222 2967 Fujitsu Technology Solutions e-mail: [email protected] Domagkstr. 28 Internet: ts.fujitsu.com D-80807 Muenchen Company details: ts.fujitsu.com/imprint.html
Re: [PATCH 2 of 3] support of cpupools in xl: commands and library changes
Quoted 35 lines · Juergen Gross
Quoted 34 lines · Gianni Tedesco
Quoted 27 lines · Juergen Gross
diff -r
cfce8e755505-rbaee85a24411tools/python/xen/lowlevel/xl/xl.ctools/python/xen/lowlevel/xl/xl.c Tue Oct 05 15:26:24 2010 +0200 renamed from tools/python/xen/lowlevel/xl/xl.c Tue Oct 05 14:19:13 2010 +0200 +10
-0@@ -208,6 +208,11 @@ return -1; } +int attrib__uint64_t_ptr_set(PyObject *v, uint64_t * *pptr) +{ + return -1; +} + int attrib__libxl_cpumap_set(PyObject *v, libxl_cpumap *pptr) { return -1;@@ -254,6 +259,11 @@ } PyObject *attrib__libxl_cpuid_policy_list_get(libxl_cpuid_policy_list *pptr) +{ + return NULL; +} + +PyObject *attrib__uint64_t_ptr_get(uint64_t * *pptr) { return NULL;Quoted 1 line
}Because of using Reference(Uint64) directly in the idl - the python bindings autogenerate these type-marshalling functions. It's not quite clear how these are supposed to be implemented in a generic way! :)
Quoted 6 lines
Quoted 2 lines
There ought to be a builtin type for this ala
libxl_uuidand other types to generate correct bindings.Gianni, I suppose I need a builtin for the complete
libxl_cpumaptype, not only for theuint64_tarray due to the size info which is needed to access the array correctly.
Yes, I think so.
There is no way in the IDL to have a pure bitmap type which refers to a different field in the containing structure to get the length, and doing this would likely be unnecessarily complicated.
Quoted 2 lines
I'm not sure how to translate this into the correct bindings. I think the cpumap should be translated into a python list.
Yes, I think lists make sense.
Quoted 1 line
Which methods do I need to include in
xc.c?
I think it will become clear when you try to build it, just follow the build errors ;-)
Quoted 2 lines
Or would it be okay to add just some minimal dummy functions and put in the functionality if needed?
Personally, given that you are planning to change the type from uint64_t to bytes I'd be happy if you stubbed them out for uint64_t for now and only implemented properly during the conversion.
Ian.
Re: [PATCH 2 of 3] support of cpupools in xl: commands and library changes
Quoted 36 lines · Ian Campbell
Quoted 35 lines · Juergen Gross
Quoted 34 lines · Gianni Tedesco
Quoted 27 lines · Juergen Gross
diff -r
cfce8e755505-rbaee85a24411tools/python/xen/lowlevel/xl/xl.ctools/python/xen/lowlevel/xl/xl.c Tue Oct 05 15:26:24 2010 +0200 renamed from tools/python/xen/lowlevel/xl/xl.c Tue Oct 05 14:19:13 2010 +0200 +10
-0@@ -208,6 +208,11 @@ return -1; } +int attrib__uint64_t_ptr_set(PyObject *v, uint64_t * *pptr) +{ + return -1; +} + int attrib__libxl_cpumap_set(PyObject *v, libxl_cpumap *pptr) { return -1;@@ -254,6 +259,11 @@ } PyObject *attrib__libxl_cpuid_policy_list_get(libxl_cpuid_policy_list *pptr) +{ + return NULL; +} + +PyObject *attrib__uint64_t_ptr_get(uint64_t * *pptr) { return NULL;Quoted 1 line
}Because of using Reference(Uint64) directly in the idl - the python bindings autogenerate these type-marshalling functions. It's not quite clear how these are supposed to be implemented in a generic way! :)
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
There ought to be a builtin type for this ala
libxl_uuidand other types to generate correct bindings.Gianni, I suppose I need a builtin for the complete
libxl_cpumaptype, not only for theuint64_tarray due to the size info which is needed to access the array correctly.
Yes exactly, creating a full struct as you have done is "the right way to do it"(tm). See detailed comments below.
Quoted 9 lines
Yes, I think so.
There is no way in the IDL to have a pure bitmap type which refers to a different field in the containing structure to get the length, and doing this would likely be unnecessarily complicated.
Quoted 2 lines
I'm not sure how to translate this into the correct bindings. I think the cpumap should be translated into a python list.
Quoted 9 lines
Yes, I think lists make sense.
Quoted 1 line
Which methods do I need to include in
xc.c?I think it will become clear when you try to build it, just follow the build errors ;-)
Quoted 2 lines
Or would it be okay to add just some minimal dummy functions and put in the functionality if needed?
Yes exactly as Ian says. You will notice plenty of similar stubbed out and unimplemented functions in the python bindings that we can do such nice things with later. If you would like to flesh out the cpupool stuff at the same time as adding it then that would be much appreciated but given how incomplete the binding is we can't say it's 'mandatory' and keep a straight face.
Quoted 3 lines
Personally, given that you are planning to change the type from
uint64_tto bytes I'd be happy if you stubbed them out foruint64_tfor now and only implemented properly during the conversion.
Yeha on closer inspection, this is all kind of moot from the binding perspective. What needs to happen is for libxl_cpumap to be the builtin type defined in libxl.h (and possibly c&p any destructor functions that were generated in to libxl.c). We don't need to generate bindings for an object who's attributes are: (array, length)... Similar to libxl_string_list.
In that case the existing attrib__libxl_cpumap_(set|get) for cpupoolinfo can do all of the necessary work of converting to and from python lists and no patch is required to tools/python/.../xl.c.
But yes, no point doing an non-dummy implementation of that if it's only going to change before the rest of the binding is actually written! :)
Gianni
PATCH 1/1 add example cpupool config file
In reply to Juergen GrossAdds an example configuration file for xm/xl pool-create
2 files changed, 19 insertions(+)
tools/examples/README | 1 +tools/examples/cpupool | 18 ++++++++++++++++++
# HG changeset patch
# User Juergen Gross <[email protected]> # Date 1286286221 -7200
# Node ID bf1b8d1bb6f723b1541699156c6a24d8fc45c843 # Parent baee85a244118f3808082358da3ccc5191d7ffd6 add example cpupool config file
Adds an example configuration file for xm/xl pool-create
tools/examples/README +1 -0
@@ -13,6 +13,7 @@ block-common.sh - sourced by block, block-* block-enbd - binds/unbinds network block devices block-nbd - binds/unbinds network block devices +cpupool - example configuration script for 'xm pool-create' external-device-migrate - called by xend for migrating external devices locking.sh - locking functions to prevent concurrent access to critical sections inside script files
tools/examples/cpupool new file +18 -0
@@ -0,0 +1,18 @@ +# -*- mode: python; -*- +#============================================================================ +# Python configuration setup for 'xm pool-create'. +# This script sets the parameters used when a cpupool is created using +# 'xm pool-create'. +# You use a separate script for each cpupool you want to create, or +# you can set the parameters for the cpupool on the xm command line. +#============================================================================ + +# the name of the new cpupool +name = "Example-Cpupool" + +# the scheduler to use: valid are e.g. credit, sedf, credit2 +sched = "credit" + +# list of cpus to use +cpus = ["2", "3"] +
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: [PATCH 3 of 3] add example cpupool config file
Quoted 35 lines · Juergen Gross
Adds an example configuration file for xm/xl pool-create
Signed-off-by [email protected]2 files changed, 19 insertions(+)
tools/examples/README| 1 +tools/examples/cpupool| 18 ++++++++++++++++++# HG changeset patch
# User Juergen Gross <[email protected]> # Date 1286286221 -7200
# Node IDbf1b8d1bb6f723b1541699156c6a24d8fc45c843# Parentbaee85a244118f3808082358da3ccc5191d7ffd6add example cpupool config fileAdds an example configuration file for xm/xl pool-create
Signed-off-by [email protected]diff -r
baee85a24411-rbf1b8d1bb6f7tools/examples/READMEtools/examples/README +1
-0@@ -13,6 +13,7 @@ block-common.sh - sourced by block, block-* block-enbd - binds/unbinds network block devices block-nbd - binds/unbinds network block devices +cpupool - example configuration script for 'xm pool-create' external-device-migrate - called by xend for migrating external devices locking.sh - locking functions to prevent concurrent access to critical sections inside script filesdiff -r
baee85a24411-rbf1b8d1bb6f7tools/examples/cpupool
tools/examples/cpupool line 9
Quoted 9 lines
tools/examples/cpupool new file +9
-0@@ -0,0 +1,18 @@ +# -*- mode: python; -*- +#============================================================================ +# Python configuration setup for 'xm pool-create'. +# This script sets the parameters used when a cpupool is created using +# 'xm pool-create'. +# You use a separate script for each cpupool you want to create, or +# you can set the parameters for the cpupool on the xm command line. +#============================================================================ +
Considering that this example file is supposed to work with xl too I would recommend to remove the mode: python line that is not needed anyway and all the other Python references in the comment.