xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0 of 5] support of NUMA topology in xl
@ 2010-12-09 10:51 Juergen Gross
  2010-12-09 10:51 ` [PATCH 1 of 5] Support getting topology info in libxl Juergen Gross
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Juergen Gross @ 2010-12-09 10:51 UTC (permalink / raw)
  To: xen-devel

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 ++

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1 of 5] Support getting topology info in libxl
  2010-12-09 10:51 [PATCH 0 of 5] support of NUMA topology in xl Juergen Gross
@ 2010-12-09 10:51 ` Juergen Gross
  2010-12-23 16:02   ` Ian Jackson
  2010-12-09 10:51 ` [PATCH 2 of 5] support topolgy info in xl info Juergen Gross
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Juergen Gross @ 2010-12-09 10:51 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 503 bytes --]

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

Signed-off-by: juergen.gross@ts.fujitsu.com


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 ++++++++++++++++



[-- Attachment #2: xen-work-5.patch --]
[-- Type: text/x-patch, Size: 7651 bytes --]

# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# 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: juergen.gross@ts.fujitsu.com

diff -r 0c97247c64d6 -r df32f4ed405a tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Thu Dec 09 08:34:59 2010 +0000
+++ b/tools/libxl/libxl.c	Thu Dec 09 11:21:30 2010 +0100
@@ -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 {
diff -r 0c97247c64d6 -r df32f4ed405a tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Thu Dec 09 08:34:59 2010 +0000
+++ b/tools/libxl/libxl.h	Thu Dec 09 11:21:30 2010 +0100
@@ -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,
diff -r 0c97247c64d6 -r df32f4ed405a tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl	Thu Dec 09 08:34:59 2010 +0000
+++ b/tools/libxl/libxl.idl	Thu Dec 09 11:21:30 2010 +0100
@@ -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),
diff -r 0c97247c64d6 -r df32f4ed405a tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c	Thu Dec 09 08:34:59 2010 +0000
+++ b/tools/libxl/libxl_utils.c	Thu Dec 09 11:21:30 2010 +0100
@@ -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);
diff -r 0c97247c64d6 -r df32f4ed405a tools/libxl/libxl_utils.h
--- a/tools/libxl/libxl_utils.h	Thu Dec 09 08:34:59 2010 +0000
+++ b/tools/libxl/libxl_utils.h	Thu Dec 09 11:21:30 2010 +0100
@@ -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
 
