@@ -43,7 +43,9 @@ int main(int argc, char **argv)
int rc;
struct xs_handle *xsh = NULL;
xc_interface *xch = NULL;
- char *domname_string = NULL, *domid_string = NULL;
+ char *domname_string = NULL, *domid_string = NULL, *pool_path, *pool_name;
+ xc_cpupoolinfo_t *xcinfo;
+ unsigned int pool_id = 0;
libxl_uuid uuid;
/* Accept 0 or 1 argument */
@@ -114,6 +116,37 @@ int main(int argc, char **argv)
goto out;
}
+ /* Create an entry in xenstore for each cpupool on the system */
+ do {
+ xcinfo = xc_cpupool_getinfo(xch, pool_id);
+ if (xcinfo != NULL) {
+ if (xcinfo->cpupool_id != pool_id)
+ pool_id = xcinfo->cpupool_id;
+ xc_cpupool_infofree(xch, xcinfo);
+ if (asprintf(&pool_path, "/local/pool/%d/name", pool_id) <= 0) {
+ fprintf(stderr, "cannot allocate memory for pool path\n");
+ rc = 1;
+ goto out;
+ }
+ if (asprintf(&pool_name, "Pool-%d", pool_id) <= 0) {
+ fprintf(stderr, "cannot allocate memory for pool name\n");
+ rc = 1;
+ goto out_err;
+ }
+ pool_id++;
+ if (!xs_write(xsh, XBT_NULL, pool_path, pool_name,
+ strlen(pool_name))) {
+ fprintf(stderr, "cannot set pool name\n");
+ rc = 1;
+ }
+ free(pool_name);
+out_err:
+ free(pool_path);
+ if ( rc )
+ goto out;
+ }
+ } while(xcinfo != NULL);
+
printf("Done setting up Dom0\n");
out:
@@ -151,8 +151,7 @@ char *libxl_cpupoolid_to_name(libxl_ctx *ctx, uint32_t poolid)
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;
}