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

[Xen-devel] [PATCH 1 of 2] libxl: add libxl_device_<type>_list_free helpers



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1344326374 -3600
# Node ID 0a67d3147a174a26dda2e268ca801e56a9c5b711
# Parent  a7ad22e5525831dd491d7ee1fe538b7543404ac7
libxl: add libxl_device_<type>_list_free helpers

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r a7ad22e55258 -r 0a67d3147a17 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Aug 06 12:31:02 2012 +0100
+++ b/tools/libxl/libxl.c       Tue Aug 07 08:59:34 2012 +0100
@@ -2090,6 +2090,14 @@ out_err:
     return NULL;
 }
 
+void libxl_device_disk_list_free(libxl_device_disk *list, int nr)
+{
+    int i;
+    for (i = 0; i < nr; i++)
+        libxl_device_disk_dispose(&list[i]);
+    free(list);
+}
+
 int libxl_device_disk_getinfo(libxl_ctx *ctx, uint32_t domid,
                               libxl_device_disk *disk, libxl_diskinfo 
*diskinfo)
 {
@@ -2759,6 +2767,14 @@ out_err:
     return NULL;
 }
 
+void libxl_device_nic_list_free(libxl_device_nic *list, int nr)
+{
+    int i;
+    for (i = 0; i < nr; i++)
+        libxl_device_nic_dispose(&list[i]);
+    free(list);
+}
+
 int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t domid,
                               libxl_device_nic *nic, libxl_nicinfo *nicinfo)
 {
diff -r a7ad22e55258 -r 0a67d3147a17 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Mon Aug 06 12:31:02 2012 +0100
+++ b/tools/libxl/libxl.h       Tue Aug 07 08:59:34 2012 +0100
@@ -668,6 +668,11 @@ void libxl_vcpuinfo_list_free(libxl_vcpu
  *   Initialises info with details of the given device which must be
  *   attached to the specified domain.
  *
+ * libxl_device_<type>_list_free(*devs, int nr_dev):
+ *
+ *   Dispose nr_dev elements of the array devs and then free the array
+ *   itself.
+ *
  * Creation / Control
  * ------------------
  *
@@ -714,6 +719,8 @@ int libxl_device_disk_destroy(libxl_ctx 
                               LIBXL_EXTERNAL_CALLERS_ONLY;
 
 libxl_device_disk *libxl_device_disk_list(libxl_ctx *ctx, uint32_t domid, int 
*num);
+void libxl_device_disk_list_free(libxl_device_disk *disks, int nr_disks);
+
 int libxl_device_disk_getinfo(libxl_ctx *ctx, uint32_t domid,
                               libxl_device_disk *disk, libxl_diskinfo 
*diskinfo);
 
@@ -739,6 +746,7 @@ int libxl_device_nic_destroy(libxl_ctx *
                              LIBXL_EXTERNAL_CALLERS_ONLY;
 
 libxl_device_nic *libxl_device_nic_list(libxl_ctx *ctx, uint32_t domid, int 
*num);
+void libxl_device_nic_list_free(libxl_device_nic *nics, int nr_nics);
 int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t domid,
                               libxl_device_nic *nic, libxl_nicinfo *nicinfo);
 
@@ -784,6 +792,7 @@ int libxl_device_pci_destroy(libxl_ctx *
 
 libxl_device_pci *libxl_device_pci_list(libxl_ctx *ctx, uint32_t domid,
                                         int *num);
+void libxl_device_pci_list_free(libxl_device_pci *pcis, int nr_pcis);
 
 /*
  * Functions related to making devices assignable -- that is, bound to
diff -r a7ad22e55258 -r 0a67d3147a17 tools/libxl/libxl_pci.c
--- a/tools/libxl/libxl_pci.c   Mon Aug 06 12:31:02 2012 +0100
+++ b/tools/libxl/libxl_pci.c   Tue Aug 07 08:59:34 2012 +0100
@@ -1406,6 +1406,14 @@ out:
     return pcidevs;
 }
 
+void libxl_device_pci_list_free(libxl_device_pci *list, int nr)
+{
+    int i;
+    for (i = 0; i < nr; i++)
+        libxl_device_pci_dispose(&list[i]);
+    free(list);
+}
+
 int libxl__device_pci_destroy_all(libxl__gc *gc, uint32_t domid)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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