aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2016-01-15 13:23:39 +0000
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>2016-01-26 17:19:28 +0000
commitc1345a88785b50ba2bf5e87b83c7e22f6b4ec83d (patch)
treeb33273e1cc6b0ed2fbcc10525e46f539525e3b74 /include
parenta2db2a1edd06a50b8a862c654cf993368cf9f1d9 (diff)
xen: Switch to libxengnttab 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 libxengnttab which provides access to grant tables. 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 gnttab shim will disappear for versions of Xen which include libxengnttab. 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 libxengnttab, it just adjusts the existing shims. 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')
-rw-r--r--include/hw/xen/xen_backend.h2
-rw-r--r--include/hw/xen/xen_common.h42
2 files changed, 33 insertions, 11 deletions
diff --git a/include/hw/xen/xen_backend.h b/include/hw/xen/xen_backend.h
index a90314f182..8e8857b155 100644
--- a/include/hw/xen/xen_backend.h
+++ b/include/hw/xen/xen_backend.h
@@ -47,7 +47,7 @@ struct XenDevice {
int local_port;
xenevtchn_handle *evtchndev;
- XenGnttab gnttabdev;
+ xengnttab_handle *gnttabdev;
struct XenDevOps *ops;
QTAILQ_ENTRY(XenDevice) next;
diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index 5c51b441da..8f38310426 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -40,7 +40,7 @@ static inline void *xc_map_foreign_bulk(int xc_handle, uint32_t dom, int prot,
typedef int XenXC;
typedef int xenevtchn_handle;
-typedef int XenGnttab;
+typedef int xengnttab_handle;
# define XC_INTERFACE_FMT "%i"
# define XC_HANDLER_INITIAL_VALUE -1
@@ -72,11 +72,31 @@ static inline int xenevtchn_close(xenevtchn_handle *h)
#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)
+static inline xengnttab_handle *xengnttab_open(void *logger,
+ unsigned int open_flags)
{
- return xc_gnttab_open();
+ xengnttab_handle *h = malloc(sizeof(*h));
+ if (!h) {
+ return NULL;
+ }
+ *h = xc_gnttab_open();
+ if (*h == -1) {
+ free(h);
+ h = NULL;
+ }
+ return h;
}
+static inline int xengnttab_close(xengnttab_handle *h)
+{
+ int rc = xc_gnttab_close(*h);
+ free(h);
+ return rc;
+}
+#define xengnttab_set_max_grants(h, n) xc_gnttab_set_max_grants(*h, n)
+#define xengnttab_map_grant_ref(h, d, r, p) xc_gnttab_map_grant_ref(*h, d, r, p)
+#define xengnttab_map_grant_refs(h, c, d, r, p) \
+ xc_gnttab_map_grant_refs(*h, c, d, r, p)
+#define xengnttab_unmap(h, a, n) xc_gnttab_munmap(*h, a, n)
static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger,
unsigned int open_flags)
@@ -130,7 +150,7 @@ static inline void xs_close(struct xs_handle *xsh)
typedef xc_interface *XenXC;
typedef xc_evtchn xenevtchn_handle;
-typedef xc_gnttab *XenGnttab;
+typedef xc_gnttab xengnttab_handle;
# define XC_INTERFACE_FMT "%p"
# define XC_HANDLER_INITIAL_VALUE NULL
@@ -144,11 +164,13 @@ typedef xc_gnttab *XenGnttab;
#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)
-{
- return xc_gnttab_open(logger, open_flags);
-}
+#define xengnttab_open(l, f) xc_gnttab_open(l, f)
+#define xengnttab_close(h) xc_gnttab_close(h)
+#define xengnttab_set_max_grants(h, n) xc_gnttab_set_max_grants(h, n)
+#define xengnttab_map_grant_ref(h, d, r, p) xc_gnttab_map_grant_ref(h, d, r, p)
+#define xengnttab_unmap(h, a, n) xc_gnttab_munmap(h, a, n)
+#define xengnttab_map_grant_refs(h, c, d, r, p) \
+ xc_gnttab_map_grant_refs(h, c, d, r, p)
static inline XenXC xen_xc_interface_open(void *logger, void *dombuild_logger,
unsigned int open_flags)