[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xl: fix memory management of migration_domname_r



# HG changeset patch
# User Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
# Date 1284485115 -3600
# Node ID ed8019e672c653a009a551682e4405adb413fcfe
# Parent  95c90bd63aedb0f38f4899f27ecc9ae8e1fe6011
xl: fix memory management of migration_domname_r

During migration, the domain name from the config file is swapped out
and replaced with a different name (with the "--incoming" suffix),
which we return to the caller.  The memory management arrangements
here were broken.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/xl_cmdimpl.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff -r 95c90bd63aed -r ed8019e672c6 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Tue Sep 14 17:46:21 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Tue Sep 14 18:25:15 2010 +0100
@@ -1209,7 +1209,7 @@ struct domain_create {
     const char *extra_config; /* extra config string */
     const char *restore_file;
     int migrate_fd; /* -1 means none */
-    char **migration_domname_r;
+    char **migration_domname_r; /* from malloc */
 };
 
 static int create_domain(struct domain_create *dom_info)
@@ -1227,7 +1227,6 @@ static int create_domain(struct domain_c
     const char *extra_config = dom_info->extra_config;
     const char *restore_file = dom_info->restore_file;
     int migrate_fd = dom_info->migrate_fd;
-    char **migration_domname_r = dom_info->migration_domname_r;
 
     int i, fd;
     int need_daemon = 1;
@@ -1353,12 +1352,16 @@ static int create_domain(struct domain_c
             /* when we receive a domain we get its name from the config
              * file; and we receive it to a temporary name */
             assert(!common_domname);
+            
             common_domname = d_config.c_info.name;
-            if (asprintf(migration_domname_r, "%s--incoming", 
d_config.c_info.name) < 0) {
+            d_config.c_info.name = 0; /* steals allocation from config */
+
+            if (asprintf(&d_config.c_info.name,
+                         "%s--incoming", d_config.c_info.name) < 0) {
                 fprintf(stderr, "Failed to allocate memory in asprintf\n");
                 exit(1);
             }
-            d_config.c_info.name = *migration_domname_r;
+            *dom_info->migration_domname_r = strdup(d_config.c_info.name);
         }
     }
 

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.