summaryrefslogtreecommitdiff
path: root/include/hw
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2016-01-15 13:23:38 +0000
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>2016-01-26 17:19:24 +0000
commita2db2a1edd06a50b8a862c654cf993368cf9f1d9 (patch)
treeeb115de7a6023c6b2bfcf757e09d0ca48ead0a80 /include/hw
parent549e9bcabc2f5b37b0be8c24257e0b527bffb49a (diff)
downloadqemu-a2db2a1edd06a50b8a862c654cf993368cf9f1d9.zip
xen: Switch to libxenevtchn interface for compat shims.
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. 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@citrix.com> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Diffstat (limited to 'include/hw')
-rw-r--r--include/hw/xen/xen_backend.h2
-rw-r--r--include/hw/xen/xen_common.h44
2 files changed, 35 insertions, 11 deletions
diff --git a/include/hw/xen/xen_backend.h b/include/hw/xen/xen_backend.h
index 3b4125e39f..a90314f182 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 4ac0c6f443..5c51b441da 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -39,17 +39,38 @@ 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)
{
- return xc_evtchn_open();
+ xenevtchn_handle *h = malloc(sizeof(*h));
+ if (!h) {
+ return NULL;
+ }
+ *h = xc_evtchn_open();
+ if (*h == -1) {
+ free(h);
+ h = NULL;
+ }
+ return h;
}
+static inline int xenevtchn_close(xenevtchn_handle *h)
+{
+ 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 +129,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)