tools: Refactor /dev/xen/evtchn wrappers into libxenevtchn.

libxenevtchn will provide a stable API and ABI for accessing the
evtchn device.

The functions are moved into the xenevtchn namespace to make a clean
break from libxc and avoid ambiguity regarding which interfaces are
stable.

All in-tree users are updated to use the new names.

Upon request (via #define XC_WANT_COMPAT_EVTCHN_API) libxenctrl will
provide a compat API for the old names. This is used by qemu-xen for
the time being. qemu-xen-traditional is updated in lockstep.

This leaves a few event channel related functions which go via privcmd
(EVTCHNOP) rather than ioctls on the /dev/xen/evtchn device in
libxenctrl. Specifically:

 - xc_evtchn_alloc_unbound
 - xc_evtchn_reset
 - xc_evtchn_status

Note that xc_evtchn_alloc_unbound's functionality is also provided by
xenevtchn_bind_unbound_port() (née xc_evtchn_bind_unbound_port) and is
probably redundant.

These functions do not appear to be needed by qemu-dm, qemu-pv
(provision of device model to HVM guests and PV backends respectively)
or by libvchan suggesting they are not needed by non-toolstack uses of
event channels. QEMU does use these in hw/xenpv/xen_domainbuild.c but
that is a "toolstack use".

The new library uses a version script to ensure that only expected
symbols are exported and to version them such that ABI guarantees can
be kept in the future.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
[ ijc -- updated MINIOS_UPSTREAM_REVISION and QEMU_TRADITIONAL_REVISION ]
This commit is contained in:
Ian Campbell committed 2016-01-22 12:21:07 +00:00
1 parent 97d9bc6ca6
commit b7f76a699d
62 files changed
+1544 -930

No files matched your search

+2
View File
@@ -14,8 +14,10 @@ XEN_ROOT=$(CURDIR)/../..
include $(XEN_ROOT)/tools/Rules.mk
CFLAGS += -Werror
CFLAGS += $(CFLAGS_libxenevtchn)
CFLAGS += $(CFLAGS_libxenctrl)
LDLIBS += $(LDLIBS_libxenctrl)
LDLIBS += $(LDLIBS_libxenevtchn)
SCRIPTS = xenmon.py
+7 -6
View File
@@ -37,6 +37,7 @@
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <xenevtchn.h>
#include <xenctrl.h>
#include <xen/xen.h>
#include <string.h>
@@ -267,7 +268,7 @@ static void log_event(int event_id)
}
int virq_port;
xc_evtchn *xce_handle = NULL;
xenevtchn_handle *xce_handle = NULL;
/* Returns the event channel handle. */
/* Stolen from xenstore code */
@@ -279,12 +280,12 @@ static int eventchn_init(void)
if (0)
return -1;
xce_handle = xc_evtchn_open(NULL, 0);
xce_handle = xenevtchn_open(NULL, 0);
if (xce_handle == NULL)
perror("Failed to open evtchn device");
if ((rc = xc_evtchn_bind_virq(xce_handle, VIRQ_TBUF)) == -1)
if ((rc = xenevtchn_bind_virq(xce_handle, VIRQ_TBUF)) == -1)
perror("Failed to bind to domain exception virq port");
virq_port = rc;
@@ -304,7 +305,7 @@ static void wait_for_event(void)
return;
}
evtchn_fd = xc_evtchn_fd(xce_handle);
evtchn_fd = xenevtchn_fd(xce_handle);
FD_ZERO(&inset);
FD_SET(evtchn_fd, &inset);
@@ -314,13 +315,13 @@ static void wait_for_event(void)
ret = select(evtchn_fd+1, &inset, NULL, NULL, &tv);
if ( (ret == 1) && FD_ISSET(evtchn_fd, &inset)) {
if ((port = xc_evtchn_pending(xce_handle)) == -1)
if ((port = xenevtchn_pending(xce_handle)) == -1)
perror("Failed to read from event fd");
// if (port == virq_port)
// printf("got the event I was looking for\r\n");
if (xc_evtchn_unmask(xce_handle, port) == -1)
if (xenevtchn_unmask(xce_handle, port) == -1)
perror("Failed to write to event fd");
}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.