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

Re: [Xen-devel] [PATCH QEMU-XEN v3 1/8] xen: Switch to libxenevtchn interface for compat shims.



Please CC qemu-devel for this series

On Wed, 7 Oct 2015, Ian Campbell wrote:
> In Xen 4.7 we are refactoring parts libxenctrl into a number of
> separate libraries which will provide backward and forward API and ABI
> compatiblity.
> 
> One such library will be libxenevtchn which provides access to event
> channels.
> 
> In preparation for this switch the compatibility layer in xen_common.h
> (which support building with older versions of Xen) to use what will
> be the new library API. This means that the evtchn shim will disappear
> for versions of Xen which include libxenevtchn.
> 
> To simplify things for the <= 4.0.0 support we wrap the int fd in a
> malloc(sizeof int) such that the handle is always a pointer. This
> leads to less typedef headaches and the need for
> XC_HANDLER_INITIAL_VALUE etc for these interfaces.
> 
> Build tested with 4.0 and 4.5.
> 
> Note that this patch does not add any support for actually using
> libxenevtchn, it just adjusts the existing shims.
> 
> Note that xc_evtchn_alloc_unbound functionality remains in libxenctrl,
> since that functionality is not exposed by /dev/xen/evtchn.
> 
> Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

Please run the series through scripts/checkpatch.pl



> diff --git a/include/hw/xen/xen_backend.h b/include/hw/xen/xen_backend.h
> index 3b4125e..a90314f 100644
> --- a/include/hw/xen/xen_backend.h
> +++ b/include/hw/xen/xen_backend.h
> @@ -46,7 +46,7 @@ struct XenDevice {
>      int                remote_port;
>      int                local_port;
>  
> -    XenEvtchn          evtchndev;
> +    xenevtchn_handle   *evtchndev;
>      XenGnttab          gnttabdev;
>  
>      struct XenDevOps   *ops;
> diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
> index 5923290..5700c1b 100644
> --- a/include/hw/xen/xen_common.h
> +++ b/include/hw/xen/xen_common.h
> @@ -39,17 +39,37 @@ static inline void *xc_map_foreign_bulk(int xc_handle, 
> uint32_t dom, int prot,
>  #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 410
>  
>  typedef int XenXC;
> -typedef int XenEvtchn;
> +typedef int xenevtchn_handle;
>  typedef int XenGnttab;
>  
>  #  define XC_INTERFACE_FMT "%i"
>  #  define XC_HANDLER_INITIAL_VALUE    -1
>  
> -static inline XenEvtchn xen_xc_evtchn_open(void *logger,
> -                                           unsigned int open_flags)
> +static inline xenevtchn_handle *xenevtchn_open(void *logger,
> +                                            unsigned int open_flags)
> +{
> +    int *h = malloc(sizeof h);
                       ^
                        sizeof(*h)?

> +    if (!h)
> +     return NULL;

indentation


> +    *h = xc_evtchn_open();
> +    if (*h == -1) {
> +      free(h);
> +         h = NULL;
> +    }
> +    return h;
> +}
> +static inline int xenevtchn_close(xenevtchn_handle *h)
>  {
> -    return xc_evtchn_open();
> +    int rc = xc_evtchn_close(*h);
> +    free(h);
> +    return rc;
>  }
> +#define xenevtchn_fd(h) xc_evtchn_fd(*h)
> +#define xenevtchn_pending(h) xc_evtchn_pending(*h)
> +#define xenevtchn_notify(h,p) xc_evtchn_notify(*h,p)
> +#define xenevtchn_bind_interdomain(h,d,p) xc_evtchn_bind_interdomain(*h,d,p)
> +#define xenevtchn_unmask(h,p) xc_evtchn_unmask(*h,p)
> +#define xenevtchn_unbind(h,p) xc_evtchn_unmask(*h,p)
>  
>  static inline XenGnttab xen_xc_gnttab_open(void *logger,
>                                             unsigned int open_flags)
> @@ -108,17 +128,20 @@ static inline void xs_close(struct xs_handle *xsh)
>  #else
>  
>  typedef xc_interface *XenXC;
> -typedef xc_evtchn *XenEvtchn;
> +typedef xc_evtchn xenevtchn_handle;
>  typedef xc_gnttab *XenGnttab;
>  
>  #  define XC_INTERFACE_FMT "%p"
>  #  define XC_HANDLER_INITIAL_VALUE    NULL
>  
> -static inline XenEvtchn xen_xc_evtchn_open(void *logger,
> -                                           unsigned int open_flags)
> -{
> -    return xc_evtchn_open(logger, open_flags);
> -}
> +#define xenevtchn_open(l,f) xc_evtchn_open(l,f);
> +#define xenevtchn_close(h) xc_evtchn_close(h)
> +#define xenevtchn_fd(h) xc_evtchn_fd(h)
> +#define xenevtchn_pending(h) xc_evtchn_pending(h)
> +#define xenevtchn_notify(h,p) xc_evtchn_notify(h,p)
> +#define xenevtchn_bind_interdomain(h,d,p) xc_evtchn_bind_interdomain(h,d,p)
> +#define xenevtchn_unmask(h,p) xc_evtchn_unmask(h,p)
> +#define xenevtchn_unbind(h,p) xc_evtchn_unbind(h,p)
>  
>  static inline XenGnttab xen_xc_gnttab_open(void *logger,
>                                             unsigned int open_flags)
> diff --git a/xen-hvm.c b/xen-hvm.c
> index 3a7fd58..54cbd72 100644
> --- a/xen-hvm.c
> +++ b/xen-hvm.c
> @@ -109,7 +109,7 @@ typedef struct XenIOState {
>      /* evtchn local port for buffered io */
>      evtchn_port_t bufioreq_local_port;
>      /* the evtchn fd for polling */
> -    XenEvtchn xce_handle;
> +    xenevtchn_handle *xce_handle;
>      /* which vcpu we are serving */
>      int send_vcpu;
>  

I assume everything else is just substitutions

_______________________________________________
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®.