diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2010-12-23 15:25:57 +0000 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2010-12-23 15:25:57 +0000 |
commit | 3e446a35ee82c738367e8f90e3bc9166687043a8 (patch) | |
tree | d2ed5fd210a798cb5c54007a08e8bd2b9e9a221f /tools/libxc/xc_private.c | |
parent | 252cb308e37470915d0f64c730e4e2e829ec2512 (diff) | |
download | xen-3e446a35ee82c738367e8f90e3bc9166687043a8.tar.gz xen-3e446a35ee82c738367e8f90e3bc9166687043a8.tar.bz2 xen-3e446a35ee82c738367e8f90e3bc9166687043a8.zip |
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@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxc/xc_private.c')
-rw-r--r-- | tools/libxc/xc_private.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c index 3b83a8aa5f..4cd89209fa 100644 --- a/tools/libxc/xc_private.c +++ b/tools/libxc/xc_private.c @@ -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); if (xch->fd < 0) goto err; } @@ -70,7 +74,7 @@ xc_interface *xc_interface_open(xentoollog_logger *logger, 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,7 +82,7 @@ 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"); } @@ -86,6 +90,31 @@ int xc_interface_close(xc_interface *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; static pthread_once_t errbuf_pkey_once = PTHREAD_ONCE_INIT; |