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;
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);
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;
}
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);
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;
"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",