diff -r 0c97247c64d6 -r df32f4ed405a tools/python/xen/lowlevel/xl/xl.c
--- a/tools/python/xen/lowlevel/xl/xl.c	Thu Dec 09 08:34:59 2010 +0000
+++ b/tools/python/xen/lowlevel/xl/xl.c	Thu Dec 09 11:21:30 2010 +0100
@@ -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)

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2 of 5] support topolgy info in xl info
  2010-12-09 10:51 [PATCH 0 of 5] support of NUMA topology in xl Juergen Gross
  2010-12-09 10:51 ` [PATCH 1 of 5] Support getting topology info in libxl Juergen Gross
@ 2010-12-09 10:51 ` Juergen Gross
  2010-12-09 10:51 ` [PATCH 3 of 5] Extend cpupools to support numa Juergen Gross
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Juergen Gross @ 2010-12-09 10:51 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

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: juergen.gross@ts.fujitsu.com


2 files changed, 50 insertions(+), 11 deletions(-)
tools/libxl/xl_cmdimpl.c  |   59 +++++++++++++++++++++++++++++++++++++--------
tools/libxl/xl_cmdtable.c |    2 -



[-- Attachment #2: xen-work-5.patch --]
[-- Type: text/x-patch, Size: 3005 bytes --]

# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# 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: juergen.gross@ts.fujitsu.com

diff -r df32f4ed405a -r 0edc47775eaa tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Dec 09 11:21:30 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Thu Dec 09 11:23:20 2010 +0100
@@ -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;
 }
 
diff -r df32f4ed405a -r 0edc47775eaa tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Thu Dec 09 11:21:30 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c	Thu Dec 09 11:23:20 2010 +0100
@@ -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,

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3 of 5] Extend cpupools to support numa
  2010-12-09 10:51 [PATCH 0 of 5] support of NUMA topology in xl Juergen Gross
  2010-12-09 10:51 ` [PATCH 1 of 5] Support getting topology info in libxl Juergen Gross
  2010-12-09 10:51 ` [PATCH 2 of 5] support topolgy info in xl info Juergen Gross
@ 2010-12-09 10:51 ` Juergen Gross
  2010-12-09 10:51 ` [PATCH 4 of 5] Support renaming of cpupools Juergen Gross
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Juergen Gross @ 2010-12-09 10:51 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1081 bytes --]

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: juergen.gross@ts.fujitsu.com


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 +-



[-- Attachment #2: xen-work-5.patch --]
[-- Type: text/x-patch, Size: 9259 bytes --]

# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# 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: juergen.gross@ts.fujitsu.com

diff -r 0edc47775eaa -r b979d430eab7 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Thu Dec 09 11:23:20 2010 +0100
+++ b/tools/libxl/libxl.c	Thu Dec 09 11:26:37 2010 +0100
@@ -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)
diff -r 0edc47775eaa -r b979d430eab7 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Thu Dec 09 11:23:20 2010 +0100
+++ b/tools/libxl/libxl.h	Thu Dec 09 11:26:37 2010 +0100
@@ -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 */
diff -r 0edc47775eaa -r b979d430eab7 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Dec 09 11:23:20 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Thu Dec 09 11:26:37 2010 +0100
@@ -5402,10 +5402,12 @@ int main_cpupoolcreate(int argc, char **
     uint32_t poolid;
     int schedid = -1;
     XLU_ConfigList *cpus;
-    int n_cpus, i, n;
+    XLU_ConfigList *nodes;
+    int n_cpus, n_nodes, i, n;
     libxl_cpumap freemap;
     libxl_cpumap cpumap;
     libxl_uuid uuid;
+    libxl_topologyinfo topology;
 
     while (1) {
         opt = getopt_long(argc, argv, "hnf:", long_options, &option_index);
@@ -5514,7 +5516,32 @@ int main_cpupoolcreate(int argc, char **
         fprintf(stderr, "Failed to allocate cpumap\n");
         return -ERROR_FAIL;
     }
-    if (!xlu_cfg_get_list(config, "cpus", &cpus, 0, 0)) {
+    if (!xlu_cfg_get_list(config, "nodes", &nodes, 0, 0)) {
+        n_cpus = 0;
+        n_nodes = 0;
+        if (libxl_get_topologyinfo(&ctx, &topology)) {
+            fprintf(stderr, "libxl_get_topologyinfo failed\n");
+            return -ERROR_FAIL;
+        }
+        while ((buf = xlu_cfg_get_listitem(nodes, n_nodes)) != NULL) {
+            n = atoi(buf);
+            for (i = 0; i < topology.nodemap.entries; i++) {
+                if ((topology.nodemap.array[i] == n) &&
+                    libxl_cpumap_test(&freemap, i)) {
+                    libxl_cpumap_set(&cpumap, i);
+                    n_cpus++;
+                }
+            }
+            n_nodes++;
+        }
+
+        libxl_topologyinfo_destroy(&topology);
+
+        if (n_cpus == 0) {
+            fprintf(stderr, "no free cpu found\n");
+            return -ERROR_FAIL;
+        }
+    } else if (!xlu_cfg_get_list(config, "cpus", &cpus, 0, 0)) {
         n_cpus = 0;
         while ((buf = xlu_cfg_get_listitem(cpus, n_cpus)) != NULL) {
             i = atoi(buf);
@@ -5698,6 +5725,8 @@ int main_cpupoolcpuadd(int argc, char **
     const char *pool;
     uint32_t poolid;
     int cpu;
+    int node;
+    int n;
 
     while ((opt = getopt(argc, argv, "h")) != -1) {
         switch (opt) {
@@ -5722,7 +5751,13 @@ int main_cpupoolcpuadd(int argc, char **
         help("cpupool-cpu-add");
         return -ERROR_FAIL;
     }
-    cpu = atoi(argv[optind]);
+    node = -1;
+    cpu = -1;
+    if (strncmp(argv[optind], "node:", 5) == 0) {
+        node = atoi(argv[optind] + 5);
+    } else {
+        cpu = atoi(argv[optind]);
+    }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
         !libxl_cpupoolid_to_name(&ctx, poolid)) {
@@ -5730,7 +5765,21 @@ int main_cpupoolcpuadd(int argc, char **
         return -ERROR_FAIL;
     }
 
-    return -libxl_cpupool_cpuadd(&ctx, poolid, cpu);
+    if (cpu >= 0) {
+        return -libxl_cpupool_cpuadd(&ctx, poolid, cpu);
+    }
+
+    if (libxl_cpupool_cpuadd_node(&ctx, poolid, node, &n)) {
+        fprintf(stderr, "libxl_cpupool_cpuadd_node failed\n");
+        return -ERROR_FAIL;
+    }
+
+    if (n > 0) {
+        return 0;
+    }
+
+    fprintf(stderr, "no free cpu found\n");
+    return -ERROR_FAIL;
 }
 
 int main_cpupoolcpuremove(int argc, char **argv)
@@ -5739,6 +5788,8 @@ int main_cpupoolcpuremove(int argc, char
     const char *pool;
     uint32_t poolid;
     int cpu;
+    int node;
+    int n;
 
     while ((opt = getopt(argc, argv, "h")) != -1) {
         switch (opt) {
@@ -5763,7 +5814,13 @@ int main_cpupoolcpuremove(int argc, char
         help("cpupool-cpu-remove");
         return -ERROR_FAIL;
     }
-    cpu = atoi(argv[optind]);
+    node = -1;
+    cpu = -1;
+    if (strncmp(argv[optind], "node:", 5) == 0) {
+        node = atoi(argv[optind] + 5);
+    } else {
+        cpu = atoi(argv[optind]);
+    }
 
     if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
         !libxl_cpupoolid_to_name(&ctx, poolid)) {
@@ -5771,7 +5828,21 @@ int main_cpupoolcpuremove(int argc, char
         return -ERROR_FAIL;
     }
 
-    return -libxl_cpupool_cpuremove(&ctx, poolid, cpu);
+    if (cpu >= 0) {
+        return -libxl_cpupool_cpuremove(&ctx, poolid, cpu);
+    }
+
+    if (libxl_cpupool_cpuremove_node(&ctx, poolid, node, &n)) {
+        fprintf(stderr, "libxl_cpupool_cpuremove_node failed\n");
+        return -ERROR_FAIL;
+    }
+
+    if (n == 0) {
+        fprintf(stderr, "no cpu of node found in cpupool\n");
+        return -ERROR_FAIL;
+    }
+
+    return 0;
 }
 
 int main_cpupoolmigrate(int argc, char **argv)
diff -r 0edc47775eaa -r b979d430eab7 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Thu Dec 09 11:23:20 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c	Thu Dec 09 11:26:37 2010 +0100
@@ -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,

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 4 of 5] Support renaming of cpupools
  2010-12-09 10:51 [PATCH 0 of 5] support of NUMA topology in xl Juergen Gross
                   ` (2 preceding siblings ...)
  2010-12-09 10:51 ` [PATCH 3 of 5] Extend cpupools to support numa Juergen Gross
@ 2010-12-09 10:51 ` Juergen Gross
  2010-12-09 12:25   ` Ian Campbell
  2010-12-09 10:51 ` [PATCH 5 of 5] Support new xl command cpupool-numa-split Juergen Gross
  2010-12-09 12:29 ` [PATCH 0 of 5] support of NUMA topology in xl Ian Campbell
  5 siblings, 1 reply; 10+ messages in thread
From: Juergen Gross @ 2010-12-09 10:51 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 517 bytes --]

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

Signed-off-by: juergen.gross@ts.fujitsu.com


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 +++++



[-- Attachment #2: xen-work-5.patch --]
[-- Type: text/x-patch, Size: 5303 bytes --]

# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# 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: juergen.gross@ts.fujitsu.com

diff -r b979d430eab7 -r fc3f33c7faa7 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Thu Dec 09 11:26:37 2010 +0100
+++ b/tools/libxl/libxl.c	Thu Dec 09 11:29:25 2010 +0100
@@ -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;
diff -r b979d430eab7 -r fc3f33c7faa7 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Thu Dec 09 11:26:37 2010 +0100
+++ b/tools/libxl/libxl.h	Thu Dec 09 11:29:25 2010 +0100
@@ -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);
diff -r b979d430eab7 -r fc3f33c7faa7 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c	Thu Dec 09 11:26:37 2010 +0100
+++ b/tools/libxl/libxl_utils.c	Thu Dec 09 11:29:25 2010 +0100
@@ -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;
 }
 
diff -r b979d430eab7 -r fc3f33c7faa7 tools/libxl/xl.h
--- a/tools/libxl/xl.h	Thu Dec 09 11:26:37 2010 +0100
+++ b/tools/libxl/xl.h	Thu Dec 09 11:29:25 2010 +0100
@@ -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);
diff -r b979d430eab7 -r fc3f33c7faa7 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Dec 09 11:26:37 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Thu Dec 09 11:29:25 2010 +0100
@@ -5719,6 +5719,47 @@ int main_cpupooldestroy(int argc, char *
     return -libxl_destroy_cpupool(&ctx, poolid);
 }
 
+int main_cpupoolrename(int argc, char **argv)
+{
+    int opt;
+    const char *pool;
+    const char *new_name;
+    uint32_t poolid;
+
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("cpupool-rename");
+            return 0;
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    pool = argv[optind++];
+    if (!pool || !argv[optind]) {
+        fprintf(stderr, "'xl cpupool-rename' requires 2 arguments.\n\n");
+        help("cpupool-rename");
+        return 1;
+    }
+
+    if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
+        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
+        return -ERROR_FAIL;
+    }
+
+    new_name = argv[optind];
+
+    if (libxl_cpupool_rename(&ctx, new_name, poolid)) {
+        fprintf(stderr, "Can't rename cpupool '%s'.\n", pool);
+        return 1;
+    }
+
+    return 0;
+}
+
 int main_cpupoolcpuadd(int argc, char **argv)
 {
     int opt;
diff -r b979d430eab7 -r fc3f33c7faa7 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Thu Dec 09 11:26:37 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c	Thu Dec 09 11:29:25 2010 +0100
@@ -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",

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 5 of 5] Support new xl command cpupool-numa-split
  2010-12-09 10:51 [PATCH 0 of 5] support of NUMA topology in xl Juergen Gross
                   ` (3 preceding siblings ...)
  2010-12-09 10:51 ` [PATCH 4 of 5] Support renaming of cpupools Juergen Gross
@ 2010-12-09 10:51 ` Juergen Gross
  2010-12-09 12:29 ` [PATCH 0 of 5] support of NUMA topology in xl Ian Campbell
  5 siblings, 0 replies; 10+ messages in thread
From: Juergen Gross @ 2010-12-09 10:51 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 449 bytes --]

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: juergen.gross@ts.fujitsu.com


3 files changed, 123 insertions(+)
tools/libxl/xl.h          |    1 
tools/libxl/xl_cmdimpl.c  |  117 +++++++++++++++++++++++++++++++++++++++++++++
tools/libxl/xl_cmdtable.c |    5 +



[-- Attachment #2: xen-work-5.patch --]
[-- Type: text/x-patch, Size: 5162 bytes --]

# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# 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: juergen.gross@ts.fujitsu.com

diff -r fc3f33c7faa7 -r 040a84d0b4c2 tools/libxl/xl.h
--- a/tools/libxl/xl.h	Thu Dec 09 11:29:25 2010 +0100
+++ b/tools/libxl/xl.h	Thu Dec 09 11:50:53 2010 +0100
@@ -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);
 
diff -r fc3f33c7faa7 -r 040a84d0b4c2 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Dec 09 11:29:25 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Thu Dec 09 11:50:53 2010 +0100
@@ -5933,3 +5933,120 @@ int main_cpupoolmigrate(int argc, char *
 
     return -libxl_cpupool_movedomain(&ctx, poolid, domid);
 }
+
+int main_cpupoolnumasplit(int argc, char **argv)
+{
+    int ret;
+    int opt;
+    int p;
+    int c;
+    int n;
+    uint32_t poolid;
+    int schedid;
+    int n_pools;
+    int node;
+    char name[16];
+    libxl_uuid uuid;
+    libxl_cpumap cpumap;
+    libxl_cpupoolinfo *poolinfo;
+    libxl_topologyinfo topology;
+
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("cpupool-numa-split");
+            return 0;
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+    ret = 0;
+
+    poolinfo = libxl_list_cpupool(&ctx, &n_pools);
+    if (!poolinfo) {
+        fprintf(stderr, "error getting cpupool info\n");
+        return -ERROR_NOMEM;
+    }
+    poolid = poolinfo[0].poolid;
+    schedid = poolinfo[0].sched_id;
+    for (p = 0; p < n_pools; p++) {
+        libxl_cpupoolinfo_destroy(poolinfo + p);
+    }
+    if (n_pools > 1) {
+        fprintf(stderr, "splitting not possible, already cpupools in use\n");
+        return -ERROR_FAIL;
+    }
+
+    if (libxl_get_topologyinfo(&ctx, &topology)) {
+        fprintf(stderr, "libxl_get_topologyinfo failed\n");
+        return -ERROR_FAIL;
+    }
+
+    if (libxl_cpumap_alloc(&ctx, &cpumap)) {
+        fprintf(stderr, "Failed to allocate cpumap\n");
+        libxl_topologyinfo_destroy(&topology);
+        return -ERROR_FAIL;
+    }
+
+    /* Reset Pool-0 to 1st node: first add cpus, then remove cpus to avoid
+       a cpupool without cpus in between */
+
+    node = topology.nodemap.array[0];
+    if (libxl_cpupool_cpuadd_node(&ctx, 0, node, &n)) {
+        fprintf(stderr, "error on adding cpu to Pool 0\n");
+        return -ERROR_FAIL;
+    }
+
+    snprintf(name, 15, "Pool-node%d", node);
+    ret = -libxl_cpupool_rename(&ctx, name, 0);
+    if (ret) {
+        fprintf(stderr, "error on renaming Pool 0\n");
+        goto out;
+    }
+
+    for (c = 0; c < topology.nodemap.entries; c++) {
+        if (topology.nodemap.array[c] == node) {
+            topology.nodemap.array[c] = LIBXL_CPUARRAY_INVALID_ENTRY;
+        }
+    }
+
+    for (c = 0; c < topology.nodemap.entries; c++) {
+        if (topology.nodemap.array[c] == LIBXL_CPUARRAY_INVALID_ENTRY) {
+            continue;
+        }
+
+        node = topology.nodemap.array[c];
+        ret = -libxl_cpupool_cpuremove_node(&ctx, 0, node, &n);
+        if (ret) {
+            fprintf(stderr, "error on removing cpu from Pool 0\n");
+            goto out;
+        }
+
+        snprintf(name, 15, "Pool-node%d", node);
+        libxl_uuid_generate(&uuid);
+        ret = -libxl_create_cpupool(&ctx, name, schedid, cpumap, &uuid, &poolid);
+        if (ret) {
+            fprintf(stderr, "error on creating cpupool\n");
+            goto out;
+        }
+
+        ret = -libxl_cpupool_cpuadd_node(&ctx, 0, node, &n);
+        if (ret) {
+            fprintf(stderr, "error on adding cpus to cpupool\n");
+            goto out;
+        }
+
+        for (p = c; p < topology.nodemap.entries; p++) {
+            if (topology.nodemap.array[p] == node) {
+                topology.nodemap.array[p] = LIBXL_CPUARRAY_INVALID_ENTRY;
+            }
+        }
+    }
+
+out:
+    libxl_topologyinfo_destroy(&topology);
+    libxl_cpumap_destroy(&cpumap);
+
+    return ret;
+}
diff -r fc3f33c7faa7 -r 040a84d0b4c2 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Thu Dec 09 11:29:25 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c	Thu Dec 09 11:50:53 2010 +0100
@@ -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);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 4 of 5] Support renaming of cpupools
  2010-12-09 10:51 ` [PATCH 4 of 5] Support renaming of cpupools Juergen Gross
