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

Re: [Xen-devel] [PATCH v1] libxl: provide typedefs for device framework functions



On Fri, Sep 22, 2017 at 3:24 PM, Oleksandr Grytsov <al1img@xxxxxxxxx> wrote:
> From: Wei Liu <wei.liu2@xxxxxxxxxx>
>
> Use the new typedefs to avoid copy-n-paste everywhere.
>
> No functional change.
>
> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
> ---
>  tools/libxl/libxl_9pfs.c     |  6 ++--
>  tools/libxl/libxl_console.c  |  6 ++--
>  tools/libxl/libxl_disk.c     |  5 ++--
>  tools/libxl/libxl_internal.h | 71 
> +++++++++++++++++++++++++++-----------------
>  tools/libxl/libxl_nic.c      |  9 ++----
>  tools/libxl/libxl_vdispl.c   | 10 ++-----
>  tools/libxl/libxl_vtpm.c     |  9 ++----
>  7 files changed, 58 insertions(+), 58 deletions(-)
>
> diff --git a/tools/libxl/libxl_9pfs.c b/tools/libxl/libxl_9pfs.c
> index 61d284c..9db887b 100644
> --- a/tools/libxl/libxl_9pfs.c
> +++ b/tools/libxl/libxl_9pfs.c
> @@ -60,8 +60,6 @@ LIBXL_DEFINE_DEVICE_REMOVE(p9)
>
>  DEFINE_DEVICE_TYPE_STRUCT(p9,
>      .skip_attach = 1,
> -    .set_xenstore_config = (int (*)(libxl__gc *, uint32_t, void *,
> -                                    flexarray_t *back, flexarray_t *front,
> -                                    flexarray_t *ro_front))
> -                           libxl__set_xenstore_p9
> +    .set_xenstore_config = (device_set_xenstore_config_fn_t)
> +                           libxl__set_xenstore_p9,
>  );
> diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
> index 68511d7..624bd01 100644
> --- a/tools/libxl/libxl_console.c
> +++ b/tools/libxl/libxl_console.c
> @@ -737,10 +737,8 @@ LIBXL_DEFINE_DEVICE_REMOVE(vfb)
>
>  DEFINE_DEVICE_TYPE_STRUCT(vfb,
>      .skip_attach = 1,
> -    .set_xenstore_config = (int (*)(libxl__gc *, uint32_t, void *,
> -                                    flexarray_t *back, flexarray_t *front,
> -                                    flexarray_t *ro_front))
> -                           libxl__set_xenstore_vfb
> +    .set_xenstore_config = (device_set_xenstore_config_fn_t)
> +                           libxl__set_xenstore_vfb,
>  );
>
>  libxl_xen_console_reader *
> diff --git a/tools/libxl/libxl_disk.c b/tools/libxl/libxl_disk.c
> index 06dd4d3..7111b42 100644
> --- a/tools/libxl/libxl_disk.c
> +++ b/tools/libxl/libxl_disk.c
> @@ -1206,9 +1206,8 @@ static int libxl_device_disk_dm_needed(void *e, 
> unsigned domid)
>  DEFINE_DEVICE_TYPE_STRUCT(disk,
>      .merge       = libxl_device_disk_merge,
>      .dm_needed   = libxl_device_disk_dm_needed,
> -    .from_xenstore = (int (*)(libxl__gc *, const char *, libxl_devid, void 
> *))
> -                     libxl__disk_from_xenstore,
> -    .skip_attach = 1
> +    .from_xenstore = (device_from_xenstore_fn_t)libxl__disk_from_xenstore,
> +    .skip_attach = 1,
>  );
>
>  /*
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 81e87ae..c726595 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -3461,28 +3461,46 @@ _hidden void libxl__bootloader_run(libxl__egc*, 
> libxl__bootloader_state *st);
>      LIBXL_DEFINE_DEVICE_REMOVE_EXT(type, type, remove, 0)               \
>      LIBXL_DEFINE_DEVICE_REMOVE_EXT(type, type, destroy, 1)
>
> +typedef void (*device_add_fn_t)(libxl__egc *, libxl__ao *, uint32_t,
> +                                libxl_domain_config *, libxl__multidev *);
> +typedef void *(*device_list_fn_t)(libxl_ctx *, uint32_t, int *);
> +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_dispose_fn_t)(void *);
> +typedef int (*device_compare_fn_t)(void *, 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 *);
> +typedef int (*device_update_devid_fn_t)(libxl__gc *, uint32_t, void *);
> +typedef int (*device_from_xenstore_fn_t)(libxl__gc *, const char *,
> +                                         libxl_devid, void *);
> +typedef int (*device_set_xenstore_config_fn_t)(libxl__gc *, uint32_t, void *,
> +                                               flexarray_t *, flexarray_t *,
> +                                               flexarray_t *);
> +
>  struct libxl_device_type {
>      char *type;
>      int skip_attach;   /* Skip entry in domcreate_attach_devices() if 1 */
>      int ptr_offset;    /* Offset of device array ptr in libxl_domain_config 
> */
>      int num_offset;    /* Offset of # of devices in libxl_domain_config */
>      int dev_elem_size; /* Size of one device element in array */
> -    void (*add)(libxl__egc *, libxl__ao *, uint32_t, libxl_domain_config *,
> -                libxl__multidev *);
> -    void *(*list)(libxl_ctx *, uint32_t, int *);
> -    int (*set_default)(libxl__gc *, uint32_t, void *, bool);
> -    int (*to_device)(libxl__gc *, uint32_t, void *, libxl__device *);
> -    void (*init)(void *);
> -    void (*copy)(libxl_ctx *, void *, void *);
> -    void (*dispose)(void *);
> -    int (*compare)(void *, void *);
> -    void (*merge)(libxl_ctx *, void *, void *);
> -    int (*dm_needed)(void *, unsigned);
> -    void (*update_config)(libxl__gc *, void *, void *);
> -    int (*update_devid)(libxl__gc *, uint32_t, void *);
> -    int (*from_xenstore)(libxl__gc *, const char *, libxl_devid, void *);
> -    int (*set_xenstore_config)(libxl__gc *, uint32_t, void *, flexarray_t *,
> -                               flexarray_t *, flexarray_t *);
> +    device_add_fn_t                 add;
> +    device_list_fn_t                list;
> +    device_set_default_fn_t         set_default;
> +    device_to_device_fn_t           to_device;
> +    device_init_fn_t                init;
> +    device_copy_fn_t                copy;
> +    device_dispose_fn_t             dispose;
> +    device_compare_fn_t             compare;
> +    device_merge_fn_t               merge;
> +    device_dm_needed_fn_t           dm_needed;
> +    device_update_config_fn_t       update_config;
> +    device_update_devid_fn_t        update_devid;
> +    device_from_xenstore_fn_t       from_xenstore;
> +    device_set_xenstore_config_fn_t set_xenstore_config;
>  };
>
>  #define DEFINE_DEVICE_TYPE_STRUCT_X(name, sname, ...)                        
>   \
> @@ -3492,20 +3510,17 @@ struct libxl_device_type {
>          .num_offset    = offsetof(libxl_domain_config, num_ ## name ## s),   
>   \
>          .dev_elem_size = sizeof(libxl_device_ ## sname),                     
>   \
>          .add           = libxl__add_ ## name ## s,                           
>   \
> -        .list          = (void *(*)(libxl_ctx *, uint32_t, int *))           
>   \
> -                         libxl_device_ ## sname ## _list,                    
>   \
> -        .set_default   = (int (*)(libxl__gc *, uint32_t, void *, bool))\
> +        .list          = (device_list_fn_t)libxl_device_ ## sname ## _list,  
>   \
> +        .set_default   = (device_set_default_fn_t)                           
>   \
>                           libxl__device_ ## sname ## _setdefault,             
>   \
> -        .to_device     = (int (*)(libxl__gc *, uint32_t,                     
>   \
> -                                  void *, libxl__device *))                  
>   \
> -                         libxl__device_from_ ## name,                        
>   \
> -        .init          = (void (*)(void *))libxl_device_ ## sname ## _init,  
>   \
> -        .copy          = (void (*)(libxl_ctx *, void *, void *))             
>   \
> -                         libxl_device_ ## sname ## _copy,                    
>   \
> -        .dispose       = (void (*)(void *))libxl_device_ ## sname ## 
> _dispose, \
> -        .compare       = (int (*)(void *, void *))                           
>   \
> +        .to_device     = (device_to_device_fn_t)libxl__device_from_ ## name, 
>   \
> +        .init          = (device_init_fn_t)libxl_device_ ## sname ## _init,  
>   \
> +        .copy          = (device_copy_fn_t)libxl_device_ ## sname ## _copy,  
>   \
> +        .dispose       = (device_dispose_fn_t)                               
>   \
> +                         libxl_device_ ## sname ## _dispose,                 
>   \
> +        .compare       = (device_compare_fn_t)                               
>   \
>                           libxl_device_ ## sname ## _compare,                 
>   \
> -        .update_devid  = (int (*)(libxl__gc *, uint32_t, void *))            
>   \
> +        .update_devid  = (device_update_devid_fn_t)                          
>   \
>                           libxl__device_ ## sname ## _update_devid,           
>   \
>          __VA_ARGS__                                                          
>   \
>      }
> diff --git a/tools/libxl/libxl_nic.c b/tools/libxl/libxl_nic.c
> index d81b95b..cf8fd5c 100644
> --- a/tools/libxl/libxl_nic.c
> +++ b/tools/libxl/libxl_nic.c
> @@ -542,12 +542,9 @@ LIBXL_DEFINE_DEVICE_REMOVE(nic)
>
>  DEFINE_DEVICE_TYPE_STRUCT(nic,
>      .update_config = libxl_device_nic_update_config,
> -    .from_xenstore = (int (*)(libxl__gc *, const char *, libxl_devid, void 
> *))
> -                     libxl__nic_from_xenstore,
> -    .set_xenstore_config = (int (*)(libxl__gc *, uint32_t, void *,
> -                                    flexarray_t *back, flexarray_t *front,
> -                                    flexarray_t *ro_front))
> -                           libxl__set_xenstore_nic
> +    .from_xenstore = (device_from_xenstore_fn_t)libxl__nic_from_xenstore,
> +    .set_xenstore_config = (device_set_xenstore_config_fn_t)
> +                           libxl__set_xenstore_nic,
>  );
>
>  /*
> diff --git a/tools/libxl/libxl_vdispl.c b/tools/libxl/libxl_vdispl.c
> index befc56b..a2371ed 100644
> --- a/tools/libxl/libxl_vdispl.c
> +++ b/tools/libxl/libxl_vdispl.c
> @@ -269,13 +269,9 @@ LIBXL_DEFINE_DEVICE_REMOVE(vdispl)
>  static LIBXL_DEFINE_UPDATE_DEVID(vdispl, "vdispl")
>
>  DEFINE_DEVICE_TYPE_STRUCT(vdispl,
> -    .update_config = (void (*)(libxl__gc *, void *, void *))
> -                     libxl__update_config_vdispl,
> -    .from_xenstore = (int (*)(libxl__gc *, const char *, libxl_devid, void 
> *))
> -                     libxl__vdispl_from_xenstore,
> -    .set_xenstore_config = (int (*)(libxl__gc *, uint32_t, void *,
> -                                    flexarray_t *back, flexarray_t *front,
> -                                    flexarray_t *ro_front))
> +    .update_config = (device_update_config_fn_t)libxl__update_config_vdispl,
> +    .from_xenstore = (device_from_xenstore_fn_t)libxl__vdispl_from_xenstore,
> +    .set_xenstore_config = (device_set_xenstore_config_fn_t)
>                             libxl__set_xenstore_vdispl
>  );
>
> diff --git a/tools/libxl/libxl_vtpm.c b/tools/libxl/libxl_vtpm.c
> index 6182cfc..a06f15d 100644
> --- a/tools/libxl/libxl_vtpm.c
> +++ b/tools/libxl/libxl_vtpm.c
> @@ -263,12 +263,9 @@ LIBXL_DEFINE_DEVICE_REMOVE(vtpm)
>
>  DEFINE_DEVICE_TYPE_STRUCT(vtpm,
>      .update_config = libxl_device_vtpm_update_config,
> -    .from_xenstore = (int (*)(libxl__gc *, const char *, libxl_devid, void 
> *))
> -                     libxl__vtpm_from_xenstore,
> -    .set_xenstore_config = (int (*)(libxl__gc *, uint32_t, void *,
> -                                    flexarray_t *back, flexarray_t *front,
> -                                    flexarray_t *ro_front))
> -                           libxl__set_xenstore_vtpm
> +    .from_xenstore = (device_from_xenstore_fn_t)libxl__vtpm_from_xenstore,
> +    .set_xenstore_config = (device_set_xenstore_config_fn_t)
> +                           libxl__set_xenstore_vtpm,
>  );
>
>  /*
> --
> 2.7.4
>

Please ignore.

-- 
Best Regards,
Oleksandr Grytsov.

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

 


Rackspace

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