WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xl: fix memory management of migration_domname_r

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xl: fix memory management of migration_domname_r
From: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Date: Tue, 14 Sep 2010 15:14:32 +0100
Delivery-date: Tue, 14 Sep 2010 07:15:51 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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>

diff -r 65010d314adb tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Mon Sep 13 17:48:19 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Tue Sep 14 15:11:48 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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] xl: fix memory management of migration_domname_r, Ian Jackson <=