@ 2010-12-09 12:25   ` Ian Campbell
  0 siblings, 0 replies; 10+ messages in thread
From: Ian Campbell @ 2010-12-09 12:25 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel@lists.xensource.com

On Thu, 2010-12-09 at 10:51 +0000, Juergen Gross wrote:
> 
> diff -r b979d430eab7 -r fc3f33c7faa7 tools/libxl/libxl.c
> --- a/tools/libxl/libxl.c       Thu Dec 09 11:26:37 2010 +0100
> +++ b/tools/libxl/libxl.c       Thu Dec 09 11:29:25 2010 +0100
> @@ -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);

You need:
	libxl__free_all(&gc);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0 of 5] support of NUMA topology in xl
  2010-12-09 10:51 [PATCH 0 of 5] support of NUMA topology in xl Juergen Gross
                   ` (4 preceding siblings ...)
  2010-12-09 10:51 ` [PATCH 5 of 5] Support new xl command cpupool-numa-split Juergen Gross
@ 2010-12-09 12:29 ` Ian Campbell
  5 siblings, 0 replies; 10+ messages in thread
From: Ian Campbell @ 2010-12-09 12:29 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel@lists.xensource.com

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:

Acked-by: Ian Campbell <ian.campbell@citrix.com>

Thanks!

