xl: Allow use of /dev/null with xl create to enable command-line definition
authorW. Michael Petullo <mike@flyn.org>
Wed, 4 Jul 2012 14:46:15 +0000 (15:46 +0100)
committerW. Michael Petullo <mike@flyn.org>
Wed, 4 Jul 2012 14:46:15 +0000 (15:46 +0100)
xm allows specifying /dev/null as the domain configuration argument to its
create option; add same functionality to xl. xl treats the configuration
argument /dev/null as a special case.  This allows specifying an entire
domain configuration on the command line.

Signed-off-by: W. Michael Petullo <mike@flyn.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- ported to xen-unstable from 4.1 ]
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/xl_cmdimpl.c

index 155d1839c78cf512ee769b55bd0705da845cd1d0..6fef819a42ce4b01cadddcf5ee9c42767288a0bd 100644 (file)
@@ -1697,10 +1697,15 @@ static int create_domain(struct domain_create *dom_info)
 
     if (config_file) {
         free(config_data);  config_data = 0;
-        ret = libxl_read_file_contents(ctx, config_file,
-                                       &config_data, &config_len);
-        if (ret) { fprintf(stderr, "Failed to read config file: %s: %s\n",
-                           config_file, strerror(errno)); return ERROR_FAIL; }
+        /* /dev/null represents special case (read config. from command line) */
+        if (!strcmp(config_file, "/dev/null")) {
+            config_len = 0;
+        } else {
+            ret = libxl_read_file_contents(ctx, config_file,
+                                           &config_data, &config_len);
+            if (ret) { fprintf(stderr, "Failed to read config file: %s: %s\n",
+                               config_file, strerror(errno)); return ERROR_FAIL; }
+        }
         if (!restoring && extra_config && strlen(extra_config)) {
             if (config_len > INT_MAX - (strlen(extra_config) + 2 + 1)) {
                 fprintf(stderr, "Failed to attach extra configration\n");