All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] correct xl cpupool-create with extra parameters
@ 2011-02-14  9:27 Juergen Gross
  2011-02-14 16:55 ` Ian Jackson
  0 siblings, 1 reply; 2+ messages in thread
From: Juergen Gross @ 2011-02-14  9:27 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 297 bytes --]

xl cpupool-create won't take always extra parameters specified on the command
line, as a 0-byte is missing at the end of the configuration file contents.

Signed-off-by: juergen.gross@ts.fujitsu.com


1 file changed, 6 insertions(+), 7 deletions(-)
tools/libxl/xl_cmdimpl.c |   13 ++++++-------



[-- Attachment #2: xen-work.patch --]
[-- Type: text/x-patch, Size: 2350 bytes --]

# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# Date 1297675603 -3600
# Node ID 78995dd5b66b193954124bf3ed49931617680cef
# Parent  67f2fed570346155d615327f4c1bd1099f155fbd
correct xl cpupool-create with extra parameters

xl cpupool-create won't take always extra parameters specified on the command
line, as a 0-byte is missing at the end of the configuration file contents.

Signed-off-by: juergen.gross@ts.fujitsu.com

diff -r 67f2fed57034 -r 78995dd5b66b tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Fri Feb 11 18:22:37 2011 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Mon Feb 14 10:26:43 2011 +0100
@@ -5204,7 +5204,7 @@ int main_cpupoolcreate(int argc, char **
         {0, 0, 0, 0}
     };
     int ret;
-    void *config_data = 0;
+    char *config_data = 0;
     int config_len = 0;
     XLU_Config *config;
     const char *buf;
@@ -5244,9 +5244,8 @@ int main_cpupoolcreate(int argc, char **
     memset(extra_config, 0, sizeof(extra_config));
     while (optind < argc) {
         if ((p = strchr(argv[optind], '='))) {
-            if (strlen(extra_config) + 1 < sizeof(extra_config)) {
-                if (strlen(extra_config))
-                    strcat(extra_config, "\n");
+            if (strlen(extra_config) + 1 + strlen(argv[optind]) < sizeof(extra_config)) {
+                strcat(extra_config, "\n");
                 strcat(extra_config, argv[optind]);
             }
         } else if (!filename) {
@@ -5263,7 +5262,7 @@ int main_cpupoolcreate(int argc, char **
         return -ERROR_FAIL;
     }
 
-    if (libxl_read_file_contents(&ctx, filename, &config_data, &config_len)) {
+    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;
@@ -5279,10 +5278,10 @@ int main_cpupoolcreate(int argc, char **
             fprintf(stderr, "Failed to realloc config_data\n");
             return -ERROR_FAIL;
         }
-        strcat(config_data, "\n");
+        config_data[config_len] = 0;
         strcat(config_data, extra_config);
         strcat(config_data, "\n");
-        config_len += (strlen(extra_config) + 2);
+        config_len += strlen(extra_config) + 1;
     }
 
     config = xlu_cfg_init(stderr, filename);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] correct xl cpupool-create with extra parameters
  2011-02-14  9:27 [PATCH] correct xl cpupool-create with extra parameters Juergen Gross
@ 2011-02-14 16:55 ` Ian Jackson
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Jackson @ 2011-02-14 16:55 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel

Juergen Gross writes ("[Xen-devel] [PATCH] correct xl cpupool-create with extra parameters"):
> xl cpupool-create won't take always extra parameters specified on the command
> line, as a 0-byte is missing at the end of the configuration file contents.

Thanks, this looks right to me; I have applied it.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

Having said that, I think this approach (reallocing the config data
buffer and tacking the args on the end) is pretty nasty really.  The
right thing would be probably call xlu_cfg_read* more than once.
Let's not do that now, though.

Ian.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-14 16:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-14  9:27 [PATCH] correct xl cpupool-create with extra parameters Juergen Gross
2011-02-14 16:55 ` Ian Jackson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.