@@ -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,
@@ -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,
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(-)