# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1293117957 0
# Node ID 60782cefa154febb7f84e7c7b4e286b1728c692c
# Parent a3ace503d04b7debd75f5898faadd0c7bc20c619
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: Ian Campbell <ian.campbell@xxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
Config.mk | 6 -
tools/console/daemon/io.c | 32 ++---
tools/fs-back/fs-backend.c | 12 +-
tools/fs-back/fs-backend.h | 2
tools/libxc/xc_dom_elfloader.c | 4
tools/libxc/xc_domain_restore.c | 2
tools/libxc/xc_linux.c | 62 +++++------
tools/libxc/xc_minios.c | 103 +++++++++----------
tools/libxc/xc_netbsd.c | 70 ++++++------
tools/libxc/xc_private.c | 45 ++++++--
tools/libxc/xc_private.h | 15 ++
tools/libxc/xc_solaris.c | 80 +++++++-------
tools/libxc/xc_suspend.c | 6 -
tools/libxc/xenctrl.h | 35 +++---
tools/libxc/xenguest.h | 10 -
tools/libxl/libxl_dom.c | 14 +-
tools/misc/xen-hptool.c | 11 +-
tools/python/xen/lowlevel/checkpoint/checkpoint.h | 2
tools/python/xen/lowlevel/checkpoint/libcheckpoint.c | 12 +-
tools/xcutils/xc_save.c | 13 +-
tools/xenmon/xenbaked.c | 12 +-
tools/xenpaging/mem_event.h | 2
tools/xenpaging/policy_default.c | 2
tools/xenpaging/xc.c | 12 +-
tools/xenpaging/xc.h | 4
tools/xenpaging/xenpaging.c | 14 +-
tools/xenstore/xenstored_core.c | 6 -
tools/xenstore/xenstored_domain.c | 13 --
tools/xenstore/xenstored_domain.h | 3
tools/xentrace/xentrace.c | 17 +--
30 files changed, 329 insertions(+), 292 deletions(-)
diff -r a3ace503d04b -r 60782cefa154 Config.mk
--- a/Config.mk Thu Dec 23 15:08:21 2010 +0000
+++ b/Config.mk Thu Dec 23 15:25:57 2010 +0000
@@ -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
diff -r a3ace503d04b -r 60782cefa154 tools/console/daemon/io.c
--- a/tools/console/daemon/io.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/console/daemon/io.c Thu Dec 23 15:25:57 2010 +0000
@@ -68,7 +68,7 @@ static int log_hv_fd = -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 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 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 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
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 domai
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;
}
diff -r a3ace503d04b -r 60782cefa154 tools/fs-back/fs-backend.c
--- a/tools/fs-back/fs-backend.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/fs-back/fs-backend.c Thu Dec 23 15:25:57 2010 +0000
@@ -228,9 +228,9 @@ static void handle_connection(int fronte
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;
}
diff -r a3ace503d04b -r 60782cefa154 tools/fs-back/fs-backend.h
--- a/tools/fs-back/fs-backend.h Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/fs-back/fs-backend.h Thu Dec 23 15:25:57 2010 +0000
@@ -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 */
diff -r a3ace503d04b -r 60782cefa154 tools/libxc/xc_dom_elfloader.c
--- a/tools/libxc/xc_dom_elfloader.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/libxc/xc_dom_elfloader.c Thu Dec 23 15:25:57 2010 +0000
@@ -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_bina
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);
}
diff -r a3ace503d04b -r 60782cefa154 tools/libxc/xc_domain_restore.c
--- a/tools/libxc/xc_domain_restore.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/libxc/xc_domain_restore.c Thu Dec 23 15:25:57 2010 +0000
@@ -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;
diff -r a3ace503d04b -r 60782cefa154 tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/libxc/xc_linux.c Thu Dec 23 15:25:57 2010 +0000
@@ -68,9 +68,9 @@ int xc_interface_open_core(xc_interface
return -1;
}
-int xc_interface_close_core(xc_interface *xch, int fd)
-{
- return close(fd);
+int xc_interface_close_core(xc_interface *xch)
+{
+ 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,
#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)
-{
- return close(xce_handle);
-}
-
-int xc_evtchn_fd(int xce_handle)
-{
- return xce_handle;
-}
-
-int xc_evtchn_notify(int xce_handle, evtchn_port_t port)
+int xc_evtchn_close_core(xc_evtchn *xce)
+{
+ return close(xce->fd);
+}
+
+int xc_evtchn_fd(xc_evtchn *xce)
+{
+ return xce->fd;
+}
+
+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, ¬ify);
+ return ioctl(xce->fd, IOCTL_EVTCHN_NOTIFY, ¬ify);
}
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_handl
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);
-}
-
-int xc_evtchn_unbind(int xce_handle, evtchn_port_t port)
+ return ioctl(xce->fd, IOCTL_EVTCHN_BIND_VIRQ, &bind);
+}
+
+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)
-{
- return write_exact(xce_handle, (char *)&port, sizeof(port));
+int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
+{
+ return write_exact(xce->fd, (char *)&port, sizeof(port));
}
/* Optionally flush file to disk and discard page cache */
diff -r a3ace503d04b -r 60782cefa154 tools/libxc/xc_minios.c
--- a/tools/libxc/xc_minios.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/libxc/xc_minios.c Thu Dec 23 15:25:57 2010 +0000
@@ -44,6 +44,9 @@ void minios_evtchn_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
return alloc_fd(FTYPE_XC);
}
-int xc_interface_close_core(xc_interface *xch, int fd)
-{
- return close(fd);
+int xc_interface_close_core(xc_interface *xch)
+{
+ return close(xch->fd);
}
void minios_interface_close_fd(int fd)
@@ -169,7 +172,7 @@ int do_xen_hypercall(xc_interface *xch,
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)
-{
- return close(xce_handle);
+int xc_evtchn_close_core(xc_evtchn *xce)
+{
+ 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)
-{
- return xce_handle;
-}
-
-int xc_evtchn_notify(int xce_handle, evtchn_port_t port)
+int xc_evtchn_fd(xc_evtchn *xce)
+{
+ return xce->fd;
+}
+
+int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port)
{
int ret;
@@ -213,144 +216,144 @@ int xc_evtchn_notify(int xce_handle, evt
}
/* 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 i;
- assert(files[xce_handle].type == FTYPE_EVTCHN);
+ int fd = (int)(intptr_t)data;
+ int i;
+ 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
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;
diff -r a3ace503d04b -r 60782cefa154 tools/libxc/xc_netbsd.c
--- a/tools/libxc/xc_netbsd.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/libxc/xc_netbsd.c Thu Dec 23 15:25:57 2010 +0000
@@ -60,9 +60,9 @@ int xc_interface_open_core(xc_interface
return -1;
}
-int xc_interface_close_core(xc_interface *xch, int fd)
-{
- return close(fd);
+int xc_interface_close_core(xc_interface *xch)
+{
+ 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,
#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)
-{
- return close(xce_handle);
-}
-
-int xc_evtchn_fd(int xce_handle)
-{
- return xce_handle;
-}
-
-int xc_evtchn_notify(int xce_handle, evtchn_port_t port)
+int xc_evtchn_close_core(xc_evtchn *xce)
+{
+ return close(xce->fd);
+}
+
+int xc_evtchn_fd(xc_evtchn *xce)
+{
+ return xce->fd;
+}
+
+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, ¬ify);
-}
-
-evtchn_port_or_error_t
-xc_evtchn_bind_unbound_port(int xce_handle, int domid)
+ return ioctl(xce->fd, IOCTL_EVTCHN_NOTIFY, ¬ify);
+}
+
+evtchn_port_or_error_t
+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_hand
}
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_handl
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);
-}
-
-evtchn_port_or_error_t
-xc_evtchn_bind_virq(int xce_handle, unsigned int virq)
+ return ioctl(xce->fd, IOCTL_EVTCHN_UNBIND, &unbind);
+}
+
+evtchn_port_or_error_t
+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, unsi
}
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)
-{
- return write_exact(xce_handle, (char *)&port, sizeof(port));
+int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
+{
+ return write_exact(xce->fd, (char *)&port, sizeof(port));
}
/* Optionally flush file to disk and discard page cache */
diff -r a3ace503d04b -r 60782cefa154 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/libxc/xc_private.c Thu Dec 23 15:25:57 2010 +0000
@@ -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(xentooll
*xch = xch_buf;
if (!(open_flags & XC_OPENFLAG_DUMMY)) {
- xch->fd = xc_interface_open_core(xch);
+ xch->fd = open_core(xch);
if (xch->fd < 0)
goto err;
}
@@ -70,7 +74,7 @@ xc_interface *xc_interface_open(xentooll
return 0;
}
-int xc_interface_close(xc_interface *xch)
+static int xc_interface_close_common(xc_interface *xch, int
(*close_core)(struct xc_interface_core *xch))
{
int rc = 0;
@@ -78,12 +82,37 @@ int xc_interface_close(xc_interface *xch
xtl_logger_destroy(xch->error_handler_tofree);
if (xch->fd >= 0) {
- rc = xc_interface_close_core(xch, xch->fd);
+ rc = close_core(xch);
if (rc) PERROR("Could not close hypervisor interface");
}
free(xch);
return rc;
+}
+
+xc_interface *xc_interface_open(xentoollog_logger *logger,
+ xentoollog_logger *dombuild_logger,
+ unsigned open_flags)
+{
+ return xc_interface_open_common(logger, dombuild_logger, open_flags,
+ XC_INTERFACE_PRIVCMD,
&xc_interface_open_core);
+}
+
+int xc_interface_close(xc_interface *xch)
+{
+ return xc_interface_close_common(xch, &xc_interface_close_core);
+}
+
+xc_evtchn *xc_evtchn_open(xentoollog_logger *logger,
+ unsigned open_flags)
+{
+ return xc_interface_open_common(logger, NULL, open_flags,
+ XC_INTERFACE_EVTCHN, &xc_evtchn_open_core);
+}
+
+int xc_evtchn_close(xc_evtchn *xce)
+{
+ return xc_interface_close_common(xce, &xc_evtchn_close_core);
}
static pthread_key_t errbuf_pkey;
diff -r a3ace503d04b -r 60782cefa154 tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/libxc/xc_private.h Thu Dec 23 15:25:57 2010 +0000
@@ -65,7 +65,13 @@
*/
#define MAX_PAGECACHE_USAGE (4*1024)
-struct xc_interface {
+enum xc_interface_type {
+ XC_INTERFACE_PRIVCMD,
+ XC_INTERFACE_EVTCHN,
+};
+
+struct xc_interface_core {
+ enum xc_interface_type type;
int fd;
int flags;
xentoollog_logger *error_handler, *error_handler_tofree;
@@ -257,8 +263,11 @@ static inline int do_sysctl(xc_interface
int do_memory_op(xc_interface *xch, int cmd, void *arg, size_t len);
-int xc_interface_open_core(xc_interface *xch); /* returns fd, logs errors */
-int xc_interface_close_core(xc_interface *xch, int fd); /* no logging */
+int xc_interface_open_core(struct xc_interface_core *xch); /* returns fd, logs
errors */
+int xc_interface_close_core(struct xc_interface_core *xch); /* no logging */
+
+int xc_evtchn_open_core(struct xc_interface_core *xce); /* returns fd, logs
errors */
+int xc_evtchn_close_core(struct xc_interface_core *xce); /* no logging */
void *xc_map_foreign_ranges(xc_interface *xch, uint32_t dom,
size_t size, int prot, size_t chunksize,
diff -r a3ace503d04b -r 60782cefa154 tools/libxc/xc_solaris.c
--- a/tools/libxc/xc_solaris.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/libxc/xc_solaris.c Thu Dec 23 15:25:57 2010 +0000
@@ -167,7 +167,7 @@ int do_xen_hypercall(xc_interface *xch,
(unsigned long)hypercall);
}
-int xc_evtchn_open(void)
+int xc_evtchn_open_core(xc_evtchn *xce)
{
int fd;
@@ -180,37 +180,37 @@ int xc_evtchn_open(void)
return fd;
}
-int xc_evtchn_close(int xce_handle)
-{
- return close(xce_handle);
-}
-
-int xc_evtchn_fd(int xce_handle)
-{
- return xce_handle;
-}
-
-int xc_evtchn_notify(int xce_handle, evtchn_port_t port)
+int xc_evtchn_close_core(xc_evtchn *xce)
+{
+ return close(xce->fd);
+}
+
+int xc_evtchn_fd(xc_evtchn *xce)
+{
+ return xce->fd;
+}
+
+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, ¬ify);
-}
-
-evtchn_port_or_error_t
-xc_evtchn_bind_unbound_port(int xce_handle, int domid)
+ return ioctl(xce->fd, IOCTL_EVTCHN_NOTIFY, ¬ify);
+}
+
+evtchn_port_or_error_t
+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);
-}
-
-evtchn_port_or_error_t
-xc_evtchn_bind_interdomain(int xce_handle, int domid,
+ return ioctl(xce->fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind);
+}
+
+evtchn_port_or_error_t
+xc_evtchn_bind_interdomain(xc_evtchn *xce, int domid,
evtchn_port_t remote_port)
{
struct ioctl_evtchn_bind_interdomain bind;
@@ -218,42 +218,42 @@ xc_evtchn_bind_interdomain(int xce_handl
bind.remote_domain = domid;
bind.remote_port = remote_port;
- return ioctl(xce_handle, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind);
-}
-
-evtchn_port_or_error_t
-xc_evtchn_bind_virq(int xce_handle, unsigned int virq)
+ return ioctl(xce->fd, IOCTL_EVTCHN_BIND_INTERDOMAIN, &bind);
+}
+
+evtchn_port_or_error_t
+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);
-}
-
-int xc_evtchn_unbind(int xce_handle, evtchn_port_t port)
+ return ioctl(xce->fd, IOCTL_EVTCHN_BIND_VIRQ, &bind);
+}
+
+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);
-}
-
-evtchn_port_or_error_t
-xc_evtchn_pending(int xce_handle)
+ return ioctl(xce->fd, IOCTL_EVTCHN_UNBIND, &unbind);
+}
+
+evtchn_port_or_error_t
+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)
-{
- return write_exact(xce_handle, (char *)&port, sizeof(port));
+int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port)
+{
+ return write_exact(xce->fd, (char *)&port, sizeof(port));
}
/* Optionally flush file to disk and discard page cache */
diff -r a3ace503d04b -r 60782cefa154 tools/libxc/xc_suspend.c
--- a/tools/libxc/xc_suspend.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/libxc/xc_suspend.c Thu Dec 23 15:25:57 2010 +0000
@@ -75,7 +75,7 @@ static int unlock_suspend_event(xc_inter
return -EPERM;
}
-int xc_await_suspend(xc_interface *xch, int xce, int suspend_evtchn)
+int xc_await_suspend(xc_interface *xch, xc_evtchn *xce, int suspend_evtchn)
{
int rc;
@@ -94,7 +94,7 @@ int xc_await_suspend(xc_interface *xch,
return 0;
}
-int xc_suspend_evtchn_release(xc_interface *xch, int xce, int domid, int
suspend_evtchn)
+int xc_suspend_evtchn_release(xc_interface *xch, xc_evtchn *xce, int domid,
int suspend_evtchn)
{
if (suspend_evtchn >= 0)
xc_evtchn_unbind(xce, suspend_evtchn);
@@ -102,7 +102,7 @@ int xc_suspend_evtchn_release(xc_interfa
return unlock_suspend_event(xch, domid);
}
-int xc_suspend_evtchn_init(xc_interface *xch, int xce, int domid, int port)
+int xc_suspend_evtchn_init(xc_interface *xch, xc_evtchn *xce, int domid, int
port)
{
int rc, suspend_evtchn = -1;
diff -r a3ace503d04b -r 60782cefa154 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/libxc/xenctrl.h Thu Dec 23 15:25:57 2010 +0000
@@ -104,7 +104,8 @@
* the callback.
*/
-typedef struct xc_interface xc_interface;
+typedef struct xc_interface_core xc_interface;
+typedef struct xc_interface_core xc_evtchn;
typedef enum xc_error_code xc_error_code;
@@ -826,38 +827,38 @@ int xc_evtchn_status(xc_interface *xch,
*
* Before Xen pre-4.1 this function would sometimes report errors with perror.
*/
-int xc_evtchn_open(void);
+xc_evtchn *xc_evtchn_open(xentoollog_logger *logger,
+ unsigned open_flags);
/*
* Close a handle previously allocated with xc_evtchn_open().
*/
-int xc_evtchn_close(int xce_handle);
-
-/*
- * Return an fd that can be select()ed on for further calls to
- * xc_evtchn_pending().
- */
-int xc_evtchn_fd(int xce_handle);
+int xc_evtchn_close(xc_evtchn *xce);
+
+/*
+ * Return an fd that can be select()ed on.
+ */
+int xc_evtchn_fd(xc_evtchn *xce);
/*
* Notify the given event channel. Returns -1 on failure, in which case
* errno will be set appropriately.
*/
-int xc_evtchn_notify(int xce_handle, evtchn_port_t port);
+int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port);
/*
* Returns a new event port awaiting interdomain connection from the given
* domain ID, or -1 on failure, in which case errno will be set appropriately.
*/
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);
/*
* Returns a new event port bound to the remote port for the given domain ID,
* or -1 on failure, in which case errno will be set appropriately.
*/
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);
/*
@@ -865,26 +866,26 @@ xc_evtchn_bind_interdomain(int xce_handl
* the VIRQ, or -1 on failure, in which case errno will be set appropriately.
*/
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);
/*
* Unbind the given event channel. Returns -1 on failure, in which case errno
* will be set appropriately.
*/
-int xc_evtchn_unbind(int xce_handle, evtchn_port_t port);
+int xc_evtchn_unbind(xc_evtchn *xce, evtchn_port_t port);
/*
* Return the next event channel to become pending, or -1 on failure, in which
* case errno will be set appropriately.
*/
evtchn_port_or_error_t
-xc_evtchn_pending(int xce_handle);
+xc_evtchn_pending(xc_evtchn *xce);
/*
* Unmask the given event channel. Returns -1 on failure, in which case errno
* will be set appropriately.
*/
-int xc_evtchn_unmask(int xce_handle, evtchn_port_t port);
+int xc_evtchn_unmask(xc_evtchn *xce, evtchn_port_t port);
int xc_physdev_pci_access_modify(xc_interface *xch,
uint32_t domid,
@@ -1754,7 +1755,7 @@ int xc_flask_setavc_threshold(xc_interfa
int xc_flask_setavc_threshold(xc_interface *xc_handle, int threshold);
struct elf_binary;
-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);
/* Useful for callers who also use libelf. */
diff -r a3ace503d04b -r 60782cefa154 tools/libxc/xenguest.h
--- a/tools/libxc/xenguest.h Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/libxc/xenguest.h Thu Dec 23 15:25:57 2010 +0000
@@ -173,11 +173,11 @@ int xc_hvm_build_mem(xc_interface *xch,
const char *image_buffer,
unsigned long image_size);
-int xc_suspend_evtchn_release(xc_interface *xch, int xce, int domid, int
suspend_evtchn);
-
-int xc_suspend_evtchn_init(xc_interface *xch, int xce, int domid, int port);
-
-int xc_await_suspend(xc_interface *xch, int xce, int suspend_evtchn);
+int xc_suspend_evtchn_release(xc_interface *xch, xc_evtchn *xce, int domid,
int suspend_evtchn);
+
+int xc_suspend_evtchn_init(xc_interface *xch, xc_evtchn *xce, int domid, int
port);
+
+int xc_await_suspend(xc_interface *xch, xc_evtchn *xce, int suspend_evtchn);
int xc_get_bit_size(xc_interface *xch,
const char *image_name, const char *cmdline,
diff -r a3ace503d04b -r 60782cefa154 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/libxl/libxl_dom.c Thu Dec 23 15:25:57 2010 +0000
@@ -315,7 +315,7 @@ int libxl__domain_restore_common(libxl_c
struct suspendinfo {
libxl__gc *gc;
- int xce; /* event channel handle */
+ xc_evtchn *xce; /* event channel handle */
int suspend_eventchn;
int domid;
int hvm;
@@ -419,11 +419,11 @@ int libxl__domain_suspend_common(libxl_c
si.gc = &gc;
si.suspend_eventchn = -1;
- si.xce = xc_evtchn_open();
- if (si.xce < 0)
- goto out;
-
- if (si.xce > 0) {
+ si.xce = xc_evtchn_open(NULL, 0);
+ if (si.xce == NULL)
+ goto out;
+ else
+ {
port = xs_suspend_evtchn_port(si.domid);
if (port >= 0) {
@@ -447,7 +447,7 @@ int libxl__domain_suspend_common(libxl_c
if (si.suspend_eventchn > 0)
xc_suspend_evtchn_release(ctx->xch, si.xce, domid,
si.suspend_eventchn);
- if (si.xce > 0)
+ if (si.xce != NULL)
xc_evtchn_close(si.xce);
out:
diff -r a3ace503d04b -r 60782cefa154 tools/misc/xen-hptool.c
--- a/tools/misc/xen-hptool.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/misc/xen-hptool.c Thu Dec 23 15:25:57 2010 +0000
@@ -98,7 +98,7 @@ static int hp_mem_query_func(int argc, c
extern int xs_suspend_evtchn_port(int domid);
-static int suspend_guest(xc_interface *xch, int xce, int domid, int *evtchn)
+static int suspend_guest(xc_interface *xch, xc_evtchn *xce, int domid, int
*evtchn)
{
int port, rc, suspend_evtchn = -1;
@@ -192,10 +192,11 @@ static int hp_mem_offline_func(int argc,
}
else if (status & PG_OFFLINE_OWNED)
{
- int result, xce, suspend_evtchn = -1;
- xce = xc_evtchn_open();
-
- if (xce < 0)
+ int result, suspend_evtchn = -1;
+ xc_evtchn *xce;
+ xce = xc_evtchn_open(NULL, 0);
+
+ if (xce == NULL)
{
fprintf(stderr, "When exchange page, fail"
" to open evtchn\n");
diff -r a3ace503d04b -r 60782cefa154
tools/python/xen/lowlevel/checkpoint/checkpoint.h
--- a/tools/python/xen/lowlevel/checkpoint/checkpoint.h Thu Dec 23 15:08:21
2010 +0000
+++ b/tools/python/xen/lowlevel/checkpoint/checkpoint.h Thu Dec 23 15:25:57
2010 +0000
@@ -19,7 +19,7 @@ typedef enum {
typedef struct {
xc_interface *xch;
- int xce; /* event channel handle */
+ xc_evtchn *xce; /* event channel handle */
struct xs_handle* xsh; /* xenstore handle */
int watching_shutdown; /* state of watch on @releaseDomain */
diff -r a3ace503d04b -r 60782cefa154
tools/python/xen/lowlevel/checkpoint/libcheckpoint.c
--- a/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c Thu Dec 23
15:08:21 2010 +0000
+++ b/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c Thu Dec 23
15:25:57 2010 +0000
@@ -48,7 +48,7 @@ void checkpoint_init(checkpoint_state* s
void checkpoint_init(checkpoint_state* s)
{
s->xch = NULL;
- s->xce = -1;
+ s->xce = NULL;
s->xsh = NULL;
s->watching_shutdown = 0;
@@ -89,8 +89,8 @@ int checkpoint_open(checkpoint_state* s,
return -1;
}
- s->xce = xc_evtchn_open();
- if (s->xce < 0) {
+ s->xce = xc_evtchn_open(NULL, 0);
+ if (s->xce == NULL) {
checkpoint_close(s);
s->errstr = "could not open event channel handle";
@@ -149,9 +149,9 @@ void checkpoint_close(checkpoint_state*
xc_interface_close(s->xch);
s->xch = NULL;
}
- if (s->xce >= 0) {
+ if (s->xce != NULL) {
xc_evtchn_close(s->xce);
- s->xce = -1;
+ s->xce = NULL;
}
if (s->xsh) {
xs_daemon_close(s->xsh);
@@ -360,7 +360,7 @@ static void release_suspend_evtchn(check
static void release_suspend_evtchn(checkpoint_state *s)
{
/* TODO: teach xen to clean up if port is unbound */
- if (s->xce >= 0 && s->suspend_evtchn >= 0) {
+ if (s->xce != NULL && s->suspend_evtchn >= 0) {
xc_suspend_evtchn_release(s->xch, s->xce, s->domid, s->suspend_evtchn);
s->suspend_evtchn = -1;
}
diff -r a3ace503d04b -r 60782cefa154 tools/xcutils/xc_save.c
--- a/tools/xcutils/xc_save.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/xcutils/xc_save.c Thu Dec 23 15:25:57 2010 +0000
@@ -25,7 +25,7 @@
static struct suspendinfo {
xc_interface *xch;
- int xce; /* event channel handle */
+ xc_evtchn *xce; /* event channel handle */
int suspend_evtchn;
int domid;
unsigned int flags;
@@ -183,13 +183,12 @@ main(int argc, char **argv)
max_f = atoi(argv[4]);
si.flags = atoi(argv[5]);
- si.suspend_evtchn = si.xce = -1;
-
- si.xce = xc_evtchn_open();
- if (si.xce < 0)
+ si.suspend_evtchn = -1;
+
+ si.xce = xc_evtchn_open(NULL, 0);
+ if (si.xce == NULL)
warnx("failed to open event channel handle");
-
- if (si.xce > 0)
+ else
{
port = xs_suspend_evtchn_port(si.domid);
diff -r a3ace503d04b -r 60782cefa154 tools/xenmon/xenbaked.c
--- a/tools/xenmon/xenbaked.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/xenmon/xenbaked.c Thu Dec 23 15:25:57 2010 +0000
@@ -268,7 +268,7 @@ static void log_event(int event_id)
}
int virq_port;
-int xce_handle = -1;
+xc_evtchn *xce_handle = NULL;
/* Returns the event channel handle. */
/* Stolen from xenstore code */
@@ -280,16 +280,16 @@ static int eventchn_init(void)
if (0)
return -1;
- xce_handle = xc_evtchn_open();
-
- if (xce_handle < 0)
+ xce_handle = xc_evtchn_open(NULL, 0);
+
+ if (xce_handle == NULL)
perror("Failed to open evtchn device");
if ((rc = xc_evtchn_bind_virq(xce_handle, VIRQ_TBUF)) == -1)
perror("Failed to bind to domain exception virq port");
virq_port = rc;
- return xce_handle;
+ return xce_handle == NULL ? -1 : 0;
}
static void wait_for_event(void)
@@ -300,7 +300,7 @@ static void wait_for_event(void)
struct timeval tv;
int evtchn_fd;
- if (xce_handle < 0) {
+ if (xce_handle == NULL) {
nanosleep(&opts.poll_sleep, NULL);
return;
}
diff -r a3ace503d04b -r 60782cefa154 tools/xenpaging/mem_event.h
--- a/tools/xenpaging/mem_event.h Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/xenpaging/mem_event.h Thu Dec 23 15:25:57 2010 +0000
@@ -40,7 +40,7 @@
typedef struct mem_event {
domid_t domain_id;
- int xce_handle;
+ xc_evtchn *xce_handle;
int port;
mem_event_back_ring_t back_ring;
mem_event_shared_page_t *shared_page;
diff -r a3ace503d04b -r 60782cefa154 tools/xenpaging/policy_default.c
--- a/tools/xenpaging/policy_default.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/xenpaging/policy_default.c Thu Dec 23 15:25:57 2010 +0000
@@ -70,7 +70,7 @@ int policy_choose_victim(xenpaging_t *pa
int policy_choose_victim(xenpaging_t *paging, domid_t domain_id,
xenpaging_victim_t *victim)
{
- struct xc_interface *xch = paging->xc_handle;
+ xc_interface *xch = paging->xc_handle;
unsigned long wrap = current_gfn;
ASSERT(victim != NULL);
diff -r a3ace503d04b -r 60782cefa154 tools/xenpaging/xc.c
--- a/tools/xenpaging/xc.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/xenpaging/xc.c Thu Dec 23 15:25:57 2010 +0000
@@ -65,9 +65,9 @@ int xc_mem_paging_flush_ioemu_cache(domi
return rc;
}
-int xc_wait_for_event_or_timeout(xc_interface *xch, int xce_handle, unsigned
long ms)
+int xc_wait_for_event_or_timeout(xc_interface *xch, xc_evtchn *xce, unsigned
long ms)
{
- struct pollfd fd = { .fd = xce_handle, .events = POLLIN | POLLERR };
+ struct pollfd fd = { .fd = xc_evtchn_fd(xce), .events = POLLIN | POLLERR };
int port;
int rc;
@@ -83,14 +83,14 @@ int xc_wait_for_event_or_timeout(xc_inte
if ( rc == 1 )
{
- port = xc_evtchn_pending(xce_handle);
+ port = xc_evtchn_pending(xce);
if ( port == -1 )
{
ERROR("Failed to read port from event channel");
goto err;
}
- rc = xc_evtchn_unmask(xce_handle, port);
+ rc = xc_evtchn_unmask(xce, port);
if ( rc != 0 )
{
ERROR("Failed to unmask event channel port");
@@ -106,9 +106,9 @@ int xc_wait_for_event_or_timeout(xc_inte
return -errno;
}
-int xc_wait_for_event(xc_interface *xch, int xce_handle)
+int xc_wait_for_event(xc_interface *xch, xc_evtchn *xce)
{
- return xc_wait_for_event_or_timeout(xch, xce_handle, -1);
+ return xc_wait_for_event_or_timeout(xch, xce, -1);
}
int xc_get_platform_info(xc_interface *xc_handle, domid_t domain_id,
diff -r a3ace503d04b -r 60782cefa154 tools/xenpaging/xc.h
--- a/tools/xenpaging/xc.h Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/xenpaging/xc.h Thu Dec 23 15:25:57 2010 +0000
@@ -53,8 +53,8 @@ int alloc_bitmap(unsigned long **bitmap,
int alloc_bitmap(unsigned long **bitmap, unsigned long bitmap_size);
int xc_mem_paging_flush_ioemu_cache(domid_t domain_id);
-int xc_wait_for_event(xc_interface *xch, int xce_handle);
-int xc_wait_for_event_or_timeout(xc_interface *xch, int xce_handle, unsigned
long ms);
+int xc_wait_for_event(xc_interface *xch, xc_evtchn *xce);
+int xc_wait_for_event_or_timeout(xc_interface *xch, xc_evtchn *xce, unsigned
long ms);
int xc_get_platform_info(xc_interface *xc_handle, domid_t domain_id,
xc_platform_info_t *platform_info);
diff -r a3ace503d04b -r 60782cefa154 tools/xenpaging/xenpaging.c
--- a/tools/xenpaging/xenpaging.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/xenpaging/xenpaging.c Thu Dec 23 15:25:57 2010 +0000
@@ -144,8 +144,8 @@ xenpaging_t *xenpaging_init(domid_t doma
}
/* Open event channel */
- paging->mem_event.xce_handle = xc_evtchn_open();
- if ( paging->mem_event.xce_handle < 0 )
+ paging->mem_event.xce_handle = xc_evtchn_open(NULL, 0);
+ if ( paging->mem_event.xce_handle == NULL )
{
ERROR("Failed to open event channel");
goto err;
@@ -246,7 +246,7 @@ int xenpaging_teardown(xenpaging_t *pagi
int xenpaging_teardown(xenpaging_t *paging)
{
int rc;
- struct xc_interface *xch;
+ xc_interface *xch;
if ( paging == NULL )
return 0;
@@ -274,7 +274,7 @@ int xenpaging_teardown(xenpaging_t *pagi
{
ERROR("Error closing event channel");
}
- paging->mem_event.xce_handle = -1;
+ paging->mem_event.xce_handle = NULL;
/* Close connection to Xen */
rc = xc_interface_close(xch);
@@ -338,7 +338,7 @@ int xenpaging_evict_page(xenpaging_t *pa
int xenpaging_evict_page(xenpaging_t *paging,
xenpaging_victim_t *victim, int fd, int i)
{
- struct xc_interface *xch = paging->xc_handle;
+ xc_interface *xch = paging->xc_handle;
void *page;
unsigned long gfn;
int ret;
@@ -412,7 +412,7 @@ static int xenpaging_populate_page(xenpa
static int xenpaging_populate_page(xenpaging_t *paging,
uint64_t *gfn, int fd, int i)
{
- struct xc_interface *xch = paging->xc_handle;
+ xc_interface *xch = paging->xc_handle;
unsigned long _gfn;
void *page;
int ret;
@@ -467,7 +467,7 @@ static int evict_victim(xenpaging_t *pag
static int evict_victim(xenpaging_t *paging, domid_t domain_id,
xenpaging_victim_t *victim, int fd, int i)
{
- struct xc_interface *xch = paging->xc_handle;
+ xc_interface *xch = paging->xc_handle;
int j = 0;
int ret;
diff -r a3ace503d04b -r 60782cefa154 tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/xenstore/xenstored_core.c Thu Dec 23 15:25:57 2010 +0000
@@ -52,7 +52,7 @@
#include "hashtable.h"
-extern int xce_handle; /* in xenstored_domain.c */
+extern xc_evtchn *xce_handle; /* in xenstored_domain.c */
static bool verbose = false;
LIST_HEAD(connections);
@@ -323,7 +323,7 @@ static int initialize_set(fd_set *inset,
set_fd(ro_sock, inset, &max);
set_fd(reopen_log_pipe[0], inset, &max);
- if (xce_handle != -1)
+ if (xce_handle != NULL)
set_fd(xc_evtchn_fd(xce_handle), inset, &max);
list_for_each_entry(conn, &connections, list) {
@@ -1901,7 +1901,7 @@ int main(int argc, char *argv[])
signal(SIGHUP, trigger_reopen_log);
- if (xce_handle != -1)
+ if (xce_handle != NULL)
evtchn_fd = xc_evtchn_fd(xce_handle);
/* Get ready to listen to the tools. */
diff -r a3ace503d04b -r 60782cefa154 tools/xenstore/xenstored_domain.c
--- a/tools/xenstore/xenstored_domain.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/xenstore/xenstored_domain.c Thu Dec 23 15:25:57 2010 +0000
@@ -36,7 +36,7 @@ static xc_interface **xc_handle;
static xc_interface **xc_handle;
static evtchn_port_t virq_port;
-int xce_handle = -1;
+xc_evtchn *xce_handle = NULL;
struct domain
{
@@ -580,8 +580,7 @@ static int dom0_init(void)
return 0;
}
-/* Returns the event channel handle. */
-int domain_init(void)
+void domain_init(void)
{
int rc;
@@ -595,9 +594,9 @@ int domain_init(void)
talloc_set_destructor(xc_handle, close_xc_handle);
- xce_handle = xc_evtchn_open();
-
- if (xce_handle < 0)
+ xce_handle = xc_evtchn_open(NULL, 0);
+
+ if (xce_handle == NULL)
barf_perror("Failed to open evtchn device");
if (dom0_init() != 0)
@@ -606,8 +605,6 @@ int domain_init(void)
if ((rc = xc_evtchn_bind_virq(xce_handle, VIRQ_DOM_EXC)) == -1)
barf_perror("Failed to bind to domain exception virq port");
virq_port = rc;
-
- return xce_handle;
}
void domain_entry_inc(struct connection *conn, struct node *node)
diff -r a3ace503d04b -r 60782cefa154 tools/xenstore/xenstored_domain.h
--- a/tools/xenstore/xenstored_domain.h Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/xenstore/xenstored_domain.h Thu Dec 23 15:25:57 2010 +0000
@@ -40,8 +40,7 @@ void do_set_target(struct connection *co
/* domid */
void do_get_domain_path(struct connection *conn, const char *domid_str);
-/* Returns the event channel handle */
-int domain_init(void);
+void domain_init(void);
/* Returns the implicit path of a connection (only domains have this) */
const char *get_implicit_path(const struct connection *conn);
diff -r a3ace503d04b -r 60782cefa154 tools/xentrace/xentrace.c
--- a/tools/xentrace/xentrace.c Thu Dec 23 15:08:21 2010 +0000
+++ b/tools/xentrace/xentrace.c Thu Dec 23 15:25:57 2010 +0000
@@ -73,7 +73,7 @@ int interrupted = 0; /* gets set if we g
int interrupted = 0; /* gets set if we get a SIGHUP */
static xc_interface *xc_handle;
-static int event_fd = -1;
+static xc_evtchn *xce_handle = NULL;
static int virq_port = -1;
static int outfd = 1;
@@ -576,14 +576,13 @@ static void event_init(void)
{
int rc;
- rc = xc_evtchn_open();
- if (rc < 0) {
+ xce_handle = xc_evtchn_open(NULL, 0);
+ if (xce_handle == NULL) {
perror("event channel open");
exit(EXIT_FAILURE);
}
- event_fd = rc;
-
- rc = xc_evtchn_bind_virq(event_fd, VIRQ_TBUF);
+
+ rc = xc_evtchn_bind_virq(xce_handle, VIRQ_TBUF);
if (rc == -1) {
PERROR("failed to bind to VIRQ port");
exit(EXIT_FAILURE);
@@ -598,7 +597,7 @@ static void wait_for_event_or_timeout(un
static void wait_for_event_or_timeout(unsigned long milliseconds)
{
int rc;
- struct pollfd fd = { .fd = event_fd,
+ struct pollfd fd = { .fd = xc_evtchn_fd(xce_handle),
.events = POLLIN | POLLERR };
int port;
@@ -611,7 +610,7 @@ static void wait_for_event_or_timeout(un
}
if (rc == 1) {
- port = xc_evtchn_pending(event_fd);
+ port = xc_evtchn_pending(xce_handle);
if (port == -1) {
PERROR("failed to read port from evtchn");
exit(EXIT_FAILURE);
@@ -622,7 +621,7 @@ static void wait_for_event_or_timeout(un
port, virq_port);
exit(EXIT_FAILURE);
}
- rc = xc_evtchn_unmask(event_fd, port);
+ rc = xc_evtchn_unmask(xce_handle, port);
if (rc == -1) {
PERROR("failed to write port to evtchn");
exit(EXIT_FAILURE);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|