Commit 21305d17 authored by Ian Campbell's avatar Ian Campbell

libxc: convert evtchn interfaces to use an opaque handle type

This makes the interface consistent with the changes made to the main
interface in 21483:779c0ef9682c.

Also fix some references to "struct xc_interface" which should have
been simply "xc_interface" in tools/xenpaging, and update QEMU_TAG to
pull in the corresponding qemu change.
Signed-off-by: default avatarIan Campbell <ian.campbell@citrix.com>
Signed-off-by: default avatarIan Jackson <ian.jackson@eu.citrix.com>
parent 5ac39859
......@@ -185,9 +185,9 @@ endif
# CONFIG_QEMU ?= ../qemu-xen.git
CONFIG_QEMU ?= $(QEMU_REMOTE)
QEMU_TAG ?= 47a25c461b6b5ab67397f7bbb209590a0839e213
# Thu Dec 16 15:50:06 2010 +0000
# stubdom: fix stubdom build following dd9d12dc
QEMU_TAG ?= b7754ca4a80e9a53b848796c860d19d6fa7a6d08
# Thu Dec 23 15:21:52 2010 +0000
# qemu-xen: update for libxc evtchn interface change
# Optional components
XENSTAT_XENTOP ?= y
......
......@@ -68,7 +68,7 @@ static int log_time_guest_needts = 1;
static int log_hv_fd = -1;
static evtchn_port_or_error_t log_hv_evtchn = -1;
static xc_interface *xch; /* why does xenconsoled have two xc handles ? */
static int xce_handle = -1;
static xc_evtchn *xce_handle = NULL;
struct buffer {
char *data;
......@@ -90,7 +90,7 @@ struct domain {
int ring_ref;
evtchn_port_or_error_t local_port;
evtchn_port_or_error_t remote_port;
int xce_handle;
xc_evtchn *xce_handle;
struct xencons_interface *interface;
int event_count;
long long next_period;
......@@ -547,13 +547,13 @@ static int domain_create_ring(struct domain *dom)
dom->local_port = -1;
dom->remote_port = -1;
if (dom->xce_handle != -1)
if (dom->xce_handle != NULL)
xc_evtchn_close(dom->xce_handle);
/* Opening evtchn independently for each console is a bit
* wasteful, but that's how the code is structured... */
dom->xce_handle = xc_evtchn_open();
if (dom->xce_handle == -1) {
dom->xce_handle = xc_evtchn_open(NULL, 0);
if (dom->xce_handle == NULL) {
err = errno;
goto out;
}
......@@ -564,7 +564,7 @@ static int domain_create_ring(struct domain *dom)
if (rc == -1) {
err = errno;
xc_evtchn_close(dom->xce_handle);
dom->xce_handle = -1;
dom->xce_handle = NULL;
goto out;
}
dom->local_port = rc;
......@@ -574,7 +574,7 @@ static int domain_create_ring(struct domain *dom)
if (!domain_create_tty(dom)) {
err = errno;
xc_evtchn_close(dom->xce_handle);
dom->xce_handle = -1;
dom->xce_handle = NULL;
dom->local_port = -1;
dom->remote_port = -1;
goto out;
......@@ -655,7 +655,7 @@ static struct domain *create_domain(int domid)
dom->local_port = -1;
dom->remote_port = -1;
dom->interface = NULL;
dom->xce_handle = -1;
dom->xce_handle = NULL;
if (!watch_domain(dom, true))
goto out;
......@@ -722,9 +722,9 @@ static void shutdown_domain(struct domain *d)
if (d->interface != NULL)
munmap(d->interface, getpagesize());
d->interface = NULL;
if (d->xce_handle != -1)
if (d->xce_handle != NULL)
xc_evtchn_close(d->xce_handle);
d->xce_handle = -1;
d->xce_handle = NULL;
}
void enum_domains(void)
......@@ -933,8 +933,8 @@ void handle_io(void)
errno, strerror(errno));
goto out;
}
xce_handle = xc_evtchn_open();
if (xce_handle == -1) {
xce_handle = xc_evtchn_open(NULL, 0);
if (xce_handle == NULL) {
dolog(LOG_ERR, "Failed to open xce handle: %d (%s)",
errno, strerror(errno));
goto out;
......@@ -994,7 +994,7 @@ void handle_io(void)
if (!next_timeout ||
d->next_period < next_timeout)
next_timeout = d->next_period;
} else if (d->xce_handle != -1) {
} else if (d->xce_handle != NULL) {
if (discard_overflowed_data ||
!d->buffer.max_capacity ||
d->buffer.size < d->buffer.max_capacity) {
......@@ -1055,7 +1055,7 @@ void handle_io(void)
for (d = dom_head; d; d = n) {
n = d->next;
if (d->event_count < RATE_LIMIT_ALLOWANCE) {
if (d->xce_handle != -1 &&
if (d->xce_handle != NULL &&
FD_ISSET(xc_evtchn_fd(d->xce_handle),
&readfds))
handle_ring_read(d);
......@@ -1083,9 +1083,9 @@ void handle_io(void)
xc_interface_close(xch);
xch = 0;
}
if (xce_handle != -1) {
if (xce_handle != NULL) {
xc_evtchn_close(xce_handle);
xce_handle = -1;
xce_handle = NULL;
}
log_hv_evtchn = -1;
}
......
......@@ -228,9 +228,9 @@ static void handle_connection(int frontend_dom_id, int export_id, char *frontend
FS_DEBUG("ERROR: failed to write backend node on xenbus\n");
goto error;
}
mount->evth = -1;
mount->evth = xc_evtchn_open();
if (mount->evth < 0) {
mount->evth = NULL;
mount->evth = xc_evtchn_open(NULL, 0);
if (mount->evth == NULL) {
FS_DEBUG("ERROR: Couldn't open evtchn!\n");
goto error;
}
......@@ -289,7 +289,7 @@ error:
xc_gnttab_close(mount->xch, mount->gnth);
if (mount->local_evtchn > 0)
xc_evtchn_unbind(mount->evth, mount->local_evtchn);
if (mount->evth > 0)
if (mount->evth != NULL)
xc_evtchn_close(mount->evth);
if (mount->xch)
xc_interface_close(mount->xch);
......@@ -343,8 +343,8 @@ static void await_connections(void)
FD_SET(tfd, &fds);
ret = select(tfd + 1, &fds, NULL, NULL, &timeout);
if (ret < 0) {
FS_DEBUG("fd %d is bogus, closing the related connection\n", tfd);
pointer->evth = fd;
FS_DEBUG("fd %d is bogus, closing the related connection %p\n", tfd, pointer->evth);
/*pointer->evth = fd;*/
terminate_mount_request(pointer);
continue;
}
......
......@@ -45,7 +45,7 @@ struct fs_mount
grant_ref_t grefs[MAX_RING_SIZE];
evtchn_port_t remote_evtchn;
xc_interface *xch; /* just for error logging, so a dummy */
int evth; /* Handle to the event channel */
xc_evtchn *evth; /* Handle to the event channel */
evtchn_port_t local_evtchn;
int gnth;
int shared_ring_size; /* in pages */
......
......@@ -35,7 +35,7 @@
static void log_callback(struct elf_binary *elf, void *caller_data,
int iserr, const char *fmt, va_list al) {
struct xc_interface *xch = caller_data;
xc_interface *xch = caller_data;
xc_reportv(xch,
xch->dombuild_logger ? xch->dombuild_logger : xch->error_handler,
......@@ -44,7 +44,7 @@ static void log_callback(struct elf_binary *elf, void *caller_data,
fmt, al);
}
void xc_elf_set_logfile(struct xc_interface *xch, struct elf_binary *elf,
void xc_elf_set_logfile(xc_interface *xch, struct elf_binary *elf,
int verbose) {
elf_set_log(elf, log_callback, xch, verbose);
}
......
......@@ -49,7 +49,7 @@ struct restore_ctx {
#define HEARTBEAT_MS 1000
#ifndef __MINIOS__
static ssize_t rdexact(struct xc_interface *xch, struct restore_ctx *ctx,
static ssize_t rdexact(xc_interface *xch, struct restore_ctx *ctx,
int fd, void* buf, size_t size)
{
size_t offset = 0;
......
......@@ -68,9 +68,9 @@ int xc_interface_open_core(xc_interface *xch)
return -1;
}
int xc_interface_close_core(xc_interface *xch, int fd)
int xc_interface_close_core(xc_interface *xch)
{
return close(fd);
return close(xch->fd);
}
static int xc_map_foreign_batch_single(xc_interface *xch, uint32_t dom,
......@@ -327,42 +327,42 @@ int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
#define DEVXEN "/dev/xen/"
int xc_evtchn_open(void)
int xc_evtchn_open_core(xc_evtchn *xce)
{
return open(DEVXEN "evtchn", O_RDWR);
}
int xc_evtchn_close(int xce_handle)
int xc_evtchn_close_core(xc_evtchn *xce)
{
return close(xce_handle);
return close(xce->fd);
}
int xc_evtchn_fd(int xce_handle)
int xc_evtchn_fd(xc_evtchn *xce)
{
return xce_handle;
return xce->fd;
}
int xc_evtchn_notify(int xce_handle, evtchn_port_t port)
int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port)
{
struct ioctl_evtchn_notify notify;
notify.port = port;
return ioctl(xce_handle, IOCTL_EVTCHN_NOTIFY, &notify);
return ioctl(xce->fd, IOCTL_EVTCHN_NOTIFY, &notify);
}
evtchn_port_or_error_t
xc_evtchn_bind_unbound_port(int xce_handle, int domid)
xc_evtchn_bind_unbound_port(xc_evtchn *xce, int domid)
{
struct ioctl_evtchn_bind_unbound_port bind;
bind.remote_domain = domid;
return ioctl(xce_handle, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind);
return ioctl(xce->fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind);
}
evtchn_port_or_error_t
xc_evtchn_bind_interdomain(int xce_handle, int domid,
xc_evtchn_bind_interdomain(xc_evtchn *xce, int domid,
evtchn_port_t remote_port)
{
struct ioctl_evtchn_bind_interdomain bind;
......@@ -370,42 +370,42 @@ xc_evtchn_bind_interdomain(int xce_handle, int domid,
bind.remote_domain = domid;
bind.remote_port = remote_port;
return ioctl(xce_handle, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind);
return ioctl(xce->fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind);
}
evtchn_port_or_error_t
xc_evtchn_bind_virq(int xce_handle, unsigned int virq)
xc_evtchn_bind_virq(xc_evtchn *xce, unsigned int virq)
{
struct ioctl_evtchn_bind_virq bind;
bind.virq = virq;
return ioctl(xce_handle, IOCTL_EVTCHN_BIND_VIRQ, &bind);
return ioctl(xce->fd, IOCTL_EVTCHN_BIND_VIRQ, &bind);
}
int xc_evtchn_unbind(int xce_handle, evtchn_port_t port)
int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port)
{
struct ioctl_evtchn_unbind unbind;
unbind.port = port;
return ioctl(xce_handle, IOCTL_EVTCHN_UNBIND, &unbind);
return ioctl(xce->fd, IOCTL_EVTCHN_UNBIND, &unbind);
}
evtchn_port_or_error_t
xc_evtchn_pending(int xce_handle)
xc_evtchn_pending(xc_evtchn *xce)
{
evtchn_port_t port;
if ( read_exact(xce_handle, (char *)&port, sizeof(port)) == -1 )
if ( read_exact(xce->fd, (char *)&port, sizeof(port)) == -1 )
return -1;
return port;
}
int xc_evtchn_unmask(int xce_handle, evtchn_port_t port)
int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
{
return write_exact(xce_handle, (char *)&port, sizeof(port));
return write_exact(xce->fd, (char *)&port, sizeof(port));
}
/* Optionally flush file to disk and discard page cache */
......
......@@ -44,6 +44,9 @@ void minios_interface_close_fd(int fd);
void minios_evtchn_close_fd(int fd);
void minios_gnttab_close_fd(int fd);
extern void minios_interface_close_fd(int fd);
extern void minios_evtchn_close_fd(int fd);
extern struct wait_queue_head event_queue;
int xc_interface_open_core(xc_interface *xch)
......@@ -51,9 +54,9 @@ int xc_interface_open_core(xc_interface *xch)
return alloc_fd(FTYPE_XC);
}
int xc_interface_close_core(xc_interface *xch, int fd)
int xc_interface_close_core(xc_interface *xch)
{
return close(fd);
return close(xch->fd);
}
void minios_interface_close_fd(int fd)
......@@ -169,7 +172,7 @@ int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
return call.result;
}
int xc_evtchn_open(void)
int xc_evtchn_open_core(xc_evtchn *xce)
{
int fd = alloc_fd(FTYPE_EVTCHN), i;
for (i = 0; i < MAX_EVTCHN_PORTS; i++) {
......@@ -180,9 +183,9 @@ int xc_evtchn_open(void)
return fd;
}
int xc_evtchn_close(int xce_handle)
int xc_evtchn_close_core(xc_evtchn *xce)
{
return close(xce_handle);
return close(xce->fd);
}
void minios_evtchn_close_fd(int fd)
......@@ -194,12 +197,12 @@ void minios_evtchn_close_fd(int fd)
files[fd].type = FTYPE_NONE;
}
int xc_evtchn_fd(int xce_handle)
int xc_evtchn_fd(xc_evtchn *xce)
{
return xce_handle;
return xce->fd;
}
int xc_evtchn_notify(int xce_handle, evtchn_port_t port)
int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port)
{
int ret;
......@@ -213,144 +216,144 @@ int xc_evtchn_notify(int xce_handle, evtchn_port_t port)
}
/* XXX Note: This is not threadsafe */
static int port_alloc(int xce_handle) {
static int port_alloc(int fd) {
int i;
for (i= 0; i < MAX_EVTCHN_PORTS; i++)
if (files[xce_handle].evtchn.ports[i].port == -1)
if (files[fd].evtchn.ports[i].port == -1)
break;
if (i == MAX_EVTCHN_PORTS) {
printf("Too many ports in xc handle\n");
errno = EMFILE;
return -1;
}
files[xce_handle].evtchn.ports[i].pending = 0;
files[fd].evtchn.ports[i].pending = 0;
return i;
}
static void evtchn_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
{
int xce_handle = (intptr_t) data;
int fd = (int)(intptr_t)data;
int i;
assert(files[xce_handle].type == FTYPE_EVTCHN);
assert(files[fd].type == FTYPE_EVTCHN);
mask_evtchn(port);
for (i= 0; i < MAX_EVTCHN_PORTS; i++)
if (files[xce_handle].evtchn.ports[i].port == port)
if (files[fd].evtchn.ports[i].port == port)
break;
if (i == MAX_EVTCHN_PORTS) {
printk("Unknown port for handle %d\n", xce_handle);
printk("Unknown port for handle %d\n", fd);
return;
}
files[xce_handle].evtchn.ports[i].pending = 1;
files[xce_handle].read = 1;
files[fd].evtchn.ports[i].pending = 1;
files[fd].read = 1;
wake_up(&event_queue);
}
evtchn_port_or_error_t xc_evtchn_bind_unbound_port(int xce_handle, int domid)
evtchn_port_or_error_t xc_evtchn_bind_unbound_port(xc_evtchn *xce, int domid)
{
int ret, i;
evtchn_port_t port;
assert(get_current() == main_thread);
i = port_alloc(xce_handle);
i = port_alloc(xce->fd);
if (i == -1)
return -1;
printf("xc_evtchn_bind_unbound_port(%d)", domid);
ret = evtchn_alloc_unbound(domid, evtchn_handler, (void*)(intptr_t)xce_handle, &port);
ret = evtchn_alloc_unbound(domid, evtchn_handler, (void*)(intptr_t)xce->fd, &port);
printf(" = %d\n", ret);
if (ret < 0) {
errno = -ret;
return -1;
}
files[xce_handle].evtchn.ports[i].bound = 1;
files[xce_handle].evtchn.ports[i].port = port;
files[xce->fd].evtchn.ports[i].bound = 1;
files[xce->fd].evtchn.ports[i].port = port;
unmask_evtchn(port);
return port;
}
evtchn_port_or_error_t xc_evtchn_bind_interdomain(int xce_handle, int domid,
evtchn_port_or_error_t xc_evtchn_bind_interdomain(xc_evtchn *xce, int domid,
evtchn_port_t remote_port)
{
evtchn_port_t local_port;
int ret, i;
assert(get_current() == main_thread);
i = port_alloc(xce_handle);
i = port_alloc(xce->fd);
if (i == -1)
return -1;
printf("xc_evtchn_bind_interdomain(%d, %"PRId32")", domid, remote_port);
ret = evtchn_bind_interdomain(domid, remote_port, evtchn_handler, (void*)(intptr_t)xce_handle, &local_port);
ret = evtchn_bind_interdomain(domid, remote_port, evtchn_handler, (void*)(intptr_t)xce->fd, &local_port);
printf(" = %d\n", ret);
if (ret < 0) {
errno = -ret;
return -1;
}
files[xce_handle].evtchn.ports[i].bound = 1;
files[xce_handle].evtchn.ports[i].port = local_port;
files[xce->fd].evtchn.ports[i].bound = 1;
files[xce->fd].evtchn.ports[i].port = local_port;
unmask_evtchn(local_port);
return local_port;
}
int xc_evtchn_unbind(int xce_handle, evtchn_port_t port)
int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port)
{
int i;
for (i = 0; i < MAX_EVTCHN_PORTS; i++)
if (files[xce_handle].evtchn.ports[i].port == port) {
files[xce_handle].evtchn.ports[i].port = -1;
if (files[xce->fd].evtchn.ports[i].port == port) {
files[xce->fd].evtchn.ports[i].port = -1;
break;
}
if (i == MAX_EVTCHN_PORTS) {
printf("Warning: couldn't find port %"PRId32" for xc handle %x\n", port, xce_handle);
printf("Warning: couldn't find port %"PRId32" for xc handle %x\n", port, xce->fd);
errno = -EINVAL;
return -1;
}
files[xce_handle].evtchn.ports[i].bound = 0;
files[xce->fd].evtchn.ports[i].bound = 0;
unbind_evtchn(port);
return 0;
}
evtchn_port_or_error_t xc_evtchn_bind_virq(int xce_handle, unsigned int virq)
evtchn_port_or_error_t xc_evtchn_bind_virq(xc_evtchn *xce, unsigned int virq)
{
evtchn_port_t port;
int i;
assert(get_current() == main_thread);
i = port_alloc(xce_handle);
i = port_alloc(xce->fd);
if (i == -1)
return -1;
printf("xc_evtchn_bind_virq(%d)", virq);
port = bind_virq(virq, evtchn_handler, (void*)(intptr_t)xce_handle);
port = bind_virq(virq, evtchn_handler, (void*)(intptr_t)xce->fd);
if (port < 0) {
errno = -port;
return -1;
}
files[xce_handle].evtchn.ports[i].bound = 1;
files[xce_handle].evtchn.ports[i].port = port;
files[xce->fd].evtchn.ports[i].bound = 1;
files[xce->fd].evtchn.ports[i].port = port;
unmask_evtchn(port);
return port;
}
evtchn_port_or_error_t xc_evtchn_pending(int xce_handle)
evtchn_port_or_error_t xc_evtchn_pending(xc_evtchn *xce)
{
int i;
unsigned long flags;
evtchn_port_t ret = -1;
local_irq_save(flags);
files[xce_handle].read = 0;
files[xce->fd].read = 0;
for (i = 0; i < MAX_EVTCHN_PORTS; i++) {
evtchn_port_t port = files[xce_handle].evtchn.ports[i].port;
if (port != -1 && files[xce_handle].evtchn.ports[i].pending) {
evtchn_port_t port = files[xce->fd].evtchn.ports[i].port;
if (port != -1 && files[xce->fd].evtchn.ports[i].pending) {
if (ret == -1) {
ret = port;
files[xce_handle].evtchn.ports[i].pending = 0;
files[xce->fd].evtchn.ports[i].pending = 0;
} else {
files[xce_handle].read = 1;
files[xce->fd].read = 1;
break;
}
}
......@@ -359,7 +362,7 @@ evtchn_port_or_error_t xc_evtchn_pending(int xce_handle)
return ret;
}
int xc_evtchn_unmask(int xce_handle, evtchn_port_t port)
int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
{
unmask_evtchn(port);
return 0;
......
......@@ -60,9 +60,9 @@ int xc_interface_open_core(xc_interface *xch)
return -1;
}
int xc_interface_close_core(xc_interface *xch, int fd)
int xc_interface_close_core(xc_interface *xch)
{
return close(fd);
return close(xch->fd);
}
void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
......@@ -181,39 +181,39 @@ int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
#define EVTCHN_DEV_NAME "/dev/xenevt"
int xc_evtchn_open(void)
int xc_evtchn_open_core(xc_evtchn *xce)
{
return open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR);
}
int xc_evtchn_close(int xce_handle)
int xc_evtchn_close_core(xc_evtchn *xce)
{
return close(xce_handle);
return close(xce->fd);
}
int xc_evtchn_fd(int xce_handle)
int xc_evtchn_fd(xc_evtchn *xce)
{
return xce_handle;
return xce->fd;
}
int xc_evtchn_notify(int xce_handle, evtchn_port_t port)
int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port)
{
struct ioctl_evtchn_notify notify;
notify.port = port;
return ioctl(xce_handle, IOCTL_EVTCHN_NOTIFY, &notify);
return ioctl(xce->fd, IOCTL_EVTCHN_NOTIFY, &notify);
}
evtchn_port_or_error_t
xc_evtchn_bind_unbound_port(int xce_handle, int domid)
xc_evtchn_bind_unbound_port(xc_evtchn * xce, int domid)
{
struct ioctl_evtchn_bind_unbound_port bind;
int ret;
bind.remote_domain = domid;
ret = ioctl(xce_handle, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind);
ret = ioctl(xce->fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind);
if (ret == 0)
return bind.port;
else
......@@ -221,7 +221,7 @@ xc_evtchn_bind_unbound_port(int xce_handle, int domid)
}
evtchn_port_or_error_t
xc_evtchn_bind_interdomain(int xce_handle, int domid,
xc_evtchn_bind_interdomain(xc_evtchn *xce, int domid,
evtchn_port_t remote_port)
{
struct ioctl_evtchn_bind_interdomain bind;
......@@ -230,31 +230,31 @@ xc_evtchn_bind_interdomain(int xce_handle, int domid,
bind.remote_domain = domid;
bind.remote_port = remote_port;
ret = ioctl(xce_handle, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind);
ret = ioctl(xce->fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind);
if (ret == 0)
return bind.port;
else
return -1;
}
int xc_evtchn_unbind(int xce_handle, evtchn_port_t port)
int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port)
{
struct ioctl_evtchn_unbind unbind;
unbind.port = port;
return ioctl(xce_handle, IOCTL_EVTCHN_UNBIND, &unbind);
return ioctl(xce->fd, IOCTL_EVTCHN_UNBIND, &unbind);
}
evtchn_port_or_error_t
xc_evtchn_bind_virq(int xce_handle, unsigned int virq)
xc_evtchn_bind_virq(xc_evtchn *xce, unsigned int virq)
{
struct ioctl_evtchn_bind_virq bind;
int err;
bind.virq = virq;
err = ioctl(xce_handle, IOCTL_EVTCHN_BIND_VIRQ, &bind);
err = ioctl(xce->fd, IOCTL_EVTCHN_BIND_VIRQ, &bind);
if (err)
return -1;
else
......@@ -262,19 +262,19 @@ xc_evtchn_bind_virq(int xce_handle, unsigned int virq)
}
evtchn_port_or_error_t
xc_evtchn_pending(int xce_handle)
xc_evtchn_pending(xc_evtchn *xce)
{
evtchn_port_t port;
if ( read_exact(xce_handle, (char *)&port, sizeof(port)) == -1 )
if ( read_exact(xce->fd, (char *)&port, sizeof(port)) == -1 )
return -1;
return port;
}
int xc_evtchn_unmask(int xce_handle, evtchn_port_t port)
int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
{
return write_exact(xce_handle, (char *)&port, sizeof(port));
return write_exact(xce->fd, (char *)&port, sizeof(port));
}
/* Optionally flush file to disk and discard page cache */
......
......@@ -27,11 +27,15 @@
#include <pthread.h>
#include <assert.h>
xc_interface *xc_interface_open(xentoollog_logger *logger,
xentoollog_logger *dombuild_logger,
unsigned open_flags) {
xc_interface xch_buf, *xch = &xch_buf;
static struct xc_interface_core *xc_interface_open_common(xentoollog_logger *logger,
xentoollog_logger *dombuild_logger,
unsigned open_flags,
enum xc_interface_type type,
int (*open_core)(struct xc_interface_core *xch))
{
struct xc_interface_core xch_buf, *xch = &xch_buf;
xch->type = type;
xch->flags = open_flags;
xch->fd = -1;
xch->dombuild_logger_file = 0;
......@@ -57,7 +61,7 @@ xc_interface *xc_interface_open(xentoollog_logger *logger,
*xch = xch_buf;
if (!(open_flags & XC_OPENFLAG_DUMMY)) {
xch->fd = xc_interface_open_core(xch);
xch->fd = open_core(xch