aboutsummaryrefslogtreecommitdiff
path: root/xen-hvm.c
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 /xen-hvm.c
parent549e9bcabc2f5b37b0be8c24257e0b527bffb49a (diff)
downloadqemu-a2db2a1edd06a50b8a862c654cf993368cf9f1d9.zip
qemu-a2db2a1edd06a50b8a862c654cf993368cf9f1d9.tar.gz
qemu-a2db2a1edd06a50b8a862c654cf993368cf9f1d9.tar.bz2
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 'xen-hvm.c')
-rw-r--r--xen-hvm.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/xen-hvm.c b/xen-hvm.c
index a9085a8..1b6fa9e 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -110,7 +110,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;
@@ -717,7 +717,7 @@ static ioreq_t *cpu_get_ioreq(XenIOState *state)
int i;
evtchn_port_t port;
- port = xc_evtchn_pending(state->xce_handle);
+ port = xenevtchn_pending(state->xce_handle);
if (port == state->bufioreq_local_port) {
timer_mod(state->buffered_io_timer,
BUFFER_IO_MAX_DELAY + qemu_clock_get_ms(QEMU_CLOCK_REALTIME));
@@ -736,7 +736,7 @@ static ioreq_t *cpu_get_ioreq(XenIOState *state)
}
/* unmask the wanted port again */
- xc_evtchn_unmask(state->xce_handle, port);
+ xenevtchn_unmask(state->xce_handle, port);
/* get the io packet from shared memory */
state->send_vcpu = i;
@@ -1043,7 +1043,7 @@ static void handle_buffered_io(void *opaque)
BUFFER_IO_MAX_DELAY + qemu_clock_get_ms(QEMU_CLOCK_REALTIME));
} else {
timer_del(state->buffered_io_timer);
- xc_evtchn_unmask(state->xce_handle, state->bufioreq_local_port);
+ xenevtchn_unmask(state->xce_handle, state->bufioreq_local_port);
}
}
@@ -1087,7 +1087,8 @@ static void cpu_handle_ioreq(void *opaque)
}
req->state = STATE_IORESP_READY;
- xc_evtchn_notify(state->xce_handle, state->ioreq_local_port[state->send_vcpu]);
+ xenevtchn_notify(state->xce_handle,
+ state->ioreq_local_port[state->send_vcpu]);
}
}
@@ -1095,8 +1096,8 @@ static void xen_main_loop_prepare(XenIOState *state)
{
int evtchn_fd = -1;
- if (state->xce_handle != XC_HANDLER_INITIAL_VALUE) {
- evtchn_fd = xc_evtchn_fd(state->xce_handle);
+ if (state->xce_handle != NULL) {
+ evtchn_fd = xenevtchn_fd(state->xce_handle);
}
state->buffered_io_timer = timer_new_ms(QEMU_CLOCK_REALTIME, handle_buffered_io,
@@ -1134,7 +1135,7 @@ static void xen_exit_notifier(Notifier *n, void *data)
{
XenIOState *state = container_of(n, XenIOState, exit);
- xc_evtchn_close(state->xce_handle);
+ xenevtchn_close(state->xce_handle);
xs_daemon_close(state->xenstore);
}
@@ -1201,8 +1202,8 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
state = g_malloc0(sizeof (XenIOState));
- state->xce_handle = xen_xc_evtchn_open(NULL, 0);
- if (state->xce_handle == XC_HANDLER_INITIAL_VALUE) {
+ state->xce_handle = xenevtchn_open(NULL, 0);
+ if (state->xce_handle == NULL) {
perror("xen: event channel open");
goto err;
}
@@ -1289,7 +1290,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
/* FIXME: how about if we overflow the page here? */
for (i = 0; i < max_cpus; i++) {
- rc = xc_evtchn_bind_interdomain(state->xce_handle, xen_domid,
+ rc = xenevtchn_bind_interdomain(state->xce_handle, xen_domid,
xen_vcpu_eport(state->shared_page, i));
if (rc == -1) {
error_report("shared evtchn %d bind error %d", i, errno);
@@ -1298,7 +1299,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
state->ioreq_local_port[i] = rc;
}
- rc = xc_evtchn_bind_interdomain(state->xce_handle, xen_domid,
+ rc = xenevtchn_bind_interdomain(state->xce_handle, xen_domid,
bufioreq_evtchn);
if (rc == -1) {
error_report("buffered evtchn bind error %d", errno);