From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH QEMU-XEN v3 1/8] xen: Switch to libxenevtchn interface for compat shims. Date: Wed, 7 Oct 2015 15:36:08 +0100 Message-ID: <56152DD8.8080909@citrix.com> References: <1444226543.1410.53.camel@citrix.com> <1444227366-1015-1-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1444227366-1015-1-git-send-email-ian.campbell@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell , ian.jackson@eu.citrix.com, wei.liu2@citrix.com, xen-devel@lists.xen.org Cc: stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On 07/10/15 15:15, Ian Campbell wrote: > 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. > > > > 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); This allocates the size of a pointer, not the size of an int, as the patch description states. As this is compatibility code, it might be better just to use "sizeof(int)" directly, as stated in the "pre 4.1 note" in xenctrl.h ~Andrew