On Thu, 2010-12-09 at 10:51 +0000, Juergen Gross wrote:
> 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
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 4 of 5] Support renaming of cpupools
  2010-12-09 12:39 Juergen Gross
@ 2010-12-09 12:39 ` Juergen Gross
  0 siblings, 0 replies; 10+ messages in thread
From: Juergen Gross @ 2010-12-09 12:39 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 520 bytes --]

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

Signed-off-by: juergen.gross@ts.fujitsu.com


6 files changed, 93 insertions(+), 2 deletions(-)
tools/libxl/libxl.c       |   43 +++++++++++++++++++++++++++++++++++++++++++
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 +++++



[-- Attachment #2: xen-work-5.patch --]
[-- Type: text/x-patch, Size: 5370 bytes --]

# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# Date 1291898252 -3600
# Node ID 0a2df9e227c678d3dfcd04b19925ced8714a2524
# Parent  34367a3d42f7f8145bdc74c464f6822144aeab70
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: juergen.gross@ts.fujitsu.com

diff -r 34367a3d42f7 -r 0a2df9e227c6 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Thu Dec 09 11:26:37 2010 +0100
+++ b/tools/libxl/libxl.c	Thu Dec 09 13:37:32 2010 +0100
@@ -3809,6 +3809,49 @@ 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) {
+        libxl__free_all(&gc);
+        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);
+    libxl__free_all(&gc);
+
+    return rc;
+}
+
 int libxl_cpupool_cpuadd(libxl_ctx *ctx, uint32_t poolid, int cpu)
 {
     int rc;
diff -r 34367a3d42f7 -r 0a2df9e227c6 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Thu Dec 09 11:26:37 2010 +0100
+++ b/tools/libxl/libxl.h	Thu Dec 09 13:37:32 2010 +0100
@@ -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);
diff -r 34367a3d42f7 -r 0a2df9e227c6 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c	Thu Dec 09 11:26:37 2010 +0100
+++ b/tools/libxl/libxl_utils.c	Thu Dec 09 13:37:32 2010 +0100
@@ -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;
 }
 
diff -r 34367a3d42f7 -r 0a2df9e227c6 tools/libxl/xl.h
--- a/tools/libxl/xl.h	Thu Dec 09 11:26:37 2010 +0100
+++ b/tools/libxl/xl.h	Thu Dec 09 13:37:32 2010 +0100
@@ -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);
diff -r 34367a3d42f7 -r 0a2df9e227c6 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Dec 09 11:26:37 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Thu Dec 09 13:37:32 2010 +0100
@@ -5719,6 +5719,47 @@ int main_cpupooldestroy(int argc, char *
     return -libxl_destroy_cpupool(&ctx, poolid);
 }
 
+int main_cpupoolrename(int argc, char **argv)
+{
+    int opt;
+    const char *pool;
+    const char *new_name;
+    uint32_t poolid;
+
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("cpupool-rename");
+            return 0;
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    pool = argv[optind++];
+    if (!pool || !argv[optind]) {
+        fprintf(stderr, "'xl cpupool-rename' requires 2 arguments.\n\n");
+        help("cpupool-rename");
+        return 1;
+    }
+
+    if (cpupool_qualifier_to_cpupoolid(pool, &poolid, NULL) ||
+        !libxl_cpupoolid_to_name(&ctx, poolid)) {
+        fprintf(stderr, "unknown cpupool \'%s\'\n", pool);
+        return -ERROR_FAIL;
+    }
+
+    new_name = argv[optind];
+
+    if (libxl_cpupool_rename(&ctx, new_name, poolid)) {
+        fprintf(stderr, "Can't rename cpupool '%s'.\n", pool);
+        return 1;
+    }
+
+    return 0;
+}
+
 int main_cpupoolcpuadd(int argc, char **argv)
 {
     int opt;
diff -r 34367a3d42f7 -r 0a2df9e227c6 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c	Thu Dec 09 11:26:37 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c	Thu Dec 09 13:37:32 2010 +0100
@@ -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",

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1 of 5] Support getting topology info in libxl
  2010-12-09 10:51 ` [PATCH 1 of 5] Support getting topology info in libxl Juergen Gross
