From: George Dunlap Subject: [PATCH] [v2] xl: Don't require a config file for cpupools Date: Thu, 5 Apr 2012 15:07:15 +0100 Message-ID: <41ff0907f4a07f1bfa1b.1333634835@kodo2> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com Cc: george.dunlap@eu.citrix.com List-Id: xen-devel@lists.xenproject.org Since the key information can be fairly simply put on the command-line, there's no need to require an actual config file. Also improve the help to cross-reference the xlcpupool.cfg manpage. v2: - Include link and manpage section for xlcpupool.cfg references. - Rewrap man page paragraph. Signed-off-by: George Dunlap diff -r 3d65214aebe4 -r 41ff0907f4a0 docs/man/xl.pod.1 --- a/docs/man/xl.pod.1 Thu Apr 05 14:04:51 2012 +0100 +++ b/docs/man/xl.pod.1 Thu Apr 05 15:01:59 2012 +0100 @@ -873,11 +873,13 @@ Cpu-pools can be specified either by nam =over 4 -=item B [I] I [I ...] +=item B [I] [I] [I ...] -Create a cpu pool based an I. -Variable settings from the I may be altered by specifying new -or additional assignments on the command line. +Create a cpu pool based an config from a I or command-line +parameters. Variable settings from the I may be altered +by specifying new or additional assignments on the command line. + +See the L manpage for more information. B diff -r 3d65214aebe4 -r 41ff0907f4a0 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Thu Apr 05 14:04:51 2012 +0100 +++ b/tools/libxl/xl_cmdimpl.c Thu Apr 05 15:01:59 2012 +0100 @@ -5556,7 +5556,7 @@ int main_tmem_freeable(int argc, char ** int main_cpupoolcreate(int argc, char **argv) { - const char *filename = NULL; + const char *filename = NULL, *config_src=NULL; const char *p; char extra_config[1024]; int opt; @@ -5620,23 +5620,26 @@ int main_cpupoolcreate(int argc, char ** optind++; } - if (!filename) { - help("cpupool-create"); - return -ERROR_FAIL; - } - - if (libxl_read_file_contents(ctx, filename, (void **)&config_data, &config_len)) { - fprintf(stderr, "Failed to read config file: %s: %s\n", - filename, strerror(errno)); - return -ERROR_FAIL; - } + if (filename) + { + if (libxl_read_file_contents(ctx, filename, (void **)&config_data, + &config_len)) { + fprintf(stderr, "Failed to read config file: %s: %s\n", + filename, strerror(errno)); + return -ERROR_FAIL; + } + config_src=filename; + } + else + config_src="command line"; + if (strlen(extra_config)) { if (config_len > INT_MAX - (strlen(extra_config) + 2)) { fprintf(stderr, "Failed to attach extra configration\n"); return -ERROR_FAIL; } config_data = xrealloc(config_data, - config_len + strlen(extra_config) + 2); + config_len + strlen(extra_config) + 2); if (!config_data) { fprintf(stderr, "Failed to realloc config_data\n"); return -ERROR_FAIL; @@ -5647,7 +5650,7 @@ int main_cpupoolcreate(int argc, char ** config_len += strlen(extra_config) + 1; } - config = xlu_cfg_init(stderr, filename); + config = xlu_cfg_init(stderr, config_src); if (!config) { fprintf(stderr, "Failed to allocate for configuration\n"); return -ERROR_FAIL; @@ -5661,8 +5664,12 @@ int main_cpupoolcreate(int argc, char ** if (!xlu_cfg_get_string (config, "name", &buf, 0)) name = strdup(buf); - else + else if (filename) name = libxl_basename(filename); + else { + fprintf(stderr, "Missing cpupool name!\n"); + return -ERROR_FAIL; + } if (!libxl_name_to_cpupoolid(ctx, name, &poolid)) { fprintf(stderr, "Pool name \"%s\" already exists\n", name); return -ERROR_FAIL; @@ -5744,7 +5751,7 @@ int main_cpupoolcreate(int argc, char ** libxl_uuid_generate(&uuid); - printf("Using config file \"%s\"\n", filename); + printf("Using config file \"%s\"\n", config_src); printf("cpupool name: %s\n", name); printf("scheduler: %s\n", libxl_scheduler_to_string(sched)); printf("number of cpus: %d\n", n_cpus); diff -r 3d65214aebe4 -r 41ff0907f4a0 tools/libxl/xl_cmdtable.c --- a/tools/libxl/xl_cmdtable.c Thu Apr 05 14:04:51 2012 +0100 +++ b/tools/libxl/xl_cmdtable.c Thu Apr 05 15:01:59 2012 +0100 @@ -373,12 +373,14 @@ struct cmd_spec cmd_table[] = { }, { "cpupool-create", &main_cpupoolcreate, 1, - "Create a CPU pool based an ConfigFile", - "[options] [vars]", + "Create a new CPU pool", + "[options] [] [Variable=value ...]", "-h, --help Print this help.\n" "-f FILE, --defconfig=FILE Use the given configuration file.\n" "-n, --dryrun Dry run - prints the resulting configuration.\n" - " (deprecated in favour of global -N option)." + " (deprecated in favour of global -N option).\n" + "\nSee the xlcpupool.cfg(5) manpage for more information.", + }, { "cpupool-list", &main_cpupoollist, 0,