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

Re: [Xen-devel] [Patch][resend] implementation of cpupool support in xl

On Wed, 2010-09-15 at 10:37 +0100, Ian Campbell wrote:
> On Wed, 2010-09-15 at 10:23 +0100, Juergen Gross wrote:
> > 
> > And I'm not sure I'll get the generating of the bindings correctly.
> > So yes, please do it! 
> 
> Will do.
> 
> >From looking at your patch it seems that the intention is that the size
> is the number of bytes in the map, rather than the number of CPUs which
> can be represented or the number of uint64_t's, is that right and/or
> what you would like to use?

Seems like libxc counts bytes but libxl (with your patch) counts 64 bit
words.

There doesn't seem to be any users of the size currently so I went with
bytes in the below (compile tested + examined generated code only) but
since your patch adds the first actual user feel free to change it if
that makes the libxl interface more suitable for your needs or whatever.

Ian.

diff -r 098790dd9327 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Thu Sep 09 17:59:33 2010 +0100
+++ b/tools/libxl/libxl.c       Wed Sep 15 11:19:35 2010 +0100
@@ -2924,8 +2924,9 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ct
 
     num_cpuwords = ((physinfo.max_cpu_id + 64) / 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) {
+        ptr->cpumap.size = num_cpuwords * sizeof(*ptr->cpumap.map);
+        ptr->cpumap.map = malloc(ptr->cpumap.size);
+        if (!ptr->cpumap.map) {
             return NULL;
         }
         if (xc_vcpu_getinfo(ctx->xch, domid, *nb_vcpu, &vcpuinfo) == -1) {
@@ -2933,7 +2934,7 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ct
             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;
         }
diff -r 098790dd9327 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Thu Sep 09 17:59:33 2010 +0100
+++ b/tools/libxl/libxl.h       Wed Sep 15 11:19:35 2010 +0100
@@ -138,8 +138,6 @@ typedef char **libxl_string_list;
 typedef char **libxl_string_list;
 
 typedef char **libxl_key_value_list;
-
-typedef uint64_t *libxl_cpumap;
 
 typedef uint32_t libxl_hwcap[8];
 
diff -r 098790dd9327 tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl     Thu Sep 09 17:59:33 2010 +0100
+++ b/tools/libxl/libxl.idl     Wed Sep 15 11:19:35 2010 +0100
@@ -14,8 +14,6 @@ libxl_nic_type = Builtin("nic_type")
 
 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_cpumap = Builtin("cpumap", destructor_fn="free")
 
 libxl_hwcap = Builtin("hwcap")
 
@@ -42,6 +40,11 @@ SHUTDOWN_* constant."""),
     ("vcpu_online", uint32),
     ], destructor_fn=None)
 
+libxl_cpumap = Struct("cpumap", [
+    ("size", uint32),
+    ("map",  Reference(uint64)),
+    ])
+                      
 libxl_poolinfo = Struct("poolinfo", [
     ("poolid", uint32)
     ], destructor_fn=None)
diff -r 098790dd9327 tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Thu Sep 09 17:59:33 2010 +0100
+++ b/tools/libxl/libxltypes.py Wed Sep 15 11:19:35 2010 +0100
@@ -119,7 +119,10 @@ class Reference(Type):
         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)
 
 #
diff -r 098790dd9327 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Sep 09 17:59:33 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Wed Sep 15 11:19:35 2010 +0100
@@ -3289,7 +3289,7 @@ static void print_vcpuinfo(uint32_t tdom
     printf("%9.1f  ", ((float)vcpuinfo->vcpu_time / 1e9));
     /* CPU AFFINITY */
     pcpumap = nr_cpus > 64 ? (uint64_t)-1 : ((1ULL << nr_cpus) - 1);
-    for (cpumap = vcpuinfo->cpumap; nr_cpus; ++cpumap) {
+    for (cpumap = vcpuinfo->cpumap.map; nr_cpus; ++cpumap) {
         if (*cpumap < pcpumap) {
             break;
         }
@@ -3304,7 +3304,7 @@ static void print_vcpuinfo(uint32_t tdom
     if (!nr_cpus) {
         printf("any cpu\n");
     } else {
-        for (cpumap = vcpuinfo->cpumap; nr_cpus; ++cpumap) {
+        for (cpumap = vcpuinfo->cpumap.map; nr_cpus; ++cpumap) {
             pcpumap = *cpumap;
             for (i = 0; !(pcpumap & 1); ++i, pcpumap >>= 1)
                 ;



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

<Prev in Thread] Current Thread [Next in Thread>