Skip to contentSkip to conversation

support of NUMA topology in xl

PATCH In review Juergen Gross 3 participants 9 messages Dec 9, 2010 – Dec 23, 2010 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support of NUMA topology in xl

Patch 1 adds a libxl function to retireve topology information from hypervisor Patch 2 adds support of -n option to xl info
Patch 3 adds possibility to specify complete nodes instead of cpus for cpupools Patch 4 adds possibility to rename a cpupool (libxl and xl command) Patch 5 adds a new xl command cpupool-numa-split to create one cpupool per numa node

9 files changed, 536 insertions(+), 21 deletions(-)
tools/libxl/libxl.c               |  167 ++++++++++++++++++++
tools/libxl/libxl.h               |   11 +
tools/libxl/libxl.idl             |    7 
tools/libxl/libxl_utils.c         |   28 +++
tools/libxl/libxl_utils.h         |    2 
tools/libxl/xl.h                  |    2 
tools/libxl/xl_cmdimpl.c          |  300 +++++++++++++++++++++++++++++++++++--
tools/libxl/xl_cmdtable.c         |   16 +
tools/python/xen/lowlevel/xl/xl.c |   24 ++
#1 lore raw

PATCH 1/1 Support getting topology info in libxl

Added new function libxl_get_topologyinfo() to obtain this information from hypervisor.

Signed-off-by [email protected]
6 files changed, 118 insertions(+)
tools/libxl/libxl.c               |   53 +++++++++++++++++++++++++++++++++++++
tools/libxl/libxl.h               |    8 +++++
tools/libxl/libxl.idl             |    7 ++++
tools/libxl/libxl_utils.c         |   24 ++++++++++++++++
tools/libxl/libxl_utils.h         |    2 +
tools/python/xen/lowlevel/xl/xl.c |   24 ++++++++++++++++

# HG changeset patch
# User Juergen Gross <[email protected]> # Date 1291890090 -3600
# Node ID df32f4ed405abb272cdf0fd66f0944f5da4a55d2 # Parent 0c97247c64d61511acff37d1903cb304b387f397 Support getting topology info in libxl

Added new function libxl_get_topologyinfo() to obtain this information from hypervisor.

Signed-off-by [email protected]
tools/libxl/libxl.c +53 -0
diff -r 0c97247c64d6 -r df32f4ed405a tools/libxl/libxl.c
@@ -3156,6 +3156,59 @@ int libxl_get_physinfo(libxl_ctx *ctx, l
     return 0;
 }
 
