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

Re: [Xen-devel] [PATCH 2 of 3] support of cpupools in xl: commands and l

To: Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 2 of 3] support of cpupools in xl: commands and library changes
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Tue, 12 Oct 2010 10:56:21 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Tue, 12 Oct 2010 02:57:24 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <91397dcffead19270897.1286536984@nehalem1>
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>
Organization: Citrix Systems, Inc.
References: <91397dcffead19270897.1286536984@nehalem1>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Fri, 2010-10-08 at 12:23 +0100, Juergen Gross wrote:

You need a destructor for the libxl_cpumap type, else you will leak the
->map.

Also you don't need to explicitly specific destructor_fn for
libxl_cpupoolinfo.

Something like the following. (hint: you can usually spot this stuff by
taking a look at the diff of the generated code in
tools/libxl/_libxl_types.[ch]).

Ian.

diff -r 11f243c2d8be tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Fri Oct 08 13:22:37 2010 +0200
+++ b/tools/libxl/libxl.h       Tue Oct 12 10:55:13 2010 +0100
@@ -147,6 +147,7 @@ typedef struct {
     uint32_t size;          /* number of bytes in map */
     uint64_t *map;
 } libxl_cpumap;
+void libxl_cpumap_destroy(libxl_cpumap *map);
 
 typedef enum {
     XENFV = 1,
diff -r 11f243c2d8be tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl     Fri Oct 08 13:22:37 2010 +0200
+++ b/tools/libxl/libxl.idl     Tue Oct 12 10:55:13 2010 +0100
@@ -6,7 +6,7 @@ libxl_ctx = Builtin("ctx")
 libxl_ctx = Builtin("ctx")
 libxl_uuid = Builtin("uuid")
 libxl_mac = Builtin("mac")
-libxl_cpumap = Builtin("cpumap")
+libxl_cpumap = Builtin("cpumap", destructor_fn="libxl_cpumap_destroy", 
passby=PASS_BY_REFERENCE)
 libxl_qemu_machine_type = Number("qemu_machine_type", namespace="libxl_")
 libxl_console_consback = Number("console_consback", namespace="libxl_")
 libxl_console_constype = Number("console_constype", namespace="libxl_")
@@ -49,7 +49,7 @@ libxl_cpupoolinfo = Struct("cpupoolinfo"
     ("sched_id",    uint32),
     ("n_dom",       uint32),
     ("cpumap",      libxl_cpumap)
-    ], destructor_fn="libxl_cpupoolinfo_destroy")
+    ])
 
 libxl_vminfo = Struct("vminfo", [
     ("uuid", libxl_uuid),
diff -r 11f243c2d8be tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Fri Oct 08 13:22:37 2010 +0200
+++ b/tools/libxl/libxl_utils.c Tue Oct 12 10:55:13 2010 +0100
@@ -720,6 +720,11 @@ int libxl_cpumap_alloc(libxl_cpumap *cpu
     return 0;
 }
 
+void libxl_cpumap_destroy(libxl_cpumap *map)
+{
+    free(map->map);
+}
+
 int libxl_cpumap_test(libxl_cpumap *cpumap, int cpu)
 {
     if (cpu >= cpumap->size * 8)



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