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

[Xen-changelog] [xen-unstable] Support renaming of cpupools

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Support renaming of cpupools
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 24 Dec 2010 15:46:28 -0800
Delivery-date: Fri, 24 Dec 2010 15:50:48 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
# Date 1291898252 -3600
# Node ID 6b0620970c73589efe67741becfdf3d3aab6a918
# Parent  e115ee319a644a8fcbd959c9131d3f74b6961520
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@xxxxxxxxxxxxxx
Signed-off-by: Ian Jackson <ian.jackson.citrix.com>
---
 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 +++++
 6 files changed, 93 insertions(+), 2 deletions(-)

diff -r e115ee319a64 -r 6b0620970c73 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
@@ -3885,6 +3885,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 e115ee319a64 -r 6b0620970c73 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
@@ -528,6 +528,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 e115ee319a64 -r 6b0620970c73 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 e115ee319a64 -r 6b0620970c73 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 e115ee319a64 -r 6b0620970c73 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
@@ -5729,6 +5729,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 e115ee319a64 -r 6b0620970c73 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
@@ -357,6 +357,11 @@ struct cmd_spec cmd_table[] = {
       &main_cpupooldestroy,
       "Deactivates a CPU pool",
       "<CPU Pool>",
+    },
+    { "cpupool-rename",
+      &main_cpupoolrename,
+      "Renames a CPU pool",
+      "<CPU Pool> <new name>",
     },
     { "cpupool-cpu-add",
       &main_cpupoolcpuadd,

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Support renaming of cpupools, Xen patchbot-unstable <=