@ 2010-12-23 16:02   ` Ian Jackson
  0 siblings, 0 replies; 10+ messages in thread
From: Ian Jackson @ 2010-12-23 16:02 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel, Gianni Tedesco

Juergen Gross writes ("[Xen-devel] [PATCH 1 of 5] Support getting topology info in libxl"):
> 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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-12-23 16:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-09 10:51 [PATCH 0 of 5] support of NUMA topology in xl Juergen Gross
2010-12-09 10:51 ` [PATCH 1 of 5] Support getting topology info in libxl Juergen Gross
2010-12-23 16:02   ` Ian Jackson
2010-12-09 10:51 ` [PATCH 2 of 5] support topolgy info in xl info Juergen Gross
2010-12-09 10:51 ` [PATCH 3 of 5] Extend cpupools to support numa Juergen Gross
2010-12-09 10:51 ` [PATCH 4 of 5] Support renaming of cpupools Juergen Gross
2010-12-09 12:25   ` Ian Campbell
2010-12-09 10:51 ` [PATCH 5 of 5] Support new xl command cpupool-numa-split Juergen Gross
2010-12-09 12:29 ` [PATCH 0 of 5] support of NUMA topology in xl Ian Campbell
  -- strict thread matches above, loose matches on Subject: below --
2010-12-09 12:39 Juergen Gross
2010-12-09 12:39 ` [PATCH 4 of 5] Support renaming of cpupools Juergen Gross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).