From: Juergen Gross <juergen.gross@ts.fujitsu.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH 4 of 5] Support renaming of cpupools
Date: Thu, 09 Dec 2010 11:51:24 +0100 [thread overview]
Message-ID: <fc3f33c7faa7f94c844a.1291891884@nehalem1> (raw)
In-Reply-To: <patchbomb.1291891880@nehalem1>
[-- 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
next prev parent reply other threads:[~2010-12-09 10:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Juergen Gross [this message]
2010-12-09 12:25 ` [PATCH 4 of 5] Support renaming of cpupools 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fc3f33c7faa7f94c844a.1291891884@nehalem1 \
--to=juergen.gross@ts.fujitsu.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).