[3/3] libxl: Document device_add_domain_config
diff mbox series

Message ID 20190405175811.7446-4-anthony.perard@citrix.com
State New, archived
Headers show
Series
  • Some cleanup of device_add_domain_config
Related show

Commit Message

Anthony PERARD April 5, 2019, 5:58 p.m. UTC
Commit 03e1a56d81c16eece735e4d0ef74bfb10eaaba07 replaced DEVICE_ADD()
calls by device_add_domain_config() calls but also removed the comment
of DEVICE_ADD(). Copy the useful part of that comment to
device_add_domain_config().

Also, rename the parameter `type` to `dev`, because that parameter isn't
used as a type but as the device we want to add/update to d_config.

Also, constify `dev` because it isn't modified.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libxl/libxl_device.c   |  6 +++---
 tools/libxl/libxl_internal.h | 15 ++++++++++++++-
 2 files changed, 17 insertions(+), 4 deletions(-)

Comments

Wei Liu April 9, 2019, 12:46 p.m. UTC | #1
On Fri, Apr 05, 2019 at 06:58:11PM +0100, Anthony PERARD wrote:
> Commit 03e1a56d81c16eece735e4d0ef74bfb10eaaba07 replaced DEVICE_ADD()
> calls by device_add_domain_config() calls but also removed the comment
> of DEVICE_ADD(). Copy the useful part of that comment to
> device_add_domain_config().
> 
> Also, rename the parameter `type` to `dev`, because that parameter isn't
> used as a type but as the device we want to add/update to d_config.
> 
> Also, constify `dev` because it isn't modified.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

Patch
diff mbox series

diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index a4a8e9ac32..87ddfc3ac7 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -1852,7 +1852,7 @@  int libxl_device_events_handler(libxl_ctx *ctx,
 }
 
 void device_add_domain_config(libxl__gc *gc, libxl_domain_config *d_config,
-                              const struct libxl_device_type *dt, void *type)
+                              const struct libxl_device_type *dt, const void *dev)
 {
     int *num_dev;
     unsigned int i;
@@ -1862,7 +1862,7 @@  void device_add_domain_config(libxl__gc *gc, libxl_domain_config *d_config,
 
     /* Check for existing device */
     for (i = 0; i < *num_dev; i++) {
-        if (dt->compare(libxl__device_type_get_elem(dt, d_config, i), type)) {
+        if (dt->compare(libxl__device_type_get_elem(dt, d_config, i), dev)) {
             item = libxl__device_type_get_elem(dt, d_config, i);
         }
     }
@@ -1878,7 +1878,7 @@  void device_add_domain_config(libxl__gc *gc, libxl_domain_config *d_config,
     }
 
     dt->init(item);
-    dt->copy(CTX, item, type);
+    dt->copy(CTX, item, dev);
 }
 
 void libxl__device_add_async(libxl__egc *egc, uint32_t domid,
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 34dc886505..44e0221284 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -4581,8 +4581,21 @@  static inline bool libxl__acpi_defbool_val(const libxl_domain_build_info *b_info
            libxl_defbool_val(b_info->u.hvm.acpi);
 }
 
+/*
+ * Add a device in libxl_domain_config structure
+ *
+ * If there is already a device with the same identifier in d_config,
+ * that entry is updated.
+ *
+ * parameters:
+ *  d_config: pointer to template domain config
+ *  dt:       type of `dev'
+ *  dev:      the device that is to be added / removed / updated
+ *            (a copy of `dev' will be made)
+ */
 void device_add_domain_config(libxl__gc *gc, libxl_domain_config *d_config,
-                              const struct libxl_device_type *dt, void *type);
+                              const struct libxl_device_type *dt,
+                              const void *dev);
 
 void libxl__device_add_async(libxl__egc *egc, uint32_t domid,
                              const struct libxl_device_type *dt, void *type,