+int libxl_get_topologyinfo(libxl_ctx *ctx, libxl_topologyinfo *info)
+{
+    xc_topologyinfo_t tinfo;
+    DECLARE_HYPERCALL_BUFFER(xc_cpu_to_core_t, coremap);
+    DECLARE_HYPERCALL_BUFFER(xc_cpu_to_socket_t, socketmap);
+    DECLARE_HYPERCALL_BUFFER(xc_cpu_to_node_t, nodemap);
+    int i;
+    int rc = 0;
+
+    rc += libxl_cpuarray_alloc(ctx, &info->coremap);
+    rc += libxl_cpuarray_alloc(ctx, &info->socketmap);
+    rc += libxl_cpuarray_alloc(ctx, &info->nodemap);
+    if (rc)
+        goto fail;
+
+    coremap = xc_hypercall_buffer_alloc(ctx->xch, coremap, sizeof(*coremap) * info->coremap.entries);
+    socketmap = xc_hypercall_buffer_alloc(ctx->xch, socketmap, sizeof(*socketmap) * info->socketmap.entries);
+    nodemap = xc_hypercall_buffer_alloc(ctx->xch, nodemap, sizeof(*nodemap) * info->nodemap.entries);
+    if ((coremap == NULL) || (socketmap == NULL) || (nodemap == NULL))
+        goto fail;
+
+    set_xen_guest_handle(tinfo.cpu_to_core, coremap);
+    set_xen_guest_handle(tinfo.cpu_to_socket, socketmap);
+    set_xen_guest_handle(tinfo.cpu_to_node, nodemap);
+    tinfo.max_cpu_index = info->coremap.entries - 1;
+    if (xc_topologyinfo(ctx->xch, &tinfo) != 0)
+        goto fail;
+
+    for (i = 0; i <= tinfo.max_cpu_index; i++) {
+        if (i < info->coremap.entries)
+            info->coremap.array[i] = (coremap[i] == INVALID_TOPOLOGY_ID) ?
+                LIBXL_CPUARRAY_INVALID_ENTRY : coremap[i];
+        if (i < info->socketmap.entries)
+            info->socketmap.array[i] = (socketmap[i] == INVALID_TOPOLOGY_ID) ?
+                LIBXL_CPUARRAY_INVALID_ENTRY : socketmap[i];
+        if (i < info->nodemap.entries)
+            info->nodemap.array[i] = (nodemap[i] == INVALID_TOPOLOGY_ID) ?
+                LIBXL_CPUARRAY_INVALID_ENTRY : nodemap[i];
+    }
+
+    xc_hypercall_buffer_free(ctx->xch, coremap);
+    xc_hypercall_buffer_free(ctx->xch, socketmap);
+    xc_hypercall_buffer_free(ctx->xch, nodemap);
+    return 0;
+
+fail:
+    xc_hypercall_buffer_free(ctx->xch, coremap);
+    xc_hypercall_buffer_free(ctx->xch, socketmap);
+    xc_hypercall_buffer_free(ctx->xch, nodemap);
+    libxl_topologyinfo_destroy(info);
+    return ERROR_FAIL;
+}
+
 const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx)
 {
     union {
tools/libxl/libxl.h +8 -0
diff -r 0c97247c64d6 -r df32f4ed405a tools/libxl/libxl.h
@@ -148,6 +148,13 @@ typedef struct {
     uint8_t *map;
 } libxl_cpumap;
 void libxl_cpumap_destroy(libxl_cpumap *map);
+
+typedef struct {
+    uint32_t entries;
+    uint32_t *array;
+} libxl_cpuarray;
+#define LIBXL_CPUARRAY_INVALID_ENTRY  ~0
+void libxl_cpuarray_destroy(libxl_cpuarray *array);
 
 typedef enum {
     XENFV = 1,
@@ -464,6 +471,7 @@ int libxl_button_press(libxl_ctx *ctx, u
 int libxl_button_press(libxl_ctx *ctx, uint32_t domid, libxl_button button);
 
 int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo);
+int libxl_get_topologyinfo(libxl_ctx *ctx, libxl_topologyinfo *info);
 libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
                                        int *nb_vcpu, int *nrcpus);
 int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
tools/libxl/libxl.idl +7 -0
diff -r 0c97247c64d6 -r df32f4ed405a tools/libxl/libxl.idl
@@ -7,6 +7,7 @@ libxl_uuid = Builtin("uuid")
 libxl_uuid = Builtin("uuid")
 libxl_mac = Builtin("mac")
 libxl_cpumap = Builtin("cpumap", destructor_fn="libxl_cpumap_destroy", passby=PASS_BY_REFERENCE)
+libxl_cpuarray = Builtin("cpuarray", destructor_fn="libxl_cpuarray_destroy", passby=PASS_BY_REFERENCE)
 libxl_qemu_machine_type = Number("qemu_machine_type", namespace="libxl_")
 libxl_console_consback = Number("console_consback", namespace="libxl_")
 libxl_console_constype = Number("console_constype", namespace="libxl_")
@@ -302,6 +303,12 @@ libxl_physinfo = Struct("physinfo", [
     ("phys_cap", uint32),
     ], destructor_fn=None)
 
+libxl_topologyinfo = Struct("topologyinfo", [
+    ("coremap", libxl_cpuarray,   False, "cpu to core map"),
+    ("socketmap", libxl_cpuarray, False, "cpu to socket map"),
+    ("nodemap", libxl_cpuarray,   False, "cpu to node map"),
+    ])
+
 libxl_sched_credit = Struct("sched_credit", [
     ("weight", integer),
     ("cap", integer),
tools/libxl/libxl_utils.c +24 -0
diff -r 0c97247c64d6 -r df32f4ed405a tools/libxl/libxl_utils.c
@@ -751,6 +751,30 @@ void libxl_cpumap_reset(libxl_cpumap *cp
     cpumap->map[cpu / 8] &= ~(1 << (cpu & 7));
 }
 
+int libxl_cpuarray_alloc(libxl_ctx *ctx, libxl_cpuarray *cpuarray)
+{
+    int max_cpus;
+    int i;
+
+    max_cpus = libxl_get_max_cpus(ctx);
+    if (max_cpus == 0)
+        return ERROR_FAIL;
+
+    cpuarray->array = calloc(max_cpus, sizeof(*cpuarray->array));
+    if (!cpuarray->array)
+        return ERROR_NOMEM;
+    cpuarray->entries = max_cpus;
+    for (i = 0; i < max_cpus; i++)
+        cpuarray->array[i] = LIBXL_CPUARRAY_INVALID_ENTRY;
+
+    return 0;
+}
+
+void libxl_cpuarray_destroy(libxl_cpuarray *array)
+{
+    free(array->array);
+}
+
 int libxl_get_max_cpus(libxl_ctx *ctx)
 {
     return xc_get_max_cpus(ctx->xch);
tools/libxl/libxl_utils.h +2 -0
diff -r 0c97247c64d6 -r df32f4ed405a tools/libxl/libxl_utils.h
@@ -82,5 +82,7 @@ void libxl_cpumap_reset(libxl_cpumap *cp
 void libxl_cpumap_reset(libxl_cpumap *cpumap, int cpu);
 #define libxl_for_each_cpu(var, map) for (var = 0; var < (map).size * 8; var++)
 
+int libxl_cpuarray_alloc(libxl_ctx *ctx, libxl_cpuarray *cpuarray);
+
 #endif
 
tools/python/xen/lowlevel/xl/xl.c +24 -0
diff -r 0c97247c64d6 -r df32f4ed405a tools/python/xen/lowlevel/xl/xl.c
@@ -224,6 +224,11 @@ int attrib__libxl_cpumap_set(PyObject *v
     return 0;
 }
 
+int attrib__libxl_cpuarray_set(PyObject *v, libxl_cpuarray *pptr)
+{
+    return -1;
+}
+
 int attrib__libxl_domain_build_state_ptr_set(PyObject *v, libxl_domain_build_state **pptr)
 {
     return -1;
@@ -284,6 +289,25 @@ PyObject *attrib__libxl_cpumap_get(libxl
         }
     }
     return cpulist;
+}
+
+PyObject *attrib__libxl_cpuarray_get(libxl_cpuarray *pptr)
+{
+    PyObject *list = NULL;
+    int i;
+
+    list = PyList_New(0);
+    for (i = 0; i < pptr->entries; i++) {
+        if (pptr->array[i] == LIBXL_CPUARRAY_INVALID_ENTRY) {
+            PyList_Append(list, Py_None);
+        } else {
+            PyObject* pyint = PyInt_FromLong(pptr->array[i]);
+
+            PyList_Append(list, pyint);
+            Py_DECREF(pyint);
+        }
+    }
+    return list;
 }
 
 PyObject *attrib__libxl_domain_build_state_ptr_get(libxl_domain_build_state **pptr)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw

Re: [PATCH 1 of 5] Support getting topology info in libxl

Juergen Gross writes ("[Xen-devel] [PATCH 1 of 5] Support getting topology info in libxl"):

Quoted 2 lines

Added new function libxl_get_topologyinfo() to obtain this information from hypervisor.

Thanks, I've applied this version (Thu, 09 Dec 2010 10:56:35 GMT) of patch 1, and the latest version (Thu, 09 Dec 2010 12:49:22 GMT etc.) of 2-5.

Ian.

#3 lore raw

PATCH 1/1 support topolgy info in xl info

In reply to Juergen Gross

Adds option -n/--numa to xl info command to print topology information. No numa information up to now, as I've no machine which will give this info via xm info (could be a bug in xm, however).

Signed-off-by [email protected]
2 files changed, 50 insertions(+), 11 deletions(-)

tools/libxl/xl_cmdimpl.c | 59 +++++++++++++++++++++++++++++++++++++--------
tools/libxl/xl_cmdtable.c | 2 -

# HG changeset patch
# User Juergen Gross <[email protected]> # Date 1291890200 -3600
# Node ID 0edc47775eaa73552471a59add5f4c7632f4d978 # Parent df32f4ed405abb272cdf0fd66f0944f5da4a55d2 support topolgy info in xl info

Adds option -n/--numa to xl info command to print topology information. No numa information up to now, as I've no machine which will give this info via xm info (could be a bug in xm, however).

Signed-off-by [email protected]
tools/libxl/xl_cmdimpl.c +49 -10
diff -r df32f4ed405a -r 0edc47775eaa tools/libxl/xl_cmdimpl.c
@@ -3925,12 +3925,41 @@ static void output_physinfo(void)
     return;
 }
 
-static void info(void)
+static void output_topologyinfo(void)
+{
+    libxl_topologyinfo info;
+    int i;
+
+    if (libxl_get_topologyinfo(&ctx, &info)) {
+        fprintf(stderr, "libxl_get_topologyinfo failed.\n");
+        return;
+    }
+
+    printf("cpu_topology           :\n");
+    printf("cpu:    core    socket     node\n");
+
+    for (i = 0; i < info.coremap.entries; i++) {
+        if (info.coremap.array[i] != LIBXL_CPUARRAY_INVALID_ENTRY)
+            printf("%3d:    %4d     %4d     %4d\n", i, info.coremap.array[i],
+                info.socketmap.array[i], info.nodemap.array[i]);
+    }
+
+    printf("numa_info              : none\n");
+
+    libxl_topologyinfo_destroy(&info);
+
+    return;
+}
+
+static void info(int numa)
 {
     output_nodeinfo();
 
     output_physinfo();
 
+    if (numa)
+        output_topologyinfo();
+
     output_xeninfo();
 
     printf("xend_config_format     : 4\n");
@@ -3941,19 +3970,29 @@ int main_info(int argc, char **argv)
 int main_info(int argc, char **argv)
 {
     int opt;
-
-    while ((opt = getopt(argc, argv, "h")) != -1) {
+    int option_index = 0;
+    static struct option long_options[] = {
+        {"help", 0, 0, 'h'},
+        {"numa", 0, 0, 'n'},
+        {0, 0, 0, 0}
+    };
+    int numa = 0;
+
+    while ((opt = getopt_long(argc, argv, "hn", long_options, &option_index)) != -1) {
         switch (opt) {
         case 'h':
             help("info");
             return 0;
-        default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
-            break;
-        }
-    }
-
-    info();
+        case 'n':
+            numa = 1;
+            break;
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    info(numa);
     return 0;
 }
 
tools/libxl/xl_cmdtable.c +1 -1
diff -r df32f4ed405a -r 0edc47775eaa tools/libxl/xl_cmdtable.c
@@ -185,7 +185,7 @@ struct cmd_spec cmd_table[] = {
     { "info",
       &main_info,
       "Get information about Xen host",
-      "",
+      "-n, --numa         List host NUMA topology information",
     },
     { "sched-credit",
       &main_sched_credit,

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw

PATCH 1/1 Extend cpupools to support numa

In reply to Juergen Gross

The user interfaces for cpupools are extended to support numa machines:
- xl cpupool-create supports now specifying a node list instead of a cpu list. The new cpupool will be created with all free cpus of the specified numa nodes.
- xl cpupool-cpu-remove and xl cpupool-cpu-add can take a node number instead of a cpu number. Using 'node:1' for the cpu parameter will, depending on the operation, either remove all cpus of node 1 in the specified cpupool, or add all free cpus of node 1 to the cpupool.

libxl is extended with the following functions to support this feature:
int libxl_cpupool_cpuadd_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus) int libxl_cpupool_cpuremove_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus)

Signed-off-by [email protected]
4 files changed, 155 insertions(+), 8 deletions(-)
tools/libxl/libxl.c       |   74 ++++++++++++++++++++++++++++++++++++++++
tools/libxl/libxl.h       |    2 +
tools/libxl/xl_cmdimpl.c  |   83 +++++++++++++++++++++++++++++++++++++++++----
tools/libxl/xl_cmdtable.c |    4 +-

# HG changeset patch
# User Juergen Gross <[email protected]> # Date 1291890397 -3600
# Node ID b979d430eab79f864db7434c26687db76d892fa6 # Parent 0edc47775eaa73552471a59add5f4c7632f4d978 Extend cpupools to support numa

The user interfaces for cpupools are extended to support numa machines:
- xl cpupool-create supports now specifying a node list instead of a cpu list. The new cpupool will be created with all free cpus of the specified numa nodes.
- xl cpupool-cpu-remove and xl cpupool-cpu-add can take a node number instead of a cpu number. Using 'node:1' for the cpu parameter will, depending on the operation, either remove all cpus of node 1 in the specified cpupool, or add all free cpus of node 1 to the cpupool.

libxl is extended with the following functions to support this feature:
int libxl_cpupool_cpuadd_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus) int libxl_cpupool_cpuremove_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus)

Signed-off-by [email protected]
tools/libxl/libxl.c +74 -0
diff -r 0edc47775eaa -r b979d430eab7 tools/libxl/libxl.c
@@ -3822,6 +3822,38 @@ int libxl_cpupool_cpuadd(libxl_ctx *ctx,
     return 0;
 }
 
+int libxl_cpupool_cpuadd_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus)
+{
+    int rc = 0;
+    int cpu;
+    libxl_cpumap freemap;
+    libxl_topologyinfo topology;
+
+    if (libxl_get_freecpus(ctx, &freemap)) {
+        return ERROR_FAIL;
+    }
+
+    if (libxl_get_topologyinfo(ctx, &topology)) {
+        rc = ERROR_FAIL;
+        goto out;
+    }
+
+    *cpus = 0;
+    for (cpu = 0; cpu < topology.nodemap.entries; cpu++) {
+        if (libxl_cpumap_test(&freemap, cpu) &&
+            (topology.nodemap.array[cpu] == node) &&
+            !libxl_cpupool_cpuadd(ctx, poolid, cpu)) {
+                (*cpus)++;
+        }
+    }
+
+    libxl_topologyinfo_destroy(&topology);
+
+out:
+    libxl_cpumap_destroy(&freemap);
+    return rc;
+}
+
 int libxl_cpupool_cpuremove(libxl_ctx *ctx, uint32_t poolid, int cpu)
 {
     int rc;
@@ -3833,6 +3865,48 @@ int libxl_cpupool_cpuremove(libxl_ctx *c
         return ERROR_FAIL;
     }
     return 0;
+}
+
+int libxl_cpupool_cpuremove_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus)
+{
+    int ret = 0;
+    int n_pools;
+    int p;
+    int cpu;
+    libxl_topologyinfo topology;
+    libxl_cpupoolinfo *poolinfo;
+
+    poolinfo = libxl_list_cpupool(ctx, &n_pools);
+    if (!poolinfo) {
+        return ERROR_NOMEM;
+    }
+
+    if (libxl_get_topologyinfo(ctx, &topology)) {
+        ret = ERROR_FAIL;
+        goto out;
+    }
+
+    *cpus = 0;
+    for (p = 0; p < n_pools; p++) {
+        if (poolinfo[p].poolid == poolid) {
+            for (cpu = 0; cpu < topology.nodemap.entries; cpu++) {
+                if ((topology.nodemap.array[cpu] == node) &&
+                    libxl_cpumap_test(&poolinfo[p].cpumap, cpu) &&
+                    !libxl_cpupool_cpuremove(ctx, poolid, cpu)) {
+                        (*cpus)++;
+                }
+            }
+        }
+    }
+
+    libxl_topologyinfo_destroy(&topology);
+
+out:
+    for (p = 0; p < n_pools; p++) {
+        libxl_cpupoolinfo_destroy(poolinfo + p);
+    }
+
+    return ret;
 }
 
 int libxl_cpupool_movedomain(libxl_ctx *ctx, uint32_t poolid, uint32_t domid)
tools/libxl/libxl.h +2 -0
diff -r 0edc47775eaa -r b979d430eab7 tools/libxl/libxl.h
@@ -525,7 +525,9 @@ int libxl_create_cpupool(libxl_ctx *ctx,
                          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_cpuadd_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus);
 int libxl_cpupool_cpuremove(libxl_ctx *ctx, uint32_t poolid, int cpu);
+int libxl_cpupool_cpuremove_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus);
 int libxl_cpupool_movedomain(libxl_ctx *ctx, uint32_t poolid, uint32_t domid);
 
 /* common paths */
tools/libxl/xl_cmdimpl.c +77 -6

134 lines not on this page · raw message

tools/libxl/xl_cmdtable.c +2 -2
diff -r 0edc47775eaa -r b979d430eab7 tools/libxl/xl_cmdtable.c
@@ -361,12 +361,12 @@ struct cmd_spec cmd_table[] = {
     { "cpupool-cpu-add",
       &main_cpupoolcpuadd,
       "Adds a CPU to a CPU pool",
-      "<CPU Pool> <CPU nr>",
+      "<CPU Pool> <CPU nr>|node:<node nr>",
     },
     { "cpupool-cpu-remove",
       &main_cpupoolcpuremove,
       "Removes a CPU from a CPU pool",
-      "<CPU Pool> <CPU nr>",
+      "<CPU Pool> <CPU nr>|node:<node nr>",
     },
     { "cpupool-migrate",
       &main_cpupoolmigrate,

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw

PATCH 1/1 Support renaming of cpupools

In reply to Juergen Gross

Add a new library function libxl_cpupool_rename() and a new xl command xl cpupool-rename to support renaming of cpupools.

Signed-off-by [email protected]
6 files changed, 90 insertions(+), 2 deletions(-)
tools/libxl/libxl.c       |   40 ++++++++++++++++++++++++++++++++++++++++
tools/libxl/libxl.h       |    1 +
tools/libxl/libxl_utils.c |    4 ++--
tools/libxl/xl.h          |    1 +
tools/libxl/xl_cmdimpl.c  |   41 +++++++++++++++++++++++++++++++++++++++++
tools/libxl/xl_cmdtable.c |    5 +++++

# HG changeset patch
# User Juergen Gross <[email protected]> # Date 1291890565 -3600
# Node ID fc3f33c7faa7f94c844ad46a68f58e097ee883f8 # Parent b979d430eab79f864db7434c26687db76d892fa6 Support renaming of cpupools

Add a new library function libxl_cpupool_rename() and a new xl command xl cpupool-rename to support renaming of cpupools.

Signed-off-by [email protected]
tools/libxl/libxl.c +40 -0
diff -r b979d430eab7 -r fc3f33c7faa7 tools/libxl/libxl.c
@@ -3809,6 +3809,46 @@ out:
     return rc;
 }
 
+int libxl_cpupool_rename(libxl_ctx *ctx, const char *name, uint32_t poolid)
+{
+    libxl__gc gc = LIBXL_INIT_GC(ctx);
+    xs_transaction_t t;
+    xc_cpupoolinfo_t *info;
+    int rc;
+
+    info = xc_cpupool_getinfo(ctx->xch, poolid);
+    if (info == NULL)
+        return ERROR_NOMEM;
+
+    rc = ERROR_INVAL;
+    if (info->cpupool_id != poolid)
+        goto out;
+
+    rc = 0;
+
+    for (;;) {
+        t = xs_transaction_start(ctx->xsh);
+
+        libxl__xs_write(&gc, t,
+                        libxl__sprintf(&gc, "/local/pool/%d/name", poolid),
+                        "%s", name);
+
+        if (xs_transaction_end(ctx->xsh, t, 0))
+            break;
+
+        if (errno == EAGAIN)
+            continue;
+
+        rc = ERROR_FAIL;
+        break;
+    }
+
+out:
+    xc_cpupool_infofree(ctx->xch, info);
+
+    return rc;
+}
+
 int libxl_cpupool_cpuadd(libxl_ctx *ctx, uint32_t poolid, int cpu)
 {
     int rc;
tools/libxl/libxl.h +1 -0
diff -r b979d430eab7 -r fc3f33c7faa7 tools/libxl/libxl.h
@@ -524,6 +524,7 @@ int libxl_create_cpupool(libxl_ctx *ctx,
                          libxl_cpumap cpumap, libxl_uuid *uuid,
                          uint32_t *poolid);
 int libxl_destroy_cpupool(libxl_ctx *ctx, uint32_t poolid);
+int libxl_cpupool_rename(libxl_ctx *ctx, const char *name, uint32_t poolid);
 int libxl_cpupool_cpuadd(libxl_ctx *ctx, uint32_t poolid, int cpu);
 int libxl_cpupool_cpuadd_node(libxl_ctx *ctx, uint32_t poolid, int node, int *cpus);
 int libxl_cpupool_cpuremove(libxl_ctx *ctx, uint32_t poolid, int cpu);
tools/libxl/libxl_utils.c +2 -2
diff -r b979d430eab7 -r fc3f33c7faa7 tools/libxl/libxl_utils.c
@@ -107,10 +107,10 @@ char *libxl_cpupoolid_to_name(libxl_ctx 
     char path[strlen("/local/pool") + 12];
     char *s;
 
-    if (poolid == 0)
-        return strdup("Pool-0");
     snprintf(path, sizeof(path), "/local/pool/%d/name", poolid);
     s = xs_read(ctx->xsh, XBT_NULL, path, &len);
+    if (!s && (poolid == 0))
+        return strdup("Pool-0");
     return s;
 }
 
tools/libxl/xl.h +1 -0
diff -r b979d430eab7 -r fc3f33c7faa7 tools/libxl/xl.h
@@ -82,6 +82,7 @@ int main_cpupoolcreate(int argc, char **
 int main_cpupoolcreate(int argc, char **argv);
 int main_cpupoollist(int argc, char **argv);
 int main_cpupooldestroy(int argc, char **argv);
+int main_cpupoolrename(int argc, char **argv);
 int main_cpupoolcpuadd(int argc, char **argv);
 int main_cpupoolcpuremove(int argc, char **argv);
 int main_cpupoolmigrate(int argc, char **argv);
tools/libxl/xl_cmdimpl.c +41 -0

47 lines not on this page · raw message

tools/libxl/xl_cmdtable.c +5 -0
diff -r b979d430eab7 -r fc3f33c7faa7 tools/libxl/xl_cmdtable.c
@@ -358,6 +358,11 @@ struct cmd_spec cmd_table[] = {
       "Deactivates a CPU pool",
       "<CPU Pool>",
     },
+    { "cpupool-rename",
+      &main_cpupoolrename,
+      "Renames a CPU pool",
+      "<CPU Pool> <new name>",
+    },
     { "cpupool-cpu-add",
       &main_cpupoolcpuadd,
       "Adds a CPU to a CPU pool",

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#6 lore raw

Re: [PATCH 4 of 5] Support renaming of cpupools

Quoted 36 lines · Juergen Gross

diff -r b979d430eab7 -r fc3f33c7faa7 tools/libxl/libxl.c

tools/libxl/libxl.c Thu Dec 09 11:29:25 2010 +0100 renamed from tools/libxl/libxl.c Thu Dec 09 11:26:37 2010 +0100 +26 -0
@@ -3809,6 +3809,46 @@ out:
     return rc;
 }
 
+int libxl_cpupool_rename(libxl_ctx *ctx, const char *name, uint32_t
 poolid)
+{
+    libxl__gc gc = LIBXL_INIT_GC(ctx);
+    xs_transaction_t t;
+    xc_cpupoolinfo_t *info;
+    int rc;
+
+    info = xc_cpupool_getinfo(ctx->xch, poolid);
+    if (info == NULL)
+        return ERROR_NOMEM;
+
+    rc = ERROR_INVAL;
+    if (info->cpupool_id != poolid)
+        goto out;
+
+    rc = 0;
+
+    for (;;) {
+        t = xs_transaction_start(ctx->xsh);
+
+        libxl__xs_write(&gc, t,
+                        libxl__sprintf(&gc, "/local/pool/%d/name",
 poolid),
+                        "%s", name);
+
+        if (xs_transaction_end(ctx->xsh, t, 0))
+            break;

tools/libxl/libxl.c Thu Dec 09 11:29:25 2010 +0100 out: · line 3849

Quoted 10 lines
tools/libxl/libxl.c Thu Dec 09 11:29:25 2010 +0100 renamed from tools/libxl/libxl.c Thu Dec 09 11:26:37 2010 +0100 +10 -0
+
+        if (errno == EAGAIN)
+            continue;
+
+        rc = ERROR_FAIL;
+        break;
+    }
+
+out:
+    xc_cpupool_infofree(ctx->xch, info);

You need:

	libxl__free_all(&gc);
#7 lore raw

PATCH 1/1 Support new xl command cpupool-numa-split

In reply to Juergen Gross

New xl command cpupool-numa-split which will create one cpupool for each numa node of the machine. Can be called only if no other cpupools than Pool 0 are defined. After creation the cpupools can be managed as usual.

Signed-off-by [email protected]
3 files changed, 123 insertions(+)
tools/libxl/xl.h          |    1 
tools/libxl/xl_cmdimpl.c  |  117 +++++++++++++++++++++++++++++++++++++++++++++
tools/libxl/xl_cmdtable.c |    5 +

# HG changeset patch
# User Juergen Gross <[email protected]> # Date 1291891853 -3600
# Node ID 040a84d0b4c22a763e680294dd9c7c351b89e778 # Parent fc3f33c7faa7f94c844ad46a68f58e097ee883f8 Support new xl command cpupool-numa-split

New xl command cpupool-numa-split which will create one cpupool for each numa node of the machine. Can be called only if no other cpupools than Pool 0 are defined. After creation the cpupools can be managed as usual.

Signed-off-by [email protected]
tools/libxl/xl.h +1 -0
diff -r fc3f33c7faa7 -r 040a84d0b4c2 tools/libxl/xl.h
@@ -86,6 +86,7 @@ int main_cpupoolcpuadd(int argc, char **
 int main_cpupoolcpuadd(int argc, char **argv);
 int main_cpupoolcpuremove(int argc, char **argv);
 int main_cpupoolmigrate(int argc, char **argv);
+int main_cpupoolnumasplit(int argc, char **argv);
 
 void help(const char *command);
 
tools/libxl/xl_cmdimpl.c +117 -0

120 lines not on this page · raw message

tools/libxl/xl_cmdtable.c +5 -0
diff -r fc3f33c7faa7 -r 040a84d0b4c2 tools/libxl/xl_cmdtable.c
@@ -378,6 +378,11 @@ struct cmd_spec cmd_table[] = {
       "Moves a domain into a CPU pool",
       "<Domain> <CPU Pool>",
     },
+    { "cpupool-numa-split",
+      &main_cpupoolnumasplit,
+      "Splits up the machine into one CPU pool per NUMA node",
+      "",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Acked-by on v1 1/1
#8 lore raw
In reply to Juergen Gross

Other than my one comment to 4/5 and Gianni's python issue the series looks good to me so assuming those are fixed all:

Thanks!

Quoted 21 lines · Juergen Gross

Patch 1 adds a libxl function to retireve topology information from hypervisor Patch 2 adds support of -n option to xl info
Patch 3 adds possibility to specify complete nodes instead of cpus for cpupools Patch 4 adds possibility to rename a cpupool (libxl and xl command) Patch 5 adds a new xl command cpupool-numa-split to create one cpupool per numa node

9 files changed, 536 insertions(+), 21 deletions(-)
tools/libxl/libxl.c               |  167 ++++++++++++++++++++
tools/libxl/libxl.h               |   11 +
tools/libxl/libxl.idl             |    7 
tools/libxl/libxl_utils.c         |   28 +++
tools/libxl/libxl_utils.h         |    2 
tools/libxl/xl.h                  |    2 
tools/libxl/xl_cmdimpl.c          |  300 +++++++++++++++++++++++++++++++++++--
tools/libxl/xl_cmdtable.c         |   16 +
tools/python/xen/lowlevel/xl/xl.c |   24 ++

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel