All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Some cleanup of device_add_domain_config
@ 2019-04-05 17:58 ` Anthony PERARD
  0 siblings, 0 replies; 14+ messages in thread
From: Anthony PERARD @ 2019-04-05 17:58 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD

Documentation of device_add_domain_config and constify `src'.

Anthony PERARD (3):
  libxl: Constify libxl_device_*_compare functions
  libxl: Constify src of device_compare_fn_t
  libxl: Document device_add_domain_config

 tools/libxl/libxl_device.c   |  6 +++---
 tools/libxl/libxl_disk.c     |  4 ++--
 tools/libxl/libxl_internal.h | 19 ++++++++++++++++---
 tools/libxl/libxl_nic.c      |  4 ++--
 tools/libxl/libxl_pci.c      |  4 ++--
 tools/libxl/libxl_usb.c      |  8 ++++----
 tools/libxl/libxl_vdispl.c   |  4 ++--
 tools/libxl/libxl_vsnd.c     |  4 ++--
 tools/libxl/libxl_vtpm.c     |  4 ++--
 9 files changed, 35 insertions(+), 22 deletions(-)

-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Xen-devel] [PATCH 0/3] Some cleanup of device_add_domain_config
@ 2019-04-05 17:58 ` Anthony PERARD
  0 siblings, 0 replies; 14+ messages in thread
From: Anthony PERARD @ 2019-04-05 17:58 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD

Documentation of device_add_domain_config and constify `src'.

Anthony PERARD (3):
  libxl: Constify libxl_device_*_compare functions
  libxl: Constify src of device_compare_fn_t
  libxl: Document device_add_domain_config

 tools/libxl/libxl_device.c   |  6 +++---
 tools/libxl/libxl_disk.c     |  4 ++--
 tools/libxl/libxl_internal.h | 19 ++++++++++++++++---
 tools/libxl/libxl_nic.c      |  4 ++--
 tools/libxl/libxl_pci.c      |  4 ++--
 tools/libxl/libxl_usb.c      |  8 ++++----
 tools/libxl/libxl_vdispl.c   |  4 ++--
 tools/libxl/libxl_vsnd.c     |  4 ++--
 tools/libxl/libxl_vtpm.c     |  4 ++--
 9 files changed, 35 insertions(+), 22 deletions(-)

-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/3] libxl: Constify libxl_device_*_compare functions
@ 2019-04-05 17:58   ` Anthony PERARD
  0 siblings, 0 replies; 14+ messages in thread
From: Anthony PERARD @ 2019-04-05 17:58 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD, Wei Liu, Ian Jackson

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libxl/libxl_disk.c     | 4 ++--
 tools/libxl/libxl_internal.h | 2 +-
 tools/libxl/libxl_nic.c      | 4 ++--
 tools/libxl/libxl_pci.c      | 4 ++--
 tools/libxl/libxl_usb.c      | 8 ++++----
 tools/libxl/libxl_vdispl.c   | 4 ++--
 tools/libxl/libxl_vsnd.c     | 4 ++--
 tools/libxl/libxl_vtpm.c     | 4 ++--
 8 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/tools/libxl/libxl_disk.c b/tools/libxl/libxl_disk.c
index e9eceb65e3..79e30f8d52 100644
--- a/tools/libxl/libxl_disk.c
+++ b/tools/libxl/libxl_disk.c
@@ -1126,8 +1126,8 @@ LIBXL_DEFINE_DEVICE_ADD(disk)
 LIBXL_DEFINE_DEVICES_ADD(disk)
 LIBXL_DEFINE_DEVICE_REMOVE(disk)
 
-static int libxl_device_disk_compare(libxl_device_disk *d1,
-                                     libxl_device_disk *d2)
+static int libxl_device_disk_compare(const libxl_device_disk *d1,
+                                     const libxl_device_disk *d2)
 {
     return COMPARE_DISK(d1, d2);
 }
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 459f9bffa8..c75c98156a 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3728,7 +3728,7 @@ typedef int (*device_to_device_fn_t)(libxl__gc *, uint32_t, void *,
 typedef void (*device_init_fn_t)(void *);
 typedef void (*device_copy_fn_t)(libxl_ctx *, void *, void *);
 typedef void (*device_dispose_fn_t)(void *);
-typedef int (*device_compare_fn_t)(void *, void *);
+typedef int (*device_compare_fn_t)(const void *, const void *);
 typedef void (*device_merge_fn_t)(libxl_ctx *, void *, void *);
 typedef int (*device_dm_needed_fn_t)(void *, unsigned);
 typedef void (*device_update_config_fn_t)(libxl__gc *, void *, void *);
diff --git a/tools/libxl/libxl_nic.c b/tools/libxl/libxl_nic.c
index 01b711b84e..f2b5e02285 100644
--- a/tools/libxl/libxl_nic.c
+++ b/tools/libxl/libxl_nic.c
@@ -454,8 +454,8 @@ const char *libxl__device_nic_devname(libxl__gc *gc,
     }
 }
 
-static int libxl_device_nic_compare(libxl_device_nic *d1,
-                                    libxl_device_nic *d2)
+static int libxl_device_nic_compare(const libxl_device_nic *d1,
+                                    const libxl_device_nic *d2)
 {
     return COMPARE_DEVID(d1, d2);
 }
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 87afa03d9e..4ec6872798 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -1679,8 +1679,8 @@ int libxl__grant_vga_iomem_permission(libxl__gc *gc, const uint32_t domid,
     return 0;
 }
 
-static int libxl_device_pci_compare(libxl_device_pci *d1,
-                                    libxl_device_pci *d2)
+static int libxl_device_pci_compare(const libxl_device_pci *d1,
+                                    const libxl_device_pci *d2)
 {
     return COMPARE_PCI(d1, d2);
 }
diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c
index 67d2fb4e37..adb122ac85 100644
--- a/tools/libxl/libxl_usb.c
+++ b/tools/libxl/libxl_usb.c
@@ -1925,8 +1925,8 @@ int libxl_ctrlport_to_device_usbdev(libxl_ctx *ctx,
     return rc;
 }
 
-static int libxl_device_usbctrl_compare(libxl_device_usbctrl *d1,
-                                        libxl_device_usbctrl *d2)
+static int libxl_device_usbctrl_compare(const libxl_device_usbctrl *d1,
+                                        const libxl_device_usbctrl *d2)
 {
     return COMPARE_USBCTRL(d1, d2);
 }
@@ -1939,8 +1939,8 @@ static int libxl_device_usbctrl_dm_needed(void *e, unsigned domid)
            elem->backend_domid == domid;
 }
 
-static int libxl_device_usbdev_compare(libxl_device_usbdev *d1,
-                                       libxl_device_usbdev *d2)
+static int libxl_device_usbdev_compare(const libxl_device_usbdev *d1,
+                                       const libxl_device_usbdev *d2)
 {
     return COMPARE_USB(d1, d2);
 }
diff --git a/tools/libxl/libxl_vdispl.c b/tools/libxl/libxl_vdispl.c
index 351f6beccb..c9cc455176 100644
--- a/tools/libxl/libxl_vdispl.c
+++ b/tools/libxl/libxl_vdispl.c
@@ -48,8 +48,8 @@ static void libxl__update_config_vdispl(libxl__gc *gc,
     dst->be_alloc = src->be_alloc;
 }
 
-static int libxl_device_vdispl_compare(libxl_device_vdispl *d1,
-                                       libxl_device_vdispl *d2)
+static int libxl_device_vdispl_compare(const libxl_device_vdispl *d1,
+                                       const libxl_device_vdispl *d2)
 {
     return COMPARE_DEVID(d1, d2);
 }
diff --git a/tools/libxl/libxl_vsnd.c b/tools/libxl/libxl_vsnd.c
index 9570a4cf0e..1151cbc567 100644
--- a/tools/libxl/libxl_vsnd.c
+++ b/tools/libxl/libxl_vsnd.c
@@ -290,8 +290,8 @@ static void libxl__update_config_vsnd(libxl__gc *gc,
     dst->devid = src->devid;
 }
 
-static int libxl_device_vsnd_compare(libxl_device_vsnd *d1,
-                                     libxl_device_vsnd *d2)
+static int libxl_device_vsnd_compare(const libxl_device_vsnd *d1,
+                                     const libxl_device_vsnd *d2)
 {
     return COMPARE_DEVID(d1, d2);
 }
diff --git a/tools/libxl/libxl_vtpm.c b/tools/libxl/libxl_vtpm.c
index 7c91f99673..f750395f6f 100644
--- a/tools/libxl/libxl_vtpm.c
+++ b/tools/libxl/libxl_vtpm.c
@@ -183,8 +183,8 @@ int libxl_devid_to_device_vtpm(libxl_ctx *ctx,
     return rc;
 }
 
-static int libxl_device_vtpm_compare(libxl_device_vtpm *d1,
-                                     libxl_device_vtpm *d2)
+static int libxl_device_vtpm_compare(const libxl_device_vtpm *d1,
+                                     const libxl_device_vtpm *d2)
 {
     return COMPARE_DEVID(d1, d2);
 }
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Xen-devel] [PATCH 1/3] libxl: Constify libxl_device_*_compare functions
@ 2019-04-05 17:58   ` Anthony PERARD
  0 siblings, 0 replies; 14+ messages in thread
From: Anthony PERARD @ 2019-04-05 17:58 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD, Wei Liu, Ian Jackson

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libxl/libxl_disk.c     | 4 ++--
 tools/libxl/libxl_internal.h | 2 +-
 tools/libxl/libxl_nic.c      | 4 ++--
 tools/libxl/libxl_pci.c      | 4 ++--
 tools/libxl/libxl_usb.c      | 8 ++++----
 tools/libxl/libxl_vdispl.c   | 4 ++--
 tools/libxl/libxl_vsnd.c     | 4 ++--
 tools/libxl/libxl_vtpm.c     | 4 ++--
 8 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/tools/libxl/libxl_disk.c b/tools/libxl/libxl_disk.c
index e9eceb65e3..79e30f8d52 100644
--- a/tools/libxl/libxl_disk.c
+++ b/tools/libxl/libxl_disk.c
@@ -1126,8 +1126,8 @@ LIBXL_DEFINE_DEVICE_ADD(disk)
 LIBXL_DEFINE_DEVICES_ADD(disk)
 LIBXL_DEFINE_DEVICE_REMOVE(disk)
 
-static int libxl_device_disk_compare(libxl_device_disk *d1,
-                                     libxl_device_disk *d2)
+static int libxl_device_disk_compare(const libxl_device_disk *d1,
+                                     const libxl_device_disk *d2)
 {
     return COMPARE_DISK(d1, d2);
 }
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 459f9bffa8..c75c98156a 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3728,7 +3728,7 @@ typedef int (*device_to_device_fn_t)(libxl__gc *, uint32_t, void *,
 typedef void (*device_init_fn_t)(void *);
 typedef void (*device_copy_fn_t)(libxl_ctx *, void *, void *);
 typedef void (*device_dispose_fn_t)(void *);
-typedef int (*device_compare_fn_t)(void *, void *);
+typedef int (*device_compare_fn_t)(const void *, const void *);
 typedef void (*device_merge_fn_t)(libxl_ctx *, void *, void *);
 typedef int (*device_dm_needed_fn_t)(void *, unsigned);
 typedef void (*device_update_config_fn_t)(libxl__gc *, void *, void *);
diff --git a/tools/libxl/libxl_nic.c b/tools/libxl/libxl_nic.c
index 01b711b84e..f2b5e02285 100644
--- a/tools/libxl/libxl_nic.c
+++ b/tools/libxl/libxl_nic.c
@@ -454,8 +454,8 @@ const char *libxl__device_nic_devname(libxl__gc *gc,
     }
 }
 
-static int libxl_device_nic_compare(libxl_device_nic *d1,
-                                    libxl_device_nic *d2)
+static int libxl_device_nic_compare(const libxl_device_nic *d1,
+                                    const libxl_device_nic *d2)
 {
     return COMPARE_DEVID(d1, d2);
 }
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 87afa03d9e..4ec6872798 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -1679,8 +1679,8 @@ int libxl__grant_vga_iomem_permission(libxl__gc *gc, const uint32_t domid,
     return 0;
 }
 
-static int libxl_device_pci_compare(libxl_device_pci *d1,
-                                    libxl_device_pci *d2)
+static int libxl_device_pci_compare(const libxl_device_pci *d1,
+                                    const libxl_device_pci *d2)
 {
     return COMPARE_PCI(d1, d2);
 }
diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c
index 67d2fb4e37..adb122ac85 100644
--- a/tools/libxl/libxl_usb.c
+++ b/tools/libxl/libxl_usb.c
@@ -1925,8 +1925,8 @@ int libxl_ctrlport_to_device_usbdev(libxl_ctx *ctx,
     return rc;
 }
 
-static int libxl_device_usbctrl_compare(libxl_device_usbctrl *d1,
-                                        libxl_device_usbctrl *d2)
+static int libxl_device_usbctrl_compare(const libxl_device_usbctrl *d1,
+                                        const libxl_device_usbctrl *d2)
 {
     return COMPARE_USBCTRL(d1, d2);
 }
@@ -1939,8 +1939,8 @@ static int libxl_device_usbctrl_dm_needed(void *e, unsigned domid)
            elem->backend_domid == domid;
 }
 
-static int libxl_device_usbdev_compare(libxl_device_usbdev *d1,
-                                       libxl_device_usbdev *d2)
+static int libxl_device_usbdev_compare(const libxl_device_usbdev *d1,
+                                       const libxl_device_usbdev *d2)
 {
     return COMPARE_USB(d1, d2);
 }
diff --git a/tools/libxl/libxl_vdispl.c b/tools/libxl/libxl_vdispl.c
index 351f6beccb..c9cc455176 100644
--- a/tools/libxl/libxl_vdispl.c
+++ b/tools/libxl/libxl_vdispl.c
@@ -48,8 +48,8 @@ static void libxl__update_config_vdispl(libxl__gc *gc,
     dst->be_alloc = src->be_alloc;
 }
 
-static int libxl_device_vdispl_compare(libxl_device_vdispl *d1,
-                                       libxl_device_vdispl *d2)
+static int libxl_device_vdispl_compare(const libxl_device_vdispl *d1,
+                                       const libxl_device_vdispl *d2)
 {
     return COMPARE_DEVID(d1, d2);
 }
diff --git a/tools/libxl/libxl_vsnd.c b/tools/libxl/libxl_vsnd.c
index 9570a4cf0e..1151cbc567 100644
--- a/tools/libxl/libxl_vsnd.c
+++ b/tools/libxl/libxl_vsnd.c
@@ -290,8 +290,8 @@ static void libxl__update_config_vsnd(libxl__gc *gc,
     dst->devid = src->devid;
 }
 
-static int libxl_device_vsnd_compare(libxl_device_vsnd *d1,
-                                     libxl_device_vsnd *d2)
+static int libxl_device_vsnd_compare(const libxl_device_vsnd *d1,
+                                     const libxl_device_vsnd *d2)
 {
     return COMPARE_DEVID(d1, d2);
 }
diff --git a/tools/libxl/libxl_vtpm.c b/tools/libxl/libxl_vtpm.c
index 7c91f99673..f750395f6f 100644
--- a/tools/libxl/libxl_vtpm.c
+++ b/tools/libxl/libxl_vtpm.c
@@ -183,8 +183,8 @@ int libxl_devid_to_device_vtpm(libxl_ctx *ctx,
     return rc;
 }
 
-static int libxl_device_vtpm_compare(libxl_device_vtpm *d1,
-                                     libxl_device_vtpm *d2)
+static int libxl_device_vtpm_compare(const libxl_device_vtpm *d1,
+                                     const libxl_device_vtpm *d2)
 {
     return COMPARE_DEVID(d1, d2);
 }
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/3] libxl: Constify src of device_compare_fn_t
@ 2019-04-05 17:58   ` Anthony PERARD
  0 siblings, 0 replies; 14+ messages in thread
From: Anthony PERARD @ 2019-04-05 17:58 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD, Wei Liu, Ian Jackson

All functions libxl_device_*_copy which implements device_compare_fn_t
already have the `src' parameter defined with const.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libxl/libxl_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index c75c98156a..34dc886505 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3726,7 +3726,7 @@ typedef int (*device_set_default_fn_t)(libxl__gc *, uint32_t, void *, bool);
 typedef int (*device_to_device_fn_t)(libxl__gc *, uint32_t, void *,
                                      libxl__device *);
 typedef void (*device_init_fn_t)(void *);
-typedef void (*device_copy_fn_t)(libxl_ctx *, void *, void *);
+typedef void (*device_copy_fn_t)(libxl_ctx *, void *dst, const void *src);
 typedef void (*device_dispose_fn_t)(void *);
 typedef int (*device_compare_fn_t)(const void *, const void *);
 typedef void (*device_merge_fn_t)(libxl_ctx *, void *, void *);
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Xen-devel] [PATCH 2/3] libxl: Constify src of device_compare_fn_t
@ 2019-04-05 17:58   ` Anthony PERARD
  0 siblings, 0 replies; 14+ messages in thread
From: Anthony PERARD @ 2019-04-05 17:58 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD, Wei Liu, Ian Jackson

All functions libxl_device_*_copy which implements device_compare_fn_t
already have the `src' parameter defined with const.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libxl/libxl_internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index c75c98156a..34dc886505 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3726,7 +3726,7 @@ typedef int (*device_set_default_fn_t)(libxl__gc *, uint32_t, void *, bool);
 typedef int (*device_to_device_fn_t)(libxl__gc *, uint32_t, void *,
                                      libxl__device *);
 typedef void (*device_init_fn_t)(void *);
-typedef void (*device_copy_fn_t)(libxl_ctx *, void *, void *);
+typedef void (*device_copy_fn_t)(libxl_ctx *, void *dst, const void *src);
 typedef void (*device_dispose_fn_t)(void *);
 typedef int (*device_compare_fn_t)(const void *, const void *);
 typedef void (*device_merge_fn_t)(libxl_ctx *, void *, void *);
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/3] libxl: Document device_add_domain_config
@ 2019-04-05 17:58   ` Anthony PERARD
  0 siblings, 0 replies; 14+ messages in thread
From: Anthony PERARD @ 2019-04-05 17:58 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD, Wei Liu, Ian Jackson

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

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,
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Xen-devel] [PATCH 3/3] libxl: Document device_add_domain_config
@ 2019-04-05 17:58   ` Anthony PERARD
  0 siblings, 0 replies; 14+ messages in thread
From: Anthony PERARD @ 2019-04-05 17:58 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD, Wei Liu, Ian Jackson

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

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,
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] libxl: Constify libxl_device_*_compare functions
@ 2019-04-09 12:38     ` Wei Liu
  0 siblings, 0 replies; 14+ messages in thread
From: Wei Liu @ 2019-04-09 12:38 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: xen-devel, Ian Jackson, Wei Liu

On Fri, Apr 05, 2019 at 06:58:09PM +0100, Anthony PERARD wrote:
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

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

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Xen-devel] [PATCH 1/3] libxl: Constify libxl_device_*_compare functions
@ 2019-04-09 12:38     ` Wei Liu
  0 siblings, 0 replies; 14+ messages in thread
From: Wei Liu @ 2019-04-09 12:38 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: xen-devel, Ian Jackson, Wei Liu

On Fri, Apr 05, 2019 at 06:58:09PM +0100, Anthony PERARD wrote:
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

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

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/3] libxl: Constify src of device_compare_fn_t
@ 2019-04-09 12:38     ` Wei Liu
  0 siblings, 0 replies; 14+ messages in thread
From: Wei Liu @ 2019-04-09 12:38 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: xen-devel, Ian Jackson, Wei Liu

On Fri, Apr 05, 2019 at 06:58:10PM +0100, Anthony PERARD wrote:
> All functions libxl_device_*_copy which implements device_compare_fn_t
> already have the `src' parameter defined with const.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

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

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Xen-devel] [PATCH 2/3] libxl: Constify src of device_compare_fn_t
@ 2019-04-09 12:38     ` Wei Liu
  0 siblings, 0 replies; 14+ messages in thread
From: Wei Liu @ 2019-04-09 12:38 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: xen-devel, Ian Jackson, Wei Liu

On Fri, Apr 05, 2019 at 06:58:10PM +0100, Anthony PERARD wrote:
> All functions libxl_device_*_copy which implements device_compare_fn_t
> already have the `src' parameter defined with const.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

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

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] libxl: Document device_add_domain_config
@ 2019-04-09 12:46     ` Wei Liu
  0 siblings, 0 replies; 14+ messages in thread
From: Wei Liu @ 2019-04-09 12:46 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: xen-devel, Ian Jackson, Wei Liu

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>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Xen-devel] [PATCH 3/3] libxl: Document device_add_domain_config
@ 2019-04-09 12:46     ` Wei Liu
  0 siblings, 0 replies; 14+ messages in thread
From: Wei Liu @ 2019-04-09 12:46 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: xen-devel, Ian Jackson, Wei Liu

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>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-04-09 12:47 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-05 17:58 [PATCH 0/3] Some cleanup of device_add_domain_config Anthony PERARD
2019-04-05 17:58 ` [Xen-devel] " Anthony PERARD
2019-04-05 17:58 ` [PATCH 1/3] libxl: Constify libxl_device_*_compare functions Anthony PERARD
2019-04-05 17:58   ` [Xen-devel] " Anthony PERARD
2019-04-09 12:38   ` Wei Liu
2019-04-09 12:38     ` [Xen-devel] " Wei Liu
2019-04-05 17:58 ` [PATCH 2/3] libxl: Constify src of device_compare_fn_t Anthony PERARD
2019-04-05 17:58   ` [Xen-devel] " Anthony PERARD
2019-04-09 12:38   ` Wei Liu
2019-04-09 12:38     ` [Xen-devel] " Wei Liu
2019-04-05 17:58 ` [PATCH 3/3] libxl: Document device_add_domain_config Anthony PERARD
2019-04-05 17:58   ` [Xen-devel] " Anthony PERARD
2019-04-09 12:46   ` Wei Liu
2019-04-09 12:46     ` [Xen-devel] " Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.