libxc: dom0 OS integration cleanup+abstraction.
PATCH 1/1 libxc: dom0 OS integration cleanup+abstraction.
The following series updates the libxc evtchn and gnttab interfaces to use the same abstract handle type as the primary libxc interface rather than the existing simple integer handle. This is good for consistency and also allows callers to control logging in the same was as they do with the primary interface. I have given each interface a distinct typedef name, in the hopes that in the future some type safety can be introduced.
In addition to this series there is two patches to qemu-xen corresponding to the change in the event channel and grant table interface respectively.
Following on from this the series then introduces an osdep abstraction which encapsulates the OS specific portions of libxc which interface with the hypervisor via the relevant kernel interfaces.
The series then makes it possible to load implementations of this interface dynamically at runtime. Although the series includes a noddy implementation (mainly to validate that such a thing builds ok) the actual primary user will be the "Xen In Userspace" (xiu) simulator used in the XCP SDK VM. The patches to implement this functionality will be included in a followup reposting of my previous "Allow XCP to use ocaml library bindings in Xen unstable" set of series.
The series has been tested using xl with PV and HVM guests (with both stub and non-stub qemu) as well as with the XCP series in both real dom0 and an SDK VM.
PATCH 1/1 libxc: some xc_gnttab_* functions are not Linux specific
# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1291369006 0
# Node ID 7c6e87f167d47b2c0b850806d0e9fa298018ebd4 # Parent 9a40ab7a4347e4c49785d079a598a1bc22477739
libxc: some xc_gnttab_* functions are not Linux specific
They simply make hypercalls and perform other operations via the abstract interface. Create xc_gnttab.c and move those functions there.
tools/libxc/Makefile +1 -0
@@ -11,6 +11,7 @@ CTRL_SRCS-y += xc_cpupool.c CTRL_SRCS-y += xc_cpupool.c CTRL_SRCS-y += xc_domain.c CTRL_SRCS-y += xc_evtchn.c +CTRL_SRCS-y += xc_gnttab.c CTRL_SRCS-y += xc_misc.c CTRL_SRCS-y += xc_acm.c CTRL_SRCS-y += xc_flask.c
tools/libxc/xc_gnttab.c new file +147 -0
147 lines not on this page · raw message
tools/libxc/xc_linux.c +0 -126
132 lines not on this page · raw message
tools/libxc/xc_minios.c +0 -12
@@ -457,18 +457,6 @@ int xc_gnttab_set_max_grants(xc_interfacreturn ret; } -grant_entry_v1_t *xc_gnttab_map_table_v1 ( -xc_interface *xch,int domid,int *gnt_num) -{ -return NULL ; -} - -grant_entry_v2_t *xc_gnttab_map_table_v2 ( -xc_interface *xch,int domid,int *gnt_num) -{ -return NULL ; -} -/* * Local variables: * mode: C
tools/libxc/xc_netbsd.c +0 -12
@@ -287,18 +287,6 @@ void discard_file_cache(xc_interface *xc } } -grant_entry_v1_t *xc_gnttab_map_table_v1 ( -xc_interface *xch,int domid,int *gnt_num) -{ -return NULL ; -} - -grant_entry_v2_t *xc_gnttab_map_table_v2 ( -xc_interface *xch,int domid,int *gnt_num) -{ -return NULL ; -} -/* * Local variables: * mode: C
tools/libxc/xc_solaris.c +0 -12
@@ -261,15 +261,3 @@ void discard_file_cache(xc_interface *xc {// TODO: Implement for Solaris! } - -grant_entry_v1_t *xc_gnttab_map_table_v1 ( -xc_interface *xch,int domid,int *gnt_num) -{ -return NULL ; -} - -grant_entry_v2_t *xc_gnttab_map_table_v2 ( -xc_interface *xch,int domid,int *gnt_num) -{ -return NULL ; -}
PATCH 1/1 libxc: convert evtchn interfaces to use an opaque handle type
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1291369006 0
# Node ID e82cccb0d9770e51f9785f109ea11d704ae4df45 # Parent 7c6e87f167d47b2c0b850806d0e9fa298018ebd4
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.
tools/console/daemon/io.c +16 -16
@@ -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 domif (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 domif (!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 domaiif (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 ; }
tools/fs-back/fs-backend.c +6 -6
@@ -228,9 +228,9 @@ static void handle_connection(int fronteFS_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 ; }
tools/fs-back/fs-backend.h +1 -1
@@ -45,7 +45,7 @@ struct fs_mountgrant_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 */
tools/libxc/xc_dom_elfloader.c +2 -2
@@ -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); }
tools/libxc/xc_domain_restore.c +1 -1
@@ -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 ;
tools/libxc/xc_linux.c +21 -21
114 lines not on this page · raw message
tools/libxc/xc_minios.c +47 -44
241 lines not on this page · raw message
tools/libxc/xc_netbsd.c +21 -21
126 lines not on this page · raw message
tools/libxc/xc_private.c +36 -7
73 lines not on this page · raw message
tools/libxc/xc_private.h +12 -3
@@ -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_interfaceint 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,
tools/libxc/xc_solaris.c +19 -19
@@ -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) +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 , ¬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;
@@ -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); +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 */
tools/libxc/xc_suspend.c +3 -3
@@ -75,7 +75,7 @@ static int unlock_suspend_event(xc_interreturn -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_interfareturn 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 ;
tools/libxc/xenctrl.h +15 -14
@@ -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); +int xc_evtchn_close (xc_evtchn *xce);/* -* Return an fd that can be select()ed on for further calls to -* xc_evtchn_pending(). +* Return an fd that can be select()ed on. */ -int xc_evtchn_fd (int xce_handle); +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_interfaint 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. */
tools/libxc/xenguest.h +3 -3
@@ -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_release (xc_interface *xch,xc_evtchn *xce,int domid,int suspend_evtchn); -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 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 xc_get_bit_size(xc_interface *xch, const char *image_name, const char *cmdline,
tools/libxl/libxl_dom.c +6 -6
@@ -313,7 +313,7 @@ int libxl__domain_restore_common(libxl_cstruct suspendinfo {libxl__gc *gc; -int xce;/* event channel handle */ +xc_evtchn *xce;/* event channel handle */ int suspend_eventchn;int domid;int hvm;
@@ -417,11 +417,11 @@ int libxl__domain_suspend_common(libxl_c si.gc = &gc; si.suspend_eventchn =-1 ; - si.xce =xc_evtchn_open (); -if (si.xce <0 ) + si.xce =xc_evtchn_open (NULL ,0 ); +if (si.xce ==NULL ) goto out; - -if (si.xce >0 ) { +else + { port =xs_suspend_evtchn_port (si.domid);if (port >=0 ) {
@@ -445,7 +445,7 @@ int libxl__domain_suspend_common(libxl_cif (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:
tools/misc/xen-hptool.c +5 -4
@@ -98,7 +98,7 @@ static int hp_mem_query_func(int argc, cextern 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 (); +int result, suspend_evtchn =-1 ; +xc_evtchn *xce; + xce =xc_evtchn_open (NULL ,0 ); -if (xce <0 ) +if (xce ==NULL ) {fprintf (stderr,"When exchange page, fail" " to open evtchn\n" );
tools/python/xen/lowlevel/checkpoint/checkpoint.h +1 -1
@@ -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 */
tools/python/xen/lowlevel/checkpoint/libcheckpoint.c +6 -6
@@ -48,7 +48,7 @@ void checkpoint_init(checkpoint_state* svoid 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(checkstatic 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 ; }
tools/xcutils/xc_save.c +5 -6
@@ -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.suspend_evtchn =-1 ; - si.xce =xc_evtchn_open (); -if (si.xce <0 ) + 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);
tools/xenmon/xenbaked.c +5 -5
@@ -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 (); + xce_handle =xc_evtchn_open (NULL ,0 ); -if (xce_handle <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 ; }
tools/xenpaging/mem_event.h +1 -1
@@ -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;
tools/xenpaging/xc.c +6 -6
@@ -65,9 +65,9 @@ int xc_mem_paging_flush_ioemu_cache(domireturn 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_inteif ( 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_intereturn -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,
tools/xenpaging/xc.h +2 -2
@@ -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);
tools/xenpaging/xenpaging.c +3 -3
@@ -148,8 +148,8 @@ xenpaging_t *xenpaging_init(xc_interface }/* 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;
@@ -274,7 +274,7 @@ int xenpaging_teardown(xc_interface *xch {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 (paging->xc_handle);
tools/xenstore/xenstored_core.c +3 -3
@@ -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. */
tools/xenstore/xenstored_domain.c +4 -7
@@ -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 (); + xce_handle =xc_evtchn_open (NULL ,0 ); -if (xce_handle <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)
tools/xenstore/xenstored_domain.h +1 -2
@@ -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);
tools/xentrace/xentrace.c +7 -8
@@ -73,7 +73,7 @@ int interrupted = 0; /* gets set if we gint 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(unstatic 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 );
PATCH 1/1 libxc: convert gnttab interfaces to use an opaque handle type
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1291369006 0
# Node ID d210f8cc84b3b228017afcca2158ccf1e06c1430 # Parent e82cccb0d9770e51f9785f109ea11d704ae4df45
libxc: convert gnttab interfaces to use an opaque handle type
The xc_interface previously passed to xc_gnttab_* was only used for logging which can now be done via the xc_gnttab handle instead.
This makes the interface consistent with the changes made to the main interface in 21483:779c0ef9682c.
tools/fs-back/fs-backend.c +9 -11
@@ -168,9 +168,8 @@ void terminate_mount_request(struct fs_m }xenbus_write_backend_state (mount,STATE_CLOSED ); -xc_gnttab_munmap (mount->xch, mount->gnth, - mount->ring.sring, mount->shared_ring_size); -xc_gnttab_close (mount->xch, mount->gnth); +xc_gnttab_munmap (mount->gnth, mount->ring.sring, mount->shared_ring_size); +xc_gnttab_close (mount->gnth);xc_evtchn_unbind (mount->evth, mount->local_evtchn);xc_evtchn_close (mount->evth);
@@ -242,15 +241,15 @@ static void handle_connection(int fronteFS_DEBUG ("ERROR: Couldn't bind evtchn!\n" ); goto error; } - mount->gnth =-1 ; - mount->gnth =xc_gnttab_open (mount->xch); -if (mount->gnth <0 ) { + mount->gnth =NULL ; + mount->gnth =xc_gnttab_open (NULL ,0 ); +if (mount->gnth ==NULL ) {FS_DEBUG ("ERROR: Couldn't open gnttab!\n" ); goto error; }for (i=0 ; i<mount->shared_ring_size; i++) dom_ids[i] = mount->dom_id; - sring = xc_gnttab_map_grant_refs(mount->xch, mount->gnth, + sring = xc_gnttab_map_grant_refs(mount->gnth, mount->shared_ring_size, dom_ids, mount->grefs,
@@ -283,10 +282,9 @@ error: error:xenbus_write_backend_state (mount,STATE_CLOSED );if (sring) -xc_gnttab_munmap (mount->xch, mount->gnth, - mount->ring.sring, mount->shared_ring_size); -if (mount->gnth >0 ) -xc_gnttab_close (mount->xch, mount->gnth); +xc_gnttab_munmap (mount->gnth, mount->ring.sring, mount->shared_ring_size); +if (mount->gnth !=NULL ) +xc_gnttab_close (mount->gnth);if (mount->local_evtchn >0 )xc_evtchn_unbind (mount->evth, mount->local_evtchn);if (mount->evth !=NULL )
tools/fs-back/fs-backend.h +1 -1
@@ -47,7 +47,7 @@ struct fs_mountxc_interface *xch;/* just for error logging, so a dummy */ xc_evtchn *evth;/* Handle to the event channel */ evtchn_port_t local_evtchn; -int gnth; +xc_gnttab *gnth;int shared_ring_size;/* in pages */ struct fsif_back_ring ring;int nr_entries;
tools/fs-back/fs-ops.c +18 -19
@@ -75,7 +75,7 @@ static void dispatch_file_open(struct fsFS_DEBUG ("Dispatching file open operation (gref=%d).\n" , req->u.fopen.gref);/* Read the request, and open file */ - file_name =xc_gnttab_map_grant_ref (mount->xch, mount->gnth, + file_name =xc_gnttab_map_grant_ref (mount->gnth, mount->dom_id, req->u.fopen.gref,PROT_READ );
@@ -99,7 +99,7 @@ static void dispatch_file_open(struct fs } } out: -if (xc_gnttab_munmap (mount->xch, mount->gnth, file_name,1 ) !=0 ) { +if (xc_gnttab_munmap (mount->gnth, file_name,1 ) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
@@ -159,7 +159,7 @@ static void dispatch_file_read(struct fsassert (req->u.fread.len >0 ); count = (req->u.fread.len -1 ) /XC_PAGE_SIZE +1 ;assert (count <=FSIF_NR_READ_GNTS ); - buf = xc_gnttab_map_domain_grant_refs(mount->xch, mount->gnth, + buf = xc_gnttab_map_domain_grant_refs(mount->gnth, count, mount->dom_id, req->u.fread.grefs,
@@ -192,8 +192,7 @@ static void dispatch_file_read(struct fs priv_req->aiocb.aio_sigevent.sigev_value.sival_ptr = priv_req;if (aio_read (&priv_req->aiocb) <0 ) {FS_DEBUG ("ERROR: aio_read failed errno=%d\n" , errno); -xc_gnttab_munmap (mount->xch, mount->gnth, - priv_req->page, priv_req->count); +xc_gnttab_munmap (mount->gnth, priv_req->page, priv_req->count);terminate_mount_request (mount); }
@@ -209,7 +208,7 @@ static void end_file_read(struct fs_mounuint16_t req_id;/* Release the grant */ -if (xc_gnttab_munmap (mount->xch, mount->gnth, +if (xc_gnttab_munmap (mount->gnth, priv_req->page, priv_req->count) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount);
@@ -236,7 +235,7 @@ static void dispatch_file_write(struct fassert (req->u.fwrite.len >0 ); count = (req->u.fwrite.len -1 ) /XC_PAGE_SIZE +1 ;assert (count <=FSIF_NR_WRITE_GNTS ); - buf = xc_gnttab_map_domain_grant_refs(mount->xch, mount->gnth, + buf = xc_gnttab_map_domain_grant_refs(mount->gnth, count, mount->dom_id, req->u.fwrite.grefs,
@@ -269,7 +268,7 @@ static void dispatch_file_write(struct f priv_req->aiocb.aio_sigevent.sigev_value.sival_ptr = priv_req;if (aio_write (&priv_req->aiocb) <0 ) {FS_DEBUG ("ERROR: aio_write failed errno=%d\n" , errno); -xc_gnttab_munmap (mount->xch, mount->gnth, +xc_gnttab_munmap (mount->gnth, priv_req->page, priv_req->count);terminate_mount_request (mount); }
@@ -287,7 +286,7 @@ static void end_file_write(struct fs_mouuint16_t req_id;/* Release the grant */ -if (xc_gnttab_munmap (mount->xch, mount->gnth, +if (xc_gnttab_munmap (mount->gnth, priv_req->page, priv_req->count) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount);
@@ -395,7 +394,7 @@ static void dispatch_remove(struct fs_moFS_DEBUG ("Dispatching remove operation (gref=%d).\n" , req->u.fremove.gref);/* Read the request, and open file */ - file_name =xc_gnttab_map_grant_ref (mount->xch, mount->gnth, + file_name =xc_gnttab_map_grant_ref (mount->gnth, mount->dom_id, req->u.fremove.gref,PROT_READ );
@@ -409,7 +408,7 @@ static void dispatch_remove(struct fs_mo ret =remove (file_name); }FS_DEBUG ("Got ret: %d\n" , ret); -if (xc_gnttab_munmap (mount->xch, mount->gnth, file_name,1 ) !=0 ) { +if (xc_gnttab_munmap (mount->gnth, file_name,1 ) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
@@ -437,7 +436,7 @@ static void dispatch_rename(struct fs_moFS_DEBUG ("Dispatching rename operation (gref=%d).\n" , req->u.fremove.gref);/* Read the request, and open file */ - buf =xc_gnttab_map_grant_ref (mount->xch, mount->gnth, + buf =xc_gnttab_map_grant_ref (mount->gnth, mount->dom_id, req->u.frename.gref,PROT_READ );
@@ -455,7 +454,7 @@ static void dispatch_rename(struct fs_mo ret =rename (old_file_name, new_file_name); }FS_DEBUG ("Got ret: %d\n" , ret); -if (xc_gnttab_munmap (mount->xch, mount->gnth, buf,1 ) !=0 ) { +if (xc_gnttab_munmap (mount->gnth, buf,1 ) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
@@ -487,7 +486,7 @@ static void dispatch_create(struct fs_mo/* Read the request, and create file/directory */ mode = req->u.fcreate.mode; directory = req->u.fcreate.directory; - file_name =xc_gnttab_map_grant_ref (mount->xch, mount->gnth, + file_name =xc_gnttab_map_grant_ref (mount->gnth, mount->dom_id, req->u.fcreate.gref,PROT_READ );
@@ -523,7 +522,7 @@ static void dispatch_create(struct fs_mo } } out: -if (xc_gnttab_munmap (mount->xch, mount->gnth, file_name,1 ) !=0 ) { +if (xc_gnttab_munmap (mount->gnth, file_name,1 ) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
@@ -551,7 +550,7 @@ static void dispatch_list(struct fs_mounFS_DEBUG ("Dispatching list operation (gref=%d).\n" , req->u.flist.gref);/* Read the request, and list directory */ offset = req->u.flist.offset; - buf = file_name =xc_gnttab_map_grant_ref (mount->xch, mount->gnth, + buf = file_name =xc_gnttab_map_grant_ref (mount->gnth, mount->dom_id, req->u.flist.gref,PROT_READ |PROT_WRITE );
@@ -599,7 +598,7 @@ error_out: ret_val = ((nr_files <<NR_FILES_SHIFT ) &NR_FILES_MASK ) | ((error_code <<ERROR_SHIFT ) &ERROR_MASK ) | (dirent !=NULL ?HAS_MORE_FLAG :0 ); -if (xc_gnttab_munmap (mount->xch, mount->gnth, file_name,1 ) !=0 ) { +if (xc_gnttab_munmap (mount->gnth, file_name,1 ) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
@@ -654,7 +653,7 @@ static void dispatch_fs_space(struct fs_FS_DEBUG ("Dispatching fs space operation (gref=%d).\n" , req->u.fspace.gref);/* Read the request, and open file */ - file_name =xc_gnttab_map_grant_ref (mount->xch, mount->gnth, + file_name =xc_gnttab_map_grant_ref (mount->gnth, mount->dom_id, req->u.fspace.gref,PROT_READ );
@@ -670,7 +669,7 @@ static void dispatch_fs_space(struct fs_if (ret >=0 ) ret = stat.f_bsize * stat.f_bfree; -if (xc_gnttab_munmap (mount->xch, mount->gnth, file_name,1 ) !=0 ) { +if (xc_gnttab_munmap (mount->gnth, file_name,1 ) !=0 ) {FS_DEBUG ("ERROR: xc_gnttab_munmap failed errno=%d\n" , errno);terminate_mount_request (mount); }
tools/libxc/xc_linux.c +20 -26
134 lines not on this page · raw message
tools/libxc/xc_minios.c +17 -17
@@ -375,17 +375,17 @@ void discard_file_cache(xc_interface *xcfsync (fd); } -int xc_gnttab_open (xc_interface *xch) +int xc_gnttab_open_core (xc_gnttab *xcg) { -int xcg_handle; - xcg_handle =alloc_fd (FTYPE_GNTMAP ); -gntmap_init (&files[xcg_handle].gntmap); -return xcg_handle; +int fd; + fd =alloc_fd (FTYPE_GNTMAP ); +gntmap_init (&files[fd].gntmap); +return fd; } -int xc_gnttab_close (xc_interface *xch,int xcg_handle) +int xc_gnttab_close_core (xc_gnttab *xcg) { -return close (xcg_handle); +return close (xcg->fd); }void minios_gnttab_close_fd (int fd)
@@ -394,50 +394,50 @@ void minios_gnttab_close_fd(int fd) files[fd].type =FTYPE_NONE ; } -void *xc_gnttab_map_grant_ref (xc_interface *xch,int xcg_handle, +void *xc_gnttab_map_grant_ref (xc_gnttab *xcg,uint32_t domid,uint32_t ref,int prot) { -return gntmap_map_grant_refs (&files[xcg_handle].gntmap, +return gntmap_map_grant_refs (&files[xcg->fd].gntmap,1 , &domid,0 , &ref, prot &PROT_WRITE ); } -void *xc_gnttab_map_grant_refs (xc_interface *xch,int xcg_handle, +void *xc_gnttab_map_grant_refs (xc_gnttab *xcg,uint32_t count,uint32_t *domids,uint32_t *refs,int prot) { -return gntmap_map_grant_refs (&files[xcg_handle].gntmap, +return gntmap_map_grant_refs (&files[xcg->fd].gntmap, count, domids,1 , refs, prot &PROT_WRITE ); } -void *xc_gnttab_map_domain_grant_refs (xc_interface *xch,int xcg_handle, +void *xc_gnttab_map_domain_grant_refs (xc_gnttab *xcg,uint32_t count,uint32_t domid,uint32_t *refs,int prot) { -return gntmap_map_grant_refs (&files[xcg_handle].gntmap, +return gntmap_map_grant_refs (&files[xcg->fd].gntmap, count, &domid,0 , refs, prot &PROT_WRITE ); } -int xc_gnttab_munmap (xc_interface *xch,int xcg_handle, +int xc_gnttab_munmap (xc_gnttab *xcg,void *start_address,uint32_t count) {int ret; - ret =gntmap_munmap (&files[xcg_handle].gntmap, + ret =gntmap_munmap (&files[xcg->fd].gntmap, (unsigned long ) start_address, count);if (ret <0 ) {
@@ -447,11 +447,11 @@ int xc_gnttab_munmap(xc_interface *xch,return ret; } -int xc_gnttab_set_max_grants (xc_interface *xch,int xcg_handle, +int xc_gnttab_set_max_grants (xc_gnttab *xcg,uint32_t count) {int ret; - ret =gntmap_set_max_grants (&files[xcg_handle].gntmap, + ret =gntmap_set_max_grants (&files[xcg->fd].gntmap, count);if (ret <0 ) { errno = -ret;
tools/libxc/xc_private.c +12 -0
@@ -113,6 +113,18 @@ int xc_evtchn_close(xc_evtchn *xce)int xc_evtchn_close (xc_evtchn *xce) {return xc_interface_close_common (xce, &xc_evtchn_close_core); +} + +xc_gnttab *xc_gnttab_open (xentoollog_logger *logger, +unsigned open_flags) +{ +return xc_interface_open_common (logger,NULL , open_flags, +XC_INTERFACE_GNTTAB , &xc_gnttab_open_core); +} + +int xc_gnttab_close (xc_gnttab *xcg) +{ +return xc_interface_close_common (xcg, &xc_gnttab_close_core); }static pthread_key_t errbuf_pkey;
tools/libxc/xc_private.h +4 -0
@@ -68,6 +68,7 @@ enum xc_interface_type {enum xc_interface_type {XC_INTERFACE_PRIVCMD ,XC_INTERFACE_EVTCHN , +XC_INTERFACE_GNTTAB , };struct xc_interface_core {
@@ -269,6 +270,9 @@ int xc_evtchn_open_core(struct xc_interfint 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 */ +int xc_gnttab_open_core (struct xc_interface_core *xcg);/* returns fd, logs errors */ +int xc_gnttab_close_core (struct xc_interface_core *xcg);/* no logging */ +void *xc_map_foreign_ranges (xc_interface *xch,uint32_t dom,size_t size,int prot,size_t chunksize,privcmd_mmap_entry_t entries[],int nentries);
tools/libxc/xenctrl.h +12 -15
@@ -106,6 +106,7 @@typedef struct xc_interface_core xc_interface ;typedef struct xc_interface_core xc_evtchn ; +typedef struct xc_interface_core xc_gnttab ;typedef enum xc_error_code xc_error_code ;
@@ -1239,25 +1240,25 @@ int xc_domain_subscribe_for_suspend(/* * Return an fd onto the grant table driver. Logs errors. */ -int xc_gnttab_open (xc_interface *xch); +xc_gnttab *xc_gnttab_open (xentoollog_logger *logger, +unsigned open_flags);/* * Close a handle previously allocated with xc_gnttab_open(). * Never logs errors. */ -int xc_gnttab_close (xc_interface *xch,int xcg_handle); +int xc_gnttab_close (xc_gnttab *xcg);/* * Memory maps a grant reference from one domain to a local address range. * Mappings should be unmapped with xc_gnttab_munmap. Logs errors. * -* @parm xcg_handle a handle on an open grant table interface +* @parm xcg a handle on an open grant table interface * @parm domid the domain to map memory from * @parm ref the grant reference ID to map * @parm prot same flag as in mmap() */ -void *xc_gnttab_map_grant_ref (xc_interface *xch, -int xcg_handle, +void *xc_gnttab_map_grant_ref (xc_gnttab *xcg,uint32_t domid,uint32_t ref,int prot);
@@ -1267,15 +1268,14 @@ void *xc_gnttab_map_grant_ref(xc_interfa* contiguous local address range. Mappings should be unmapped with * xc_gnttab_munmap. Logs errors. * -* @parm xcg_handle a handle on an open grant table interface +* @parm xcg a handle on an open grant table interface * @parm count the number of grant references to be mapped * @parm domids an array of @count domain IDs by which the corresponding @refs * were granted * @parm refs an array of @count grant references to be mapped * @parm prot same flag as in mmap() */ -void *xc_gnttab_map_grant_refs(xc_interface *xch, - int xcg_handle, +void *xc_gnttab_map_grant_refs(xc_gnttab *xcg, uint32_t count, uint32_t *domids, uint32_t *refs,
@@ -1286,14 +1286,13 @@ void *xc_gnttab_map_grant_refs(xc_interf* contiguous local address range. Mappings should be unmapped with * xc_gnttab_munmap. Logs errors. * -* @parm xcg_handle a handle on an open grant table interface +* @parm xcg a handle on an open grant table interface * @parm count the number of grant references to be mapped * @parm domid the domain to map memory from * @parm refs an array of @count grant references to be mapped * @parm prot same flag as in mmap() */ -void *xc_gnttab_map_domain_grant_refs(xc_interface *xch, - int xcg_handle, +void *xc_gnttab_map_domain_grant_refs(xc_gnttab *xcg, uint32_t count, uint32_t domid, uint32_t *refs,
@@ -1303,8 +1302,7 @@ void *xc_gnttab_map_domain_grant_refs(xc* Unmaps the @count pages starting at @start_address, which were mapped by a * call to xc_gnttab_map_grant_ref or xc_gnttab_map_grant_refs. Never logs. */ -int xc_gnttab_munmap (xc_interface *xch, -int xcg_handle, +int xc_gnttab_munmap (xc_gnttab *xcg,void *start_address,uint32_t count);
@@ -1319,8 +1317,7 @@ int xc_gnttab_munmap(xc_interface *xch,* and it may not be possible to satisfy requests up to the maximum number * of grants. */ -int xc_gnttab_set_max_grants (xc_interface *xch, -int xcg_handle, +int xc_gnttab_set_max_grants (xc_gnttab *xcg,uint32_t count); int xc_gnttab_op(xc_interface *xch, int cmd,
PATCH 1/1 libxc: osdep: add framework for abstracting access to dom0 OS hypervisor interfaces
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1291369006 0
# Node ID f6ca48223803053b2d55c5845cc358ddd4cd5743
# Parent d210f8cc84b3b228017afcca2158ccf1e06c1430
libxc: osdep: add framework for abstracting access to dom0 OS hypervisor interfaces.
This patch introduces the basic infrastructure and uses it for open and close operations on privcmd, evtchn and gnttab devices.
tools/libxc/Makefile +1 -1
@@ -109,7 +109,7 @@ install: build $(INSTALL_DATA) libxenctrl.a $(DESTDIR)$(LIBDIR) ln -sf libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/libxenctrl.so.$(MAJOR) ln -sf libxenctrl.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libxenctrl.so - $(INSTALL_DATA) xenctrl.h xentoollog.h $(DESTDIR)$(INCLUDEDIR) + $(INSTALL_DATA) xenctrl.h xenctrlosdep.h xentoollog.h $(DESTDIR)$(INCLUDEDIR) $(INSTALL_PROG) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR) $(INSTALL_DATA) libxenguest.a $(DESTDIR)$(LIBDIR) ln -sf libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/libxenguest.so.$(MAJOR)
tools/libxc/xc_linux.c +65 -15
140 lines not on this page · raw message
tools/libxc/xc_minios.c +63 -14
126 lines not on this page · raw message
tools/libxc/xc_netbsd.c +50 -10
110 lines not on this page · raw message
tools/libxc/xc_private.c +60 -20
144 lines not on this page · raw message
tools/libxc/xc_private.h +6 -16
@@ -30,6 +30,7 @@#include <sys/ioctl.h> #include "xenctrl.h" +#include "xenctrlosdep.h" #include <xen/sys/privcmd.h>
@@ -65,14 +66,8 @@*/ #define MAX_PAGECACHE_USAGE (4*1024) -enum xc_interface_type { -XC_INTERFACE_PRIVCMD , -XC_INTERFACE_EVTCHN , -XC_INTERFACE_GNTTAB , -}; -struct xc_interface_core { -enum xc_interface_type type; +enum xc_osdep_type type;int fd;int flags;xentoollog_logger *error_handler, *error_handler_tofree;
@@ -80,6 +75,10 @@ struct xc_interface_core {struct xc_error last_error;/* for xc_get_last_error */ FILE *dombuild_logger_file;const char *currently_progress_reporting; + +xc_osdep_info_t osdep; +xc_osdep_ops *ops;/* backend operations */ +xc_osdep_handle ops_handle;/* opaque data for xc_osdep_ops */ };void xc_report_error (xc_interface *xch,int code,const char *fmt, ...);
@@ -264,15 +263,6 @@ static inline int do_sysctl(xc_interfaceint do_memory_op (xc_interface *xch,int cmd,void *arg,size_t len); -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 */ - -int xc_gnttab_open_core (struct xc_interface_core *xcg);/* returns fd, logs errors */ -int xc_gnttab_close_core (struct xc_interface_core *xcg);/* no logging */ -void *xc_map_foreign_ranges (xc_interface *xch,uint32_t dom,size_t size,int prot,size_t chunksize,privcmd_mmap_entry_t entries[],int nentries);
tools/libxc/xc_solaris.c +55 -11
123 lines not on this page · raw message
tools/libxc/xenctrlosdep.h new file +90 -0
90 lines not on this page · raw message
PATCH 1/1 libxc: osdep: convert do_xen_hypercall()
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369006 0
# Node ID 0d91fce8549eaf0d23a306f2ec7931467c850edd # Parent f6ca48223803053b2d55c5845cc358ddd4cd5743
libxc: osdep: convert do_xen_hypercall()
do_privcmd() was only ever used by do_xen_hypercall() so remove it.
tools/libxc/xc_linux.c +10 -11
@@ -73,6 +73,12 @@ static int linux_privcmd_close(xc_interf {int fd = (int )h;return close (fd); +} + +static int linux_privcmd_hypercall (xc_interface *xch,xc_osdep_handle h,privcmd_hypercall_t *hypercall) +{ +int fd = (int )h; +return ioctl (fd,IOCTL_PRIVCMD_HYPERCALL , hypercall); } static int xc_map_foreign_batch_single(xc_interface *xch, uint32_t dom,
@@ -316,20 +322,13 @@ void *xc_map_foreign_ranges(xc_interfacereturn ret; } -static int do_privcmd (xc_interface *xch,int cmd,unsigned long data) -{ -return ioctl (xch->fd, cmd, data); -} - -int do_xen_hypercall (xc_interface *xch,privcmd_hypercall_t *hypercall) -{ -return do_privcmd (xch,IOCTL_PRIVCMD_HYPERCALL , - (unsigned long )hypercall); -} -static struct xc_osdep_ops linux_privcmd_ops = { .open = &linux_privcmd_open, .close = &linux_privcmd_close, + + .u.privcmd = { + .hypercall = &linux_privcmd_hypercall, + }, };#define DEVXEN "/dev/xen/"
tools/libxc/xc_minios.c +26 -22
63 lines not on this page · raw message
tools/libxc/xc_netbsd.c +15 -21
@@ -66,6 +66,17 @@ static int netbsd_privcmd_close(xc_inter {int fd = (int )h;return close (fd); +} + +static int netbsd_privcmd_hypercall (xc_interface *xch,xc_osdep_handle h,privcmd_hypercall_t *hypercall) +{ +int fd = (int )h; +int error =ioctl (fd,IOCTL_PRIVCMD_HYPERCALL , hypercall); + +if (error <0 ) +return -errno; +else +return hypercall->retval; } void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
@@ -161,30 +172,13 @@ mmap_failed:return NULL ; } - -static int do_privcmd (xc_interface *xch,unsigned int cmd,unsigned long data) -{ -int err =ioctl (xch->fd, cmd, data); -if (err ==0 ) -return 0 ; -else -return -errno; -} - -int do_xen_hypercall (xc_interface *xch,privcmd_hypercall_t *hypercall) -{ -int error =do_privcmd (xch, -IOCTL_PRIVCMD_HYPERCALL , - (unsigned long )hypercall); -if (error) -return error; -else -return (hypercall->retval); -} -static struct xc_osdep_ops netbsd_privcmd_ops = { .open = &netbsd_privcmd_open, .close = &netbsd_privcmd_close, + + .u.privcmd = { + .hypercall = &netbsd_privcmd_hypercall; + }, };#define EVTCHN_DEV_NAME "/dev/xenevt"
tools/libxc/xc_private.c +6 -0
@@ -137,6 +137,12 @@ int xc_interface_close(xc_interface *xchint xc_interface_close (xc_interface *xch) {return xc_interface_close_common (xch); +} + + +int do_xen_hypercall (xc_interface *xch,privcmd_hypercall_t *hypercall) +{ +return xch->ops->u.privcmd.hypercall (xch, xch->ops_handle, hypercall); } xc_evtchn *xc_evtchn_open(xentoollog_logger *logger,
tools/libxc/xc_solaris.c +10 -12
@@ -66,6 +66,12 @@ static int solaris_privcmd_close(xc_inte {int fd = (int )h;return close (fd); +} + +static int solaris_privcmd_hypercall (xc_interface *xch,xc_osdep_handle h,privcmd_hypercall_t *hypercall) +{ +int fd = (int )h; +return ioctl (fd,IOCTL_PRIVCMD_HYPERCALL , hypercall); } void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
@@ -156,21 +162,13 @@ mmap_failed:return NULL ; } -static int do_privcmd (xc_interface *xch,unsigned int cmd,unsigned long data) -{ -return ioctl (xch->fd, cmd, data); -} - -int do_xen_hypercall (xc_interface *xch,privcmd_hypercall_t *hypercall) -{ -return do_privcmd (xch, -IOCTL_PRIVCMD_HYPERCALL , - (unsigned long )hypercall); -} -static struct xc_osdep_ops solaris_privcmd_ops = { .open = &solaris_privcmd_open, .close = &solaris_privcmd_close, + + .u.privcmd = { + .hypercall = &solaris_privcmd_hypercall; + }, };static xc_osdep_handle solaris_evtchn_open (xc_evtchn *xce)
tools/libxc/xenctrlosdep.h +6 -0
@@ -59,6 +59,12 @@ struct xc_osdep_opsxc_osdep_handle (*open)(xc_interface *xch);int (*close)(xc_interface *xch,xc_osdep_handle h); + +union { +struct { +int (*hypercall)(xc_interface *xch,xc_osdep_handle h,privcmd_hypercall_t *hypercall); + } privcmd; + } u; };typedef struct xc_osdep_ops xc_osdep_ops ;
PATCH 1/1 libxc: osdep: convert xc_map_foreign_{batch, bulk}
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID d0214e8537cee3c401e5ba5567d632d386ac5860 # Parent 0d91fce8549eaf0d23a306f2ec7931467c850edd
libxc: osdep: convert xc_map_foreign_{batch,bulk}
tools/libxc/Makefile +1 -0
@@ -30,6 +30,7 @@ CTRL_SRCS-y += xc_mem_paging.c CTRL_SRCS-y += xc_mem_paging.c CTRL_SRCS-y += xc_memshr.c CTRL_SRCS-y += xc_hcall_buf.c +CTRL_SRCS-y += xc_foreign_memory.c CTRL_SRCS-y += xtl_core.c CTRL_SRCS-y += xtl_logger_stdio.c CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c
tools/libxc/xc_foreign_memory.c new file +35 -0
@@ -0,0 +1,35 @@ +/****************************************************************************** +* xc_foreign_memory.c +* +* Functions for mapping foreign domain's memory. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "xc_private.h" + +void *xc_map_foreign_batch (xc_interface *xch,uint32_t dom,int prot, +xen_pfn_t *arr,int num ) +{ +return xch->ops->u.privcmd.map_foreign_batch (xch, xch->ops_handle, + dom, prot, arr, num); +} + +void *xc_map_foreign_bulk (xc_interface *xch,uint32_t dom,int prot, +const xen_pfn_t *arr,int *err,unsigned int num) +{ +return xch->ops->u.privcmd.map_foreign_bulk (xch, xch->ops_handle, + dom, prot, arr, err, num); +}
tools/libxc/xc_linux.c +21 -14
@@ -81,7 +81,7 @@ static int linux_privcmd_hypercall(xc_inreturn ioctl (fd,IOCTL_PRIVCMD_HYPERCALL , hypercall); } -static int xc_map_foreign_batch_single (xc_interface *xch,uint32_t dom, +static int xc_map_foreign_batch_single (int fd,uint32_t dom,xen_pfn_t *mfn,unsigned long addr) {privcmd_mmapbatch_t ioctlx;
@@ -96,21 +96,23 @@ static int xc_map_foreign_batch_single(x { *mfn ^=XEN_DOMCTL_PFINFO_PAGEDTAB ;usleep (100 ); - rc =ioctl (xch->fd,IOCTL_PRIVCMD_MMAPBATCH , &ioctlx); + rc =ioctl (fd,IOCTL_PRIVCMD_MMAPBATCH , &ioctlx); }while ( (rc <0 ) && (errno ==ENOENT ) );return rc; } -void *xc_map_foreign_batch (xc_interface *xch,uint32_t dom,int prot, -xen_pfn_t *arr,int num) +static void *linux_privcmd_map_foreign_batch (xc_interface *xch,xc_osdep_handle h, +uint32_t dom,int prot, +xen_pfn_t *arr,int num) { +int fd = (int )h;privcmd_mmapbatch_t ioctlx;void *addr;int rc; - addr =mmap (NULL , num <<PAGE_SHIFT , prot,MAP_SHARED , xch->fd,0 ); + addr =mmap (NULL , num <<PAGE_SHIFT , prot,MAP_SHARED , fd,0 );if ( addr ==MAP_FAILED ) {PERROR ("xc_map_foreign_batch: mmap failed" );
@@ -122,7 +124,7 @@ void *xc_map_foreign_batch(xc_interface ioctlx.addr = (unsigned long )addr; ioctlx.arr = arr; - rc =ioctl (xch->fd,IOCTL_PRIVCMD_MMAPBATCH , &ioctlx); + rc =ioctl (fd,IOCTL_PRIVCMD_MMAPBATCH , &ioctlx);if ( (rc <0 ) && (errno ==ENOENT ) ) {int i;
@@ -133,7 +135,7 @@ void *xc_map_foreign_batch(xc_interface XEN_DOMCTL_PFINFO_PAGEDTAB ) {unsigned long paged_addr = (unsigned long )addr + (i <<PAGE_SHIFT ); - rc =xc_map_foreign_batch_single (xch, dom, &arr[i], + rc =xc_map_foreign_batch_single (fd, dom, &arr[i], paged_addr);if ( rc <0 ) goto out;
@@ -154,16 +156,18 @@ void *xc_map_foreign_batch(xc_interfacereturn addr; } -void *xc_map_foreign_bulk (xc_interface *xch,uint32_t dom,int prot, -const xen_pfn_t *arr,int *err,unsigned int num) +static void *linux_privcmd_map_foreign_bulk (xc_interface *xch,xc_osdep_handle h, +uint32_t dom,int prot, +const xen_pfn_t *arr,int *err,unsigned int num) { +int fd = (int )h;privcmd_mmapbatch_v2_t ioctlx;void *addr;unsigned int i;int rc; addr =mmap (NULL , (unsigned long )num <<PAGE_SHIFT , prot,MAP_SHARED , - xch->fd,0 ); + fd,0 );if ( addr ==MAP_FAILED ) {PERROR ("xc_map_foreign_batch: mmap failed" );
@@ -176,7 +180,7 @@ void *xc_map_foreign_bulk(xc_interface * ioctlx.arr = arr; ioctlx.err = err; - rc =ioctl (xch->fd,IOCTL_PRIVCMD_MMAPBATCH_V2 , &ioctlx); + rc =ioctl (fd,IOCTL_PRIVCMD_MMAPBATCH_V2 , &ioctlx);if ( rc <0 && errno ==ENOENT ) {
@@ -192,7 +196,7 @@ void *xc_map_foreign_bulk(xc_interface * ioctlx.err = err + i;do {usleep (100 ); - rc =ioctl (xch->fd,IOCTL_PRIVCMD_MMAPBATCH_V2 , &ioctlx); + rc =ioctl (fd,IOCTL_PRIVCMD_MMAPBATCH_V2 , &ioctlx); }while ( rc <0 && err[i] == -ENOENT ); } }
@@ -216,7 +220,7 @@ void *xc_map_foreign_bulk(xc_interface * ioctlx.addr = (unsigned long )addr; ioctlx.arr = pfn; - rc =ioctl (xch->fd,IOCTL_PRIVCMD_MMAPBATCH , &ioctlx); + rc =ioctl (fd,IOCTL_PRIVCMD_MMAPBATCH , &ioctlx); rc = rc <0 ? -errno :0 ;
@@ -236,7 +240,7 @@ void *xc_map_foreign_bulk(xc_interface * err[i] = rc ?: -EINVAL ;continue ; } - rc =xc_map_foreign_batch_single (xch, dom, pfn + i, + rc =xc_map_foreign_batch_single (fd, dom, pfn + i, (unsigned long )addr + ((unsigned long )i<<PAGE_SHIFT ));if ( rc <0 ) {
@@ -328,6 +332,9 @@ static struct xc_osdep_ops linux_privcmd .u.privcmd = { .hypercall = &linux_privcmd_hypercall, + + .map_foreign_batch = &linux_privcmd_map_foreign_batch, + .map_foreign_bulk = &linux_privcmd_map_foreign_bulk, }, };
tools/libxc/xc_minios.c +9 -4
@@ -93,8 +93,9 @@ static int minios_privcmd_hypercall(xc_ireturn call.result; } -void *xc_map_foreign_bulk (xc_interface *xch,uint32_t dom,int prot, -const xen_pfn_t *arr,int *err,unsigned int num) +static void *minios_privcmd_map_foreign_bulk (xc_interface *xch,xc_osdep_handle h, +uint32_t dom,int prot, +const xen_pfn_t *arr,int *err,unsigned int num) {unsigned long pt_prot =0 ;#ifdef __ia64__
@@ -108,8 +109,9 @@ void *xc_map_foreign_bulk(xc_interface *return map_frames_ex (arr, num,1 ,0 ,1 , dom, err, pt_prot); } -void *xc_map_foreign_batch (xc_interface *xch,uint32_t dom,int prot, -xen_pfn_t *arr,int num) +static void *minios_privcmd_map_foreign_batch (xc_interface *xch,xc_osdep_handle h, +uint32_t dom,int prot, +xen_pfn_t *arr,int num) {unsigned long pt_prot =0 ;int err[num];
@@ -185,6 +187,9 @@ static struct xc_osdep_ops minios_privcm .u.privcmd = { .hypercall = &minios_privcmd_hypercall, + + .map_foreign_batch = &minios_privcmd_map_foreign_batch, + .map_foreign_bulk = &minios_privcmd_map_foreign_bulk, }, };
tools/libxc/xc_misc.c +3 -6
@@ -513,12 +513,9 @@ int xc_hvm_set_mem_type(/* stub for all not yet converted OSes */ -void * -#ifdef __GNUC__ -__attribute__((__weak__)) -#endif -xc_map_foreign_bulk(xc_interface *xch, uint32_t dom, int prot, - const xen_pfn_t *arr, int *err, unsigned int num) +void *xc_map_foreign_bulk_compat (xc_interface *xch,xc_osdep_handle h, +uint32_t dom,int prot, +const xen_pfn_t *arr,int *err,unsigned int num) {xen_pfn_t *pfn;unsigned int i;
tools/libxc/xc_netbsd.c +8 -3
@@ -79,9 +79,11 @@ static int netbsd_privcmd_hypercall(xc_ireturn hypercall->retval; } -void *xc_map_foreign_batch (xc_interface *xch,uint32_t dom,int prot, -xen_pfn_t *arr,int num) +static void *netbsd_privcmd_map_foreign_batch (xc_interface *xch,xc_osdep_handle h, +uint32_t dom,int prot, +xen_pfn_t *arr,int num) { +int fd = (int )h;privcmd_mmapbatch_t ioctlx;void *addr; addr =mmap (NULL , num*PAGE_SIZE , prot,MAP_ANON |MAP_SHARED ,-1 ,0 );
@@ -94,7 +96,7 @@ void *xc_map_foreign_batch(xc_interface ioctlx.dom=dom; ioctlx.addr=(unsigned long )addr; ioctlx.arr=arr; -if (ioctl (xch->fd,IOCTL_PRIVCMD_MMAPBATCH , &ioctlx) <0 ) +if (ioctl (fd,IOCTL_PRIVCMD_MMAPBATCH , &ioctlx) <0 ) {int saved_errno = errno;PERROR ("xc_map_foreign_batch: ioctl failed" );
@@ -178,6 +180,9 @@ static struct xc_osdep_ops netbsd_privcm .u.privcmd = { .hypercall = &netbsd_privcmd_hypercall; + + .map_foreign_batch = &netbsd_privcmd_map_foreign_batch, + .map_foreign_bulk = &xc_map_foreign_bulk_compat, }, };
tools/libxc/xc_solaris.c +9 -4
@@ -74,12 +74,14 @@ static int solaris_privcmd_hypercall(xc_return ioctl (fd,IOCTL_PRIVCMD_HYPERCALL , hypercall); } -void *xc_map_foreign_batch (xc_interface *xch,uint32_t dom,int prot, -xen_pfn_t *arr,int num) +static void *solaris_privcmd_map_foreign_batch (xc_interface *xch,xc_osdep_handle h, +uint32_t dom,int prot, +xen_pfn_t *arr,int num) { +int fd = (int )h;privcmd_mmapbatch_t ioctlx;void *addr; - addr =mmap (NULL , num*PAGE_SIZE , prot,MAP_SHARED , xch->fd,0 ); + addr =mmap (NULL , num*PAGE_SIZE , prot,MAP_SHARED , fd,0 );if ( addr ==MAP_FAILED )return NULL ;
@@ -87,7 +89,7 @@ void *xc_map_foreign_batch(xc_interface ioctlx.dom=dom; ioctlx.addr=(unsigned long )addr; ioctlx.arr=arr; -if (ioctl (xch->fd,IOCTL_PRIVCMD_MMAPBATCH , &ioctlx) <0 ) +if (ioctl (fd,IOCTL_PRIVCMD_MMAPBATCH , &ioctlx) <0 ) {int saved_errno = errno;PERROR ("XXXXXXXX" );
@@ -168,6 +170,9 @@ static struct xc_osdep_ops solaris_privc .u.privcmd = { .hypercall = &solaris_privcmd_hypercall; + + .map_foreign_batch = &solaris_privcmd_map_foreign_batch, + .map_foreign_bulk = &xc_map_foreign_bulk_compat, }, };
tools/libxc/xenctrlosdep.h +10 -0
@@ -63,6 +63,11 @@ struct xc_osdep_opsunion {struct {int (*hypercall)(xc_interface *xch,xc_osdep_handle h,privcmd_hypercall_t *hypercall); + +void *(*map_foreign_batch)(xc_interface *xch,xc_osdep_handle h,uint32_t dom,int prot, +xen_pfn_t *arr,int num); +void *(*map_foreign_bulk)(xc_interface *xch,xc_osdep_handle h,uint32_t dom,int prot, +const xen_pfn_t *arr,int *err,unsigned int num); } privcmd; } u; };
@@ -83,6 +88,11 @@ typedef struct xc_osdep_info xc_osdep_in/* All backends, including the builtin backend, must supply this structure. */ extern xc_osdep_info_t xc_osdep_info; +/* Stub for not yet converted OSes */ +void *xc_map_foreign_bulk_compat (xc_interface *xch,xc_osdep_handle h, +uint32_t dom,int prot, +const xen_pfn_t *arr,int *err,unsigned int num); +#endif /*
PATCH 1/1 libxc: osdep: convert xc_map_foreign_range()
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID 1c71417729377312b82096541adec0bd19e8f2d0 # Parent d0214e8537cee3c401e5ba5567d632d386ac5860
libxc: osdep: convert xc_map_foreign_range()
tools/libxc/xc_foreign_memory.c +18 -1
@@ -20,8 +20,15 @@#include "xc_private.h" +void *xc_map_foreign_range (xc_interface *xch,uint32_t dom, +int size,int prot,unsigned long mfn) +{ +return xch->ops->u.privcmd.map_foreign_range (xch, xch->ops_handle, + dom, size, prot, mfn); +} +void *xc_map_foreign_batch (xc_interface *xch,uint32_t dom,int prot, -xen_pfn_t *arr,int num ) +xen_pfn_t *arr,int num) {return xch->ops->u.privcmd.map_foreign_batch (xch, xch->ops_handle, dom, prot, arr, num);
@@ -33,3 +40,13 @@ void *xc_map_foreign_bulk(xc_interface *return xch->ops->u.privcmd.map_foreign_bulk (xch, xch->ops_handle, dom, prot, arr, err, num); } + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxc/xc_linux.c +4 -2
@@ -283,8 +283,9 @@ static void *linux_privcmd_map_foreign_breturn addr; } -void *xc_map_foreign_range (xc_interface *xch,uint32_t dom,int size,int prot, -unsigned long mfn) +static void *linux_privcmd_map_foreign_range (xc_interface *xch,xc_osdep_handle h, +uint32_t dom,int size,int prot, +unsigned long mfn) {xen_pfn_t *arr;int num;
@@ -335,6 +336,7 @@ static struct xc_osdep_ops linux_privcmd .map_foreign_batch = &linux_privcmd_map_foreign_batch, .map_foreign_bulk = &linux_privcmd_map_foreign_bulk, + .map_foreign_range = &linux_privcmd_map_foreign_range, }, };
tools/libxc/xc_minios.c +5 -3
@@ -134,9 +134,10 @@ static void *minios_privcmd_map_foreign_return (void *) addr; } -void *xc_map_foreign_range (xc_interface *xch,uint32_t dom, -int size,int prot, -unsigned long mfn) +static void *minios_privcmd_map_foreign_range (xc_interface *xch,xc_osdep_handle h, +uint32_t dom, +int size,int prot, +unsigned long mfn) {unsigned long pt_prot =0 ;#ifdef __ia64__
@@ -190,6 +191,7 @@ static struct xc_osdep_ops minios_privcm .map_foreign_batch = &minios_privcmd_map_foreign_batch, .map_foreign_bulk = &minios_privcmd_map_foreign_bulk, + .map_foreign_range = &minios_privcmd_map_foreign_range, }, };
tools/libxc/xc_netbsd.c +7 -4
@@ -108,10 +108,12 @@ static void *netbsd_privcmd_map_foreign_ } -void *xc_map_foreign_range (xc_interface *xch,uint32_t dom, -int size,int prot, -unsigned long mfn) +static void *netbsd_privcmd_map_foreign_range (xc_interface *xch,xc_osdep_handle h, +uint32_t dom, +int size,int prot, +unsigned long mfn) { +int fd = (int )h;privcmd_mmap_t ioctlx;privcmd_mmap_entry_t entry;void *addr;
@@ -127,7 +129,7 @@ void *xc_map_foreign_range(xc_interface entry.va=(unsigned long ) addr; entry.mfn=mfn; entry.npages=(size+PAGE_SIZE -1 )>>PAGE_SHIFT ; -if (ioctl (xch->fd,IOCTL_PRIVCMD_MMAP , &ioctlx) <0 ) +if (ioctl (fd,IOCTL_PRIVCMD_MMAP , &ioctlx) <0 ) {int saved_errno = errno;PERROR ("xc_map_foreign_range: ioctl failed" );
@@ -183,6 +185,7 @@ static struct xc_osdep_ops netbsd_privcm .map_foreign_batch = &netbsd_privcmd_map_foreign_batch, .map_foreign_bulk = &xc_map_foreign_bulk_compat, + .map_foreign_range = &netbsd_privcmd_map_foreign_range, }, };
tools/libxc/xc_solaris.c +8 -5
@@ -101,14 +101,16 @@ static void *solaris_privcmd_map_foreign } -void *xc_map_foreign_range (xc_interface *xch,uint32_t dom, -int size,int prot, -unsigned long mfn) +static void *xc_map_foreign_range (xc_interface *xch,xc_osdep_handle h, +uint32_t dom, +int size,int prot, +unsigned long mfn) { +int fd = (int )fd;privcmd_mmap_t ioctlx;privcmd_mmap_entry_t entry;void *addr; - addr =mmap (NULL , size, prot,MAP_SHARED , xch->fd,0 ); + addr =mmap (NULL , size, prot,MAP_SHARED , fd,0 );if ( addr ==MAP_FAILED )return NULL ;
@@ -118,7 +120,7 @@ void *xc_map_foreign_range(xc_interface entry.va=(unsigned long ) addr; entry.mfn=mfn; entry.npages=(size+PAGE_SIZE -1 )>>PAGE_SHIFT ; -if (ioctl (xch->fd,IOCTL_PRIVCMD_MMAP , &ioctlx) <0 ) +if (ioctl (fd,IOCTL_PRIVCMD_MMAP , &ioctlx) <0 ) {int saved_errno = errno; (void )munmap (addr, size);
@@ -173,6 +175,7 @@ static struct xc_osdep_ops solaris_privc .map_foreign_batch = &solaris_privcmd_map_foreign_batch, .map_foreign_bulk = &xc_map_foreign_bulk_compat, + .map_foreign_range = &solaris_privcmd_map_foreign_range, }, };
tools/libxc/xenctrlosdep.h +2 -0
@@ -68,6 +68,8 @@ struct xc_osdep_ops xen_pfn_t *arr, int num);void *(*map_foreign_bulk)(xc_interface *xch,xc_osdep_handle h,uint32_t dom,int prot,const xen_pfn_t *arr,int *err,unsigned int num); +void *(*map_foreign_range)(xc_interface *xch,xc_osdep_handle h,uint32_t dom,int size,int prot, +unsigned long mfn); } privcmd; } u; };
PATCH 1/1 libxc: osdep: convert xc_map_foreign_ranges()
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID c4d555d68b742405874662bbc57bfe98a9e250dd # Parent 1c71417729377312b82096541adec0bd19e8f2d0
libxc: osdep: convert xc_map_foreign_ranges()
tools/libxc/xc_foreign_memory.c +8 -0
@@ -27,6 +27,14 @@ void *xc_map_foreign_range(xc_interface dom, size, prot, mfn); } +void *xc_map_foreign_ranges (xc_interface *xch,uint32_t dom, +size_t size,int prot,size_t chunksize, +privcmd_mmap_entry_t entries[],int nentries) +{ +return xch->ops->u.privcmd.map_foreign_ranges (xch, xch->ops_handle, + dom, size, prot, chunksize, entries, nentries); +} +void *xc_map_foreign_batch (xc_interface *xch,uint32_t dom,int prot,xen_pfn_t *arr,int num) {
tools/libxc/xc_linux.c +5 -3
@@ -303,9 +303,10 @@ static void *linux_privcmd_map_foreign_rreturn ret; } -void *xc_map_foreign_ranges (xc_interface *xch,uint32_t dom,size_t size,int prot, -size_t chunksize,privcmd_mmap_entry_t entries[], -int nentries) +static void *linux_privcmd_map_foreign_ranges (xc_interface *xch,xc_osdep_handle h, +uint32_t dom,size_t size,int prot, +size_t chunksize,privcmd_mmap_entry_t entries[], +int nentries) {xen_pfn_t *arr;int num_per_entry;
@@ -337,6 +338,7 @@ static struct xc_osdep_ops linux_privcmd .map_foreign_batch = &linux_privcmd_map_foreign_batch, .map_foreign_bulk = &linux_privcmd_map_foreign_bulk, .map_foreign_range = &linux_privcmd_map_foreign_range, + .map_foreign_ranges = &linux_privcmd_map_foreign_ranges, }, };
tools/libxc/xc_minios.c +5 -3
@@ -152,9 +152,10 @@ static void *minios_privcmd_map_foreign_return map_frames_ex (&mfn, size /getpagesize (),0 ,1 ,1 , dom,NULL , pt_prot); } -void *xc_map_foreign_ranges (xc_interface *xch,uint32_t dom, -size_t size,int prot,size_t chunksize, -privcmd_mmap_entry_t entries[],int nentries) +static void *minios_privcmd_map_foreign_ranges (xc_interface *xch,xc_osdep_handle h, +uint32_t dom, +size_t size,int prot,size_t chunksize, +privcmd_mmap_entry_t entries[],int nentries) {unsigned long *mfns;int i, j, n;
@@ -192,6 +193,7 @@ static struct xc_osdep_ops minios_privcm .map_foreign_batch = &minios_privcmd_map_foreign_batch, .map_foreign_bulk = &minios_privcmd_map_foreign_bulk, .map_foreign_range = &minios_privcmd_map_foreign_range, + .map_foreign_ranges = &minios_privcmd_map_foreign_ranges, }, };
tools/libxc/xc_netbsd.c +7 -4
@@ -140,10 +140,12 @@ static void *netbsd_privcmd_map_foreign_return addr; } -void *xc_map_foreign_ranges (xc_interface *xch,uint32_t dom, -size_t size,int prot,size_t chunksize, -privcmd_mmap_entry_t entries[],int nentries) +static void *netbsd_privcmd_map_foreign_ranges (xc_interface *xch,xc_osdep_handle h, +uint32_t dom, +size_t size,int prot,size_t chunksize, +privcmd_mmap_entry_t entries[],int nentries) { +int fd = (int )h;privcmd_mmap_t ioctlx;int i, rc;void *addr;
@@ -161,7 +163,7 @@ void *xc_map_foreign_ranges(xc_interface ioctlx.dom = dom; ioctlx.entry = entries; - rc =ioctl (xch->fd,IOCTL_PRIVCMD_MMAP , &ioctlx); + rc =ioctl (fd,IOCTL_PRIVCMD_MMAP , &ioctlx);if (rc) goto ioctl_failed;
@@ -186,6 +188,7 @@ static struct xc_osdep_ops netbsd_privcm .map_foreign_batch = &netbsd_privcmd_map_foreign_batch, .map_foreign_bulk = &xc_map_foreign_bulk_compat, .map_foreign_range = &netbsd_privcmd_map_foreign_range, + .map_foreign_ranges = &netbsd_privcmd_map_foreign_ranges, }, };
tools/libxc/xc_solaris.c +8 -5
@@ -130,15 +130,17 @@ static void *xc_map_foreign_range(xc_intreturn addr; } -void *xc_map_foreign_ranges (xc_interface *xch,uint32_t dom, -size_t size,int prot,size_t chunksize, -privcmd_mmap_entry_t entries[],int nentries) +static void *solaric_privcmd_map_foreign_ranges (xc_interface *xch,xc_osdep_handle h, +uint32_t dom, +size_t size,int prot,size_t chunksize, +privcmd_mmap_entry_t entries[],int nentries) { +int fd = (int )fd;privcmd_mmap_t ioctlx;int i, rc;void *addr; - addr =mmap (NULL , size, prot,MAP_SHARED , xch->fd,0 ); + addr =mmap (NULL , size, prot,MAP_SHARED , fd,0 );if (addr ==MAP_FAILED ) goto mmap_failed;
@@ -151,7 +153,7 @@ void *xc_map_foreign_ranges(xc_interface ioctlx.dom = dom; ioctlx.entry = entries; - rc =ioctl (xch->fd,IOCTL_PRIVCMD_MMAP , &ioctlx); + rc =ioctl (fd,IOCTL_PRIVCMD_MMAP , &ioctlx);if (rc) goto ioctl_failed;
@@ -176,6 +178,7 @@ static struct xc_osdep_ops solaris_privc .map_foreign_batch = &solaris_privcmd_map_foreign_batch, .map_foreign_bulk = &xc_map_foreign_bulk_compat, .map_foreign_range = &solaris_privcmd_map_foreign_range, + .map_foreign_ranges = &solaris_privcmd_map_foreign_ranges, }, };
tools/libxc/xenctrlosdep.h +3 -0
@@ -70,6 +70,9 @@ struct xc_osdep_ops const xen_pfn_t *arr, int *err, unsigned int num);void *(*map_foreign_range)(xc_interface *xch,xc_osdep_handle h,uint32_t dom,int size,int prot,unsigned long mfn); +void *(*map_foreign_ranges)(xc_interface *xch,xc_osdep_handle h,uint32_t dom,size_t size,int prot, +size_t chunksize,privcmd_mmap_entry_t entries[], +int nentries); } privcmd; } u; };
PATCH 1/1 libxc: osdep: convert xc_evtchn_fd()
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID 48c16f1810aa383774b6c0e373d24838c7affffc # Parent c4d555d68b742405874662bbc57bfe98a9e250dd
libxc: osdep: convert xc_evtchn_fd()
tools/libxc/xc_evtchn.c +5 -0
@@ -77,3 +77,8 @@ int xc_evtchn_status(xc_interface *xch,return do_evtchn_op (xch, EVTCHNOP_status, status,sizeof (*status),1 ); } + +int xc_evtchn_fd (xc_evtchn *xce) +{ +return xce->ops->u.evtchn.fd (xce, xce->ops_handle); +}
tools/libxc/xc_linux.c +6 -2
@@ -360,9 +360,9 @@ static int linux_evtchn_close(xc_evtchnreturn close (fd); } -int xc_evtchn_fd (xc_evtchn *xce) +static int linux_evtchn_fd (xc_evtchn *xce,xc_osdep_handle h) { -return xce->fd; +return (int )h; }int xc_evtchn_notify (xc_evtchn *xce,evtchn_port_t port)
@@ -434,6 +434,10 @@ static struct xc_osdep_ops linux_evtchn_static struct xc_osdep_ops linux_evtchn_ops = { .open = &linux_evtchn_open, .close = &linux_evtchn_close, + + .u.evtchn = { + .fd = &linux_evtchn_fd, + }, };/* Optionally flush file to disk and discard page cache */
tools/libxc/xc_minios.c +6 -2
@@ -226,9 +226,9 @@ void minios_evtchn_close_fd(int fd) files[fd].type =FTYPE_NONE ; } -int xc_evtchn_fd (xc_evtchn *xce) +static int minios_evtchn_fd (xc_evtchn *xce,xc_osdep_handle h) { -return xce->fd; +return (int )h; }int xc_evtchn_notify (xc_evtchn *xce,evtchn_port_t port)
@@ -400,6 +400,10 @@ static struct xc_osdep_ops minios_evtchnstatic struct xc_osdep_ops minios_evtchn_ops = { .open = &minios_evtchn_open, .close = &minios_evtchn_close, + + .u.evtchn = { + .fd = &minios_evtchn_fd, + }, };/* Optionally flush file to disk and discard page cache */
tools/libxc/xc_netbsd.c +6 -2
@@ -210,9 +210,9 @@ static int netbsd_evtchn_close(xc_evtchnreturn close (fd); } -int xc_evtchn_fd (xc_evtchn *xce) +static int netbsd_evtchn_fd (xc_evtchn *xce,xc_osdep_handle h) { -return xce->fd; +return (int )h; }int xc_evtchn_notify (xc_evtchn *xce,evtchn_port_t port)
@@ -299,6 +299,10 @@ static struct xc_osdep_ops netbsd_evtchnstatic struct xc_osdep_ops netbsd_evtchn_ops = { .open = &netbsd_evtchn_open, .close = &netbsd_evtchn_close, + + .u.evtchn = { + .fd = &netbsd_evtchn_fd, + }, };/* Optionally flush file to disk and discard page cache */
tools/libxc/xc_solaris.c +6 -2
@@ -202,9 +202,9 @@ static int solaris_evtchn_close(xc_evtchreturn close (fd); } -int xc_evtchn_fd (xc_evtchn *xce) +static int solaris_evtchn_fd (xc_evtchn *xce,xc_osdep_handle h) { -return xce->fd; +return (int )h; }int xc_evtchn_notify (xc_evtchn *xce,evtchn_port_t port)
@@ -276,6 +276,10 @@ static struct xc_osdep_ops solaris_evtchstatic struct xc_osdep_ops solaris_evtchn_ops = { .open = &solaris_evtchn_open, .close = &solaris_evtchn_close, + + .u.evtchn = { + .fd = &solaris_evtchn_fd, + }, };/* Optionally flush file to disk and discard page cache */
tools/libxc/xenctrlosdep.h +3 -0
@@ -74,6 +74,9 @@ struct xc_osdep_ops size_t chunksize, privcmd_mmap_entry_t entries[], int nentries); } privcmd; +struct { +int (*fd)(xc_evtchn *xce,xc_osdep_handle h); + } evtchn; } u; };typedef struct xc_osdep_ops xc_osdep_ops ;
PATCH 1/1 libxc: osdep: convert xc_evtchn_notify()
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID f8ada96329da34e94ac3a7f4a6c6967aa5d2dd73 # Parent 48c16f1810aa383774b6c0e373d24838c7affffc
libxc: osdep: convert xc_evtchn_notify()
tools/libxc/xc_evtchn.c +15 -0
@@ -82,3 +82,18 @@ int xc_evtchn_fd(xc_evtchn *xce) {return xce->ops->u.evtchn.fd (xce, xce->ops_handle); } + +int xc_evtchn_notify (xc_evtchn *xce,evtchn_port_t port) +{ +return xce->ops->u.evtchn.notify (xce, xce->ops_handle, port); +} + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxc/xc_linux.c +4 -2
@@ -365,13 +365,14 @@ static int linux_evtchn_fd(xc_evtchn *xcreturn (int )h; } -int xc_evtchn_notify (xc_evtchn *xce,evtchn_port_t port) +static int linux_evtchn_notify (xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port) { +int fd = (int )h;struct ioctl_evtchn_notify notify; notify.port = port; -return ioctl (xce->fd,IOCTL_EVTCHN_NOTIFY , ¬ify); +return ioctl (fd,IOCTL_EVTCHN_NOTIFY , ¬ify); } evtchn_port_or_error_t
@@ -437,6 +438,7 @@ static struct xc_osdep_ops linux_evtchn_ .u.evtchn = { .fd = &linux_evtchn_fd, + .notify = &linux_evtchn_notify, }, };
tools/libxc/xc_minios.c +2 -1
@@ -231,7 +231,7 @@ static int minios_evtchn_fd(xc_evtchn *xreturn (int )h; } -int xc_evtchn_notify (xc_evtchn *xce,evtchn_port_t port) +static int minios_evtchn_notify (xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port) {int ret;
@@ -403,6 +403,7 @@ static struct xc_osdep_ops minios_evtchn .u.evtchn = { .fd = &minios_evtchn_fd, + .notify = &minios_evtchn_notify, }, };
tools/libxc/xc_netbsd.c +5 -3
@@ -215,13 +215,14 @@ static int netbsd_evtchn_fd(xc_evtchn *xreturn (int )h; } -int xc_evtchn_notify (xc_evtchn *xce,evtchn_port_t port) +static int netbsd_evtchn_notify (xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port) { +int fd = (int )h;struct ioctl_evtchn_notify notify; notify.port = port; -return ioctl (xce->fd,IOCTL_EVTCHN_NOTIFY , ¬ify); +return ioctl (fd,IOCTL_EVTCHN_NOTIFY , ¬ify); } evtchn_port_or_error_t
@@ -301,7 +302,8 @@ static struct xc_osdep_ops netbsd_evtchn .close = &netbsd_evtchn_close, .u.evtchn = { - .fd = &netbsd_evtchn_fd, + .fd = &netbsd_evtchn_fd, + .notify = &netbsd_evtchn_notify, }, };
tools/libxc/xc_solaris.c +4 -2
@@ -207,13 +207,14 @@ static int solaris_evtchn_fd(xc_evtchn *return (int )h; } -int xc_evtchn_notify (xc_evtchn *xce,evtchn_port_t port) +static int solaris_evtchn_notify (xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port) { +int fd = (int )h;struct ioctl_evtchn_notify notify; notify.port = port; -return ioctl (xce->fd,IOCTL_EVTCHN_NOTIFY , ¬ify); +return ioctl (fd,IOCTL_EVTCHN_NOTIFY , ¬ify); } evtchn_port_or_error_t
@@ -279,6 +280,7 @@ static struct xc_osdep_ops solaris_evtch .u.evtchn = { .fd = &solaris_evtchn_fd, + .notify = &solaris_evtchn_notify, }, };
tools/libxc/xenctrlosdep.h +2 -0
@@ -76,6 +76,8 @@ struct xc_osdep_ops } privcmd;struct {int (*fd)(xc_evtchn *xce,xc_osdep_handle h); + +int (*notify)(xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port); } evtchn; } u; };
PATCH 1/1 libxc: osdep: convert xc_evtchn_bind_unbound_port()
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID 8d07a123c875c57d0b1127d9a0cbd86c27c857d5 # Parent f8ada96329da34e94ac3a7f4a6c6967aa5d2dd73
libxc: osdep: convert xc_evtchn_bind_unbound_port()
tools/libxc/xc_evtchn.c +6 -0
@@ -88,6 +88,12 @@ int xc_evtchn_notify(xc_evtchn *xce, evtreturn xce->ops->u.evtchn.notify (xce, xce->ops_handle, port); } +evtchn_port_or_error_t +xc_evtchn_bind_unbound_port (xc_evtchn *xce,int domid) +{ +return xce->ops->u.evtchn.bind_unbound_port (xce, xce->ops_handle, domid); +} +/* * Local variables: * mode: C
tools/libxc/xc_linux.c +5 -3
@@ -375,14 +375,15 @@ static int linux_evtchn_notify(xc_evtchnreturn ioctl (fd,IOCTL_EVTCHN_NOTIFY , ¬ify); } -evtchn_port_or_error_t -xc_evtchn_bind_unbound_port (xc_evtchn *xce,int domid) +static evtchn_port_or_error_t +linux_evtchn_bind_unbound_port (xc_evtchn *xce,xc_osdep_handle h,int domid) { +int fd = (int )h;struct ioctl_evtchn_bind_unbound_port bind; bind.remote_domain = domid; -return ioctl (xce->fd,IOCTL_EVTCHN_BIND_UNBOUND_PORT , &bind); +return ioctl (fd,IOCTL_EVTCHN_BIND_UNBOUND_PORT , &bind); } evtchn_port_or_error_t
@@ -439,6 +440,7 @@ static struct xc_osdep_ops linux_evtchn_ .u.evtchn = { .fd = &linux_evtchn_fd, .notify = &linux_evtchn_notify, + .bind_unbound_port = &linux_evtchn_bind_unbound_port, }, };
tools/libxc/xc_minios.c +7 -5
@@ -277,26 +277,27 @@ static void evtchn_handler(evtchn_port_twake_up (&event_queue); } -evtchn_port_or_error_t xc_evtchn_bind_unbound_port (xc_evtchn *xce,int domid) +static evtchn_port_or_error_t minios_evtchn_bind_unbound_port (xc_evtchn *xce,xc_osdep_handle h,int domid) { +int fd = (int )h;int ret, i;evtchn_port_t port;assert (get_current () == main_thread); - i =port_alloc (xce->fd); + i =port_alloc (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->fd, &port); + ret =evtchn_alloc_unbound (domid, evtchn_handler, (void *)(intptr_t )fd, &port);printf (" = %d\n" , ret);if (ret <0 ) { errno = -ret;return -1 ; } - files[xce->fd].evtchn.ports[i].bound =1 ; - files[xce->fd].evtchn.ports[i].port = port; + files[fd].evtchn.ports[i].bound =1 ; + files[fd].evtchn.ports[i].port = port;unmask_evtchn (port);return port; }
@@ -404,6 +405,7 @@ static struct xc_osdep_ops minios_evtchn .u.evtchn = { .fd = &minios_evtchn_fd, .notify = &minios_evtchn_notify, + .bind_unbound_port = &minios_evtchn_bind_unbound_port, }, };
tools/libxc/xc_netbsd.c +5 -3
@@ -225,15 +225,16 @@ static int netbsd_evtchn_notify(xc_evtchreturn ioctl (fd,IOCTL_EVTCHN_NOTIFY , ¬ify); } -evtchn_port_or_error_t -xc_evtchn_bind_unbound_port (xc_evtchn * xce,int domid) +static evtchn_port_or_error_t +netbsd_evtchn_bind_unbound_port (xc_evtchn * xce,xc_osdep_handle h,int domid) { +int fd = (int )h;struct ioctl_evtchn_bind_unbound_port bind;int ret; bind.remote_domain = domid; - ret =ioctl (xce->fd,IOCTL_EVTCHN_BIND_UNBOUND_PORT , &bind); + ret =ioctl (fd,IOCTL_EVTCHN_BIND_UNBOUND_PORT , &bind);if (ret ==0 )return bind.port;else
@@ -304,6 +305,7 @@ static struct xc_osdep_ops netbsd_evtchn .u.evtchn = { .fd = &netbsd_evtchn_fd, .notify = &netbsd_evtchn_notify, + .bind_unbound_port = &netbsd_evtchn_bind_unbound_port, }, };
tools/libxc/xc_solaris.c +5 -3
@@ -217,14 +217,15 @@ static int solaris_evtchn_notify(xc_evtcreturn ioctl (fd,IOCTL_EVTCHN_NOTIFY , ¬ify); } -evtchn_port_or_error_t -xc_evtchn_bind_unbound_port (xc_evtchn *xce,int domid) +static evtchn_port_or_error_t +solaris_evtchn_bind_unbound_port (xc_evtchn *xce,xc_osdep_handle h,int domid) { +int fd = (int )h;struct ioctl_evtchn_bind_unbound_port bind; bind.remote_domain = domid; -return ioctl (xce->fd,IOCTL_EVTCHN_BIND_UNBOUND_PORT , &bind); +return ioctl (fd,IOCTL_EVTCHN_BIND_UNBOUND_PORT , &bind); } evtchn_port_or_error_t
@@ -281,6 +282,7 @@ static struct xc_osdep_ops solaris_evtch .u.evtchn = { .fd = &solaris_evtchn_fd, .notify = &solaris_evtchn_notify, + .bind_unbound_port = &solaris_evtchn_bind_unbound_port, }, };
tools/libxc/xenctrlosdep.h +2 -0
@@ -78,6 +78,8 @@ struct xc_osdep_opsint (*fd)(xc_evtchn *xce,xc_osdep_handle h);int (*notify)(xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port); + +evtchn_port_or_error_t (*bind_unbound_port)(xc_evtchn *xce,xc_osdep_handle h,int domid); } evtchn; } u; };
PATCH 1/1 libxc: osdep: convert xc_evtchn_bind_interdomain()
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID 7a24de957ebbf9ac8681962c0e6dccf4c657a1dc # Parent 8d07a123c875c57d0b1127d9a0cbd86c27c857d5
libxc: osdep: convert xc_evtchn_bind_interdomain()
tools/libxc/xc_evtchn.c +7 -0
@@ -94,6 +94,13 @@ xc_evtchn_bind_unbound_port(xc_evtchn *xreturn xce->ops->u.evtchn.bind_unbound_port (xce, xce->ops_handle, domid); } +evtchn_port_or_error_t +xc_evtchn_bind_interdomain (xc_evtchn *xce,int domid, +evtchn_port_t remote_port) +{ +return xce->ops->u.evtchn.bind_interdomain (xce, xce->ops_handle, domid, remote_port); +} +/* * Local variables: * mode: C
tools/libxc/xc_linux.c +6 -4
@@ -386,16 +386,17 @@ linux_evtchn_bind_unbound_port(xc_evtchnreturn ioctl (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) +static evtchn_port_or_error_t +linux_evtchn_bind_interdomain (xc_evtchn *xce,xc_osdep_handle h,int domid, +evtchn_port_t remote_port) { +int fd = (int )h;struct ioctl_evtchn_bind_interdomain bind; bind.remote_domain = domid; bind.remote_port = remote_port; -return ioctl (xce->fd,IOCTL_EVTCHN_BIND_INTERDOMAIN , &bind); +return ioctl (fd,IOCTL_EVTCHN_BIND_INTERDOMAIN , &bind); } evtchn_port_or_error_t
@@ -441,6 +442,7 @@ static struct xc_osdep_ops linux_evtchn_ .fd = &linux_evtchn_fd, .notify = &linux_evtchn_notify, .bind_unbound_port = &linux_evtchn_bind_unbound_port, + .bind_interdomain = &linux_evtchn_bind_interdomain, }, };
tools/libxc/xc_minios.c +7 -5
@@ -302,27 +302,28 @@ static evtchn_port_or_error_t minios_evtreturn port; } -evtchn_port_or_error_t xc_evtchn_bind_interdomain (xc_evtchn *xce,int domid, +static evtchn_port_or_error_t minios_evtchn_bind_interdomain (xc_evtchn *xce,xc_osdep_handle h,int domid,evtchn_port_t remote_port) { +int fd = (int )h;evtchn_port_t local_port;int ret, i;assert (get_current () == main_thread); - i =port_alloc (xce->fd); + i =port_alloc (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->fd, &local_port); + ret =evtchn_bind_interdomain (domid, remote_port, evtchn_handler, (void *)(intptr_t )fd, &local_port);printf (" = %d\n" , ret);if (ret <0 ) { errno = -ret;return -1 ; } - files[xce->fd].evtchn.ports[i].bound =1 ; - files[xce->fd].evtchn.ports[i].port = local_port; + files[fd].evtchn.ports[i].bound =1 ; + files[fd].evtchn.ports[i].port = local_port;unmask_evtchn (local_port);return local_port; }
@@ -406,6 +407,7 @@ static struct xc_osdep_ops minios_evtchn .fd = &minios_evtchn_fd, .notify = &minios_evtchn_notify, .bind_unbound_port = &minios_evtchn_bind_unbound_port, + .bind_interdomain = &minios_evtchn_bind_interdomain, }, };
tools/libxc/xc_netbsd.c +6 -4
@@ -241,17 +241,18 @@ netbsd_evtchn_bind_unbound_port(xc_evtchreturn -1 ; } -evtchn_port_or_error_t -xc_evtchn_bind_interdomain (xc_evtchn *xce,int domid, -evtchn_port_t remote_port) +static evtchn_port_or_error_t +netbsd_evtchn_bind_interdomain (xc_evtchn *xce,xc_osdep_handle h,int domid, +evtchn_port_t remote_port) { +int fd = (int )h;struct ioctl_evtchn_bind_interdomain bind;int ret; bind.remote_domain = domid; bind.remote_port = remote_port; - ret =ioctl (xce->fd,IOCTL_EVTCHN_BIND_INTERDOMAIN , &bind); + ret =ioctl (fd,IOCTL_EVTCHN_BIND_INTERDOMAIN , &bind);if (ret ==0 )return bind.port;else
@@ -306,6 +307,7 @@ static struct xc_osdep_ops netbsd_evtchn .fd = &netbsd_evtchn_fd, .notify = &netbsd_evtchn_notify, .bind_unbound_port = &netbsd_evtchn_bind_unbound_port, + .bind_interdomain = &netbsd_evtchn_bind_interdomain, }, };
tools/libxc/xc_solaris.c +4 -2
@@ -229,15 +229,16 @@ solaris_evtchn_bind_unbound_port(xc_evtc }evtchn_port_or_error_t -xc_evtchn_bind_interdomain (xc_evtchn *xce,int domid, +solaris_evtchn_bind_interdomain (xc_evtchn *xce,xc_osdep_handle h,int domid,evtchn_port_t remote_port) { +int fd = (int )h;struct ioctl_evtchn_bind_interdomain bind; bind.remote_domain = domid; bind.remote_port = remote_port; -return ioctl (xce->fd,IOCTL_EVTCHN_BIND_INTERDOMAIN , &bind); +return ioctl (fd,IOCTL_EVTCHN_BIND_INTERDOMAIN , &bind); } evtchn_port_or_error_t
@@ -283,6 +284,7 @@ static struct xc_osdep_ops solaris_evtch .fd = &solaris_evtchn_fd, .notify = &solaris_evtchn_notify, .bind_unbound_port = &solaris_evtchn_bind_unbound_port, + .bind_interdomain = &solaris_evtchn_bind_interdomain, }, };
tools/libxc/xenctrlosdep.h +2 -0
@@ -80,6 +80,8 @@ struct xc_osdep_opsint (*notify)(xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port);evtchn_port_or_error_t (*bind_unbound_port)(xc_evtchn *xce,xc_osdep_handle h,int domid); +evtchn_port_or_error_t (*bind_interdomain)(xc_evtchn *xce,xc_osdep_handle h,int domid, +evtchn_port_t remote_port); } evtchn; } u; };
PATCH 1/1 libxc: osdep: convert xc_evtchn_bind_virq()
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID 32767e7632ccac87a9b0b33ec8a2322a7938af68 # Parent 7a24de957ebbf9ac8681962c0e6dccf4c657a1dc
libxc: osdep: convert xc_evtchn_bind_virq()
tools/libxc/xc_evtchn.c +6 -0
@@ -101,6 +101,12 @@ xc_evtchn_bind_interdomain(xc_evtchn *xcreturn xce->ops->u.evtchn.bind_interdomain (xce, xce->ops_handle, domid, remote_port); } +evtchn_port_or_error_t +xc_evtchn_bind_virq (xc_evtchn *xce,unsigned int virq) +{ +return xce->ops->u.evtchn.bind_virq (xce, xce->ops_handle, virq); +} +/* * Local variables: * mode: C
tools/libxc/xc_linux.c +5 -3
@@ -399,14 +399,15 @@ linux_evtchn_bind_interdomain(xc_evtchnreturn ioctl (fd,IOCTL_EVTCHN_BIND_INTERDOMAIN , &bind); } -evtchn_port_or_error_t -xc_evtchn_bind_virq (xc_evtchn *xce,unsigned int virq) +static evtchn_port_or_error_t +linux_evtchn_bind_virq (xc_evtchn *xce,xc_osdep_handle h,unsigned int virq) { +int fd = (int )h;struct ioctl_evtchn_bind_virq bind; bind.virq = virq; -return ioctl (xce->fd,IOCTL_EVTCHN_BIND_VIRQ , &bind); +return ioctl (fd,IOCTL_EVTCHN_BIND_VIRQ , &bind); }int xc_evtchn_unbind (xc_evtchn *xce,evtchn_port_t port)
@@ -443,6 +444,7 @@ static struct xc_osdep_ops linux_evtchn_ .notify = &linux_evtchn_notify, .bind_unbound_port = &linux_evtchn_bind_unbound_port, .bind_interdomain = &linux_evtchn_bind_interdomain, + .bind_virq = &linux_evtchn_bind_virq, }, };
tools/libxc/xc_minios.c +7 -5
@@ -346,25 +346,26 @@ int xc_evtchn_unbind(xc_evtchn *xce, evtreturn 0 ; } -evtchn_port_or_error_t xc_evtchn_bind_virq (xc_evtchn *xce,unsigned int virq) +static evtchn_port_or_error_t minios_evtchn_bind_virq (xc_evtchn *xce,xc_osdep_handle h,unsigned int virq) { +int fd = (int )h;evtchn_port_t port;int i;assert (get_current () == main_thread); - i =port_alloc (xce->fd); + i =port_alloc (fd);if (i ==-1 )return -1 ;printf ("xc_evtchn_bind_virq(%d)" , virq); - port =bind_virq (virq, evtchn_handler, (void *)(intptr_t )xce->fd); + port =bind_virq (virq, evtchn_handler, (void *)(intptr_t )fd);if (port <0 ) { errno = -port;return -1 ; } - files[xce->fd].evtchn.ports[i].bound =1 ; - files[xce->fd].evtchn.ports[i].port = port; + files[fd].evtchn.ports[i].bound =1 ; + files[fd].evtchn.ports[i].port = port;unmask_evtchn (port);return port; }
@@ -408,6 +409,7 @@ static struct xc_osdep_ops minios_evtchn .notify = &minios_evtchn_notify, .bind_unbound_port = &minios_evtchn_bind_unbound_port, .bind_interdomain = &minios_evtchn_bind_interdomain, + .bind_virq = &minios_evtchn_bind_virq, }, };
tools/libxc/xc_netbsd.c +5 -3
@@ -268,15 +268,16 @@ int xc_evtchn_unbind(xc_evtchn *xce, evtreturn ioctl (xce->fd,IOCTL_EVTCHN_UNBIND , &unbind); } -evtchn_port_or_error_t -xc_evtchn_bind_virq (xc_evtchn *xce,unsigned int virq) +static evtchn_port_or_error_t +netbsd_evtchn_bind_virq (xc_evtchn *xce,xc_osdep_handle h,unsigned int virq) { +int fd = (int )h;struct ioctl_evtchn_bind_virq bind;int err; bind.virq = virq; - err =ioctl (xce->fd,IOCTL_EVTCHN_BIND_VIRQ , &bind); + err =ioctl (fd,IOCTL_EVTCHN_BIND_VIRQ , &bind);if (err)return -1 ;else
@@ -308,6 +309,7 @@ static struct xc_osdep_ops netbsd_evtchn .notify = &netbsd_evtchn_notify, .bind_unbound_port = &netbsd_evtchn_bind_unbound_port, .bind_interdomain = &netbsd_evtchn_bind_interdomain, + .bind_virq = &netbsd_evtchn_bind_virq, }, };
tools/libxc/xc_solaris.c +5 -3
@@ -241,14 +241,15 @@ solaris_evtchn_bind_interdomain(xc_evtchreturn ioctl (fd,IOCTL_EVTCHN_BIND_INTERDOMAIN , &bind); } -evtchn_port_or_error_t -xc_evtchn_bind_virq (xc_evtchn *xce,unsigned int virq) +static evtchn_port_or_error_t +solaris_evtchn_bind_virq (xc_evtchn *xce,xc_osdep_handle h,unsigned int virq) { +int fd = (int )h;struct ioctl_evtchn_bind_virq bind; bind.virq = virq; -return ioctl (xce->fd,IOCTL_EVTCHN_BIND_VIRQ , &bind); +return ioctl (fd,IOCTL_EVTCHN_BIND_VIRQ , &bind); }int xc_evtchn_unbind (xc_evtchn *xce,evtchn_port_t port)
@@ -285,6 +286,7 @@ static struct xc_osdep_ops solaris_evtch .notify = &solaris_evtchn_notify, .bind_unbound_port = &solaris_evtchn_bind_unbound_port, .bind_interdomain = &solaris_evtchn_bind_interdomain, + .bind_virq = &solaris_evtchn_bind_virq, }, };
tools/libxc/xenctrlosdep.h +1 -0
@@ -82,6 +82,7 @@ struct xc_osdep_opsevtchn_port_or_error_t (*bind_unbound_port)(xc_evtchn *xce,xc_osdep_handle h,int domid);evtchn_port_or_error_t (*bind_interdomain)(xc_evtchn *xce,xc_osdep_handle h,int domid,evtchn_port_t remote_port); +evtchn_port_or_error_t (*bind_virq)(xc_evtchn *xce,xc_osdep_handle h,unsigned int virq); } evtchn; } u; };
PATCH 1/1 libxc: osdep: convert xc_evtchn_unbind()
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID 03b9f81f1f367a2143e2ef48fd7f2a57b0c47643 # Parent 32767e7632ccac87a9b0b33ec8a2322a7938af68
libxc: osdep: convert xc_evtchn_unbind()
tools/libxc/xc_evtchn.c +5 -0
@@ -107,6 +107,11 @@ xc_evtchn_bind_virq(xc_evtchn *xce, unsireturn xce->ops->u.evtchn.bind_virq (xce, xce->ops_handle, virq); } +int xc_evtchn_unbind (xc_evtchn *xce,evtchn_port_t port) +{ +return xce->ops->u.evtchn.unbind (xce, xce->ops_handle, port); +} +/* * Local variables: * mode: C
tools/libxc/xc_linux.c +4 -2
@@ -410,13 +410,14 @@ linux_evtchn_bind_virq(xc_evtchn *xce, xreturn ioctl (fd,IOCTL_EVTCHN_BIND_VIRQ , &bind); } -int xc_evtchn_unbind (xc_evtchn *xce,evtchn_port_t port) +static int linux_evtchn_unbind (xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port) { +int fd = (int )h;struct ioctl_evtchn_unbind unbind; unbind.port = port; -return ioctl (xce->fd,IOCTL_EVTCHN_UNBIND , &unbind); +return ioctl (fd,IOCTL_EVTCHN_UNBIND , &unbind); } evtchn_port_or_error_t
@@ -445,6 +446,7 @@ static struct xc_osdep_ops linux_evtchn_ .bind_unbound_port = &linux_evtchn_bind_unbound_port, .bind_interdomain = &linux_evtchn_bind_interdomain, .bind_virq = &linux_evtchn_bind_virq, + .unbind = &linux_evtchn_unbind, }, };
tools/libxc/xc_minios.c +7 -5
@@ -328,20 +328,21 @@ static evtchn_port_or_error_t minios_evtreturn local_port; } -int xc_evtchn_unbind (xc_evtchn *xce,evtchn_port_t port) +static int minios_evtchn_unbind (xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port) { +int fd = (int )h;int i;for (i =0 ; i <MAX_EVTCHN_PORTS ; i++) -if (files[xce->fd].evtchn.ports[i].port == port) { - files[xce->fd].evtchn.ports[i].port =-1 ; +if (files[fd].evtchn.ports[i].port == port) { + files[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->fd); +printf ("Warning: couldn't find port %" PRId32" for xc handle %x\n" , port, fd); errno = -EINVAL ;return -1 ; } - files[xce->fd].evtchn.ports[i].bound =0 ; + files[fd].evtchn.ports[i].bound =0 ;unbind_evtchn (port);return 0 ; }
@@ -410,6 +411,7 @@ static struct xc_osdep_ops minios_evtchn .bind_unbound_port = &minios_evtchn_bind_unbound_port, .bind_interdomain = &minios_evtchn_bind_interdomain, .bind_virq = &minios_evtchn_bind_virq, + .unbind = &minios_evtchn_unbind, }, };
tools/libxc/xc_netbsd.c +4 -2
@@ -259,13 +259,14 @@ netbsd_evtchn_bind_interdomain(xc_evtchnreturn -1 ; } -int xc_evtchn_unbind (xc_evtchn *xce,evtchn_port_t port) +static int netbsd_evtchn_unbind (xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port) { +int fd = (int )h;struct ioctl_evtchn_unbind unbind; unbind.port = port; -return ioctl (xce->fd,IOCTL_EVTCHN_UNBIND , &unbind); +return ioctl (fd,IOCTL_EVTCHN_UNBIND , &unbind); } static evtchn_port_or_error_t
@@ -310,6 +311,7 @@ static struct xc_osdep_ops netbsd_evtchn .bind_unbound_port = &netbsd_evtchn_bind_unbound_port, .bind_interdomain = &netbsd_evtchn_bind_interdomain, .bind_virq = &netbsd_evtchn_bind_virq, + .unbind = &netbsd_evtchn_unbind, }, };
tools/libxc/xc_solaris.c +4 -2
@@ -252,13 +252,14 @@ solaris_evtchn_bind_virq(xc_evtchn *xce,return ioctl (fd,IOCTL_EVTCHN_BIND_VIRQ , &bind); } -int xc_evtchn_unbind (xc_evtchn *xce,evtchn_port_t port) +static int solaris_evtchn_unbind (xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port) { +int fd = (int )h;struct ioctl_evtchn_unbind unbind; unbind.port = port; -return ioctl (xce->fd,IOCTL_EVTCHN_UNBIND , &unbind); +return ioctl (fd,IOCTL_EVTCHN_UNBIND , &unbind); } evtchn_port_or_error_t
@@ -287,6 +288,7 @@ static struct xc_osdep_ops solaris_evtch .bind_unbound_port = &solaris_evtchn_bind_unbound_port, .bind_interdomain = &solaris_evtchn_bind_interdomain, .bind_virq = &solaris_evtchn_bind_virq, + .unbind = &solaris_evtchn_unbind, }, };
tools/libxc/xenctrlosdep.h +2 -0
@@ -83,6 +83,8 @@ struct xc_osdep_opsevtchn_port_or_error_t (*bind_interdomain)(xc_evtchn *xce,xc_osdep_handle h,int domid,evtchn_port_t remote_port);evtchn_port_or_error_t (*bind_virq)(xc_evtchn *xce,xc_osdep_handle h,unsigned int virq); + +int (*unbind)(xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port); } evtchn; } u; };
PATCH 1/1 libxc: osdep: convert xc_evtchn_{pending, unmask}()
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID 3e8cb37144eb01a1ebb843882f4c3f43d0b4bd26 # Parent 03b9f81f1f367a2143e2ef48fd7f2a57b0c47643
libxc: osdep: convert xc_evtchn_{pending,unmask}()
tools/libxc/xc_evtchn.c +11 -0
@@ -112,6 +112,17 @@ int xc_evtchn_unbind(xc_evtchn *xce, evtreturn xce->ops->u.evtchn.unbind (xce, xce->ops_handle, port); } +evtchn_port_or_error_t +xc_evtchn_pending (xc_evtchn *xce) +{ +return xce->ops->u.evtchn.pending (xce, xce->ops_handle); +} + +int xc_evtchn_unmask (xc_evtchn *xce,evtchn_port_t port) +{ +return xce->ops->u.evtchn.unmask (xce, xce->ops_handle, port); +} +/* * Local variables: * mode: C
tools/libxc/xc_linux.c +11 -5
@@ -420,20 +420,24 @@ static int linux_evtchn_unbind(xc_evtchnreturn ioctl (fd,IOCTL_EVTCHN_UNBIND , &unbind); } -evtchn_port_or_error_t -xc_evtchn_pending (xc_evtchn *xce) +static evtchn_port_or_error_t linux_evtchn_pending (xc_evtchn *xce,xc_osdep_handle h) { +int fd = (int )h;evtchn_port_t port; -if (read_exact (xce->fd, (char *)&port,sizeof (port)) ==-1 ) +if (read (fd, &port,sizeof (port)) !=sizeof (port) )return -1 ;return port; } -int xc_evtchn_unmask (xc_evtchn *xce,evtchn_port_t port) +static int linux_evtchn_unmask (xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port) { -return write_exact (xce->fd, (char *)&port,sizeof (port)); +int fd = (int )h; + +if (write (fd, &port,sizeof (port)) !=sizeof (port) ) +return -1 ; +return 0 ; }static struct xc_osdep_ops linux_evtchn_ops = {
@@ -447,6 +451,8 @@ static struct xc_osdep_ops linux_evtchn_ .bind_interdomain = &linux_evtchn_bind_interdomain, .bind_virq = &linux_evtchn_bind_virq, .unbind = &linux_evtchn_unbind, + .pending = &linux_evtchn_pending, + .unmask = &linux_evtchn_unmask, }, };
tools/libxc/xc_minios.c +11 -8
@@ -371,22 +371,23 @@ static evtchn_port_or_error_t minios_evtreturn port; } -evtchn_port_or_error_t xc_evtchn_pending (xc_evtchn *xce) +static evtchn_port_or_error_t minios_evtchn_pending (xc_evtchn *xce,xc_osdep_handle h) { +int fd = (int )h;int i;unsigned long flags;evtchn_port_t ret =-1 ;local_irq_save (flags); - files[xce->fd].read =0 ; + files[fd].read =0 ;for (i =0 ; i <MAX_EVTCHN_PORTS ; i++) { -evtchn_port_t port = files[xce->fd].evtchn.ports[i].port; -if (port !=-1 && files[xce->fd].evtchn.ports[i].pending) { +evtchn_port_t port = files[fd].evtchn.ports[i].port; +if (port !=-1 && files[fd].evtchn.ports[i].pending) {if (ret ==-1 ) { ret = port; - files[xce->fd].evtchn.ports[i].pending =0 ; + files[fd].evtchn.ports[i].pending =0 ; }else { - files[xce->fd].read =1 ; + files[fd].read =1 ;break ; } }
@@ -395,7 +396,7 @@ evtchn_port_or_error_t xc_evtchn_pendingreturn ret; } -int xc_evtchn_unmask (xc_evtchn *xce,evtchn_port_t port) +static int minios_evtchn_unmask (xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port) {unmask_evtchn (port);return 0 ;
@@ -412,7 +413,9 @@ static struct xc_osdep_ops minios_evtchn .bind_interdomain = &minios_evtchn_bind_interdomain, .bind_virq = &minios_evtchn_bind_virq, .unbind = &minios_evtchn_unbind, - }, + .pending = &minios_evtchn_pending, + .unmask = &minios_evtchn_unmask, + }, };/* Optionally flush file to disk and discard page cache */
tools/libxc/xc_netbsd.c +9 -5
@@ -285,20 +285,22 @@ netbsd_evtchn_bind_virq(xc_evtchn *xce,return bind.port; } -evtchn_port_or_error_t -xc_evtchn_pending (xc_evtchn *xce) +static evtchn_port_or_error_t +netbsd_evtchn_pending (xc_evtchn *xce,xc_osdep_handle h) { +int fd = (int )h;evtchn_port_t port; -if (read_exact (xce->fd, (char *)&port,sizeof (port)) ==-1 ) +if (read_exact (fd, (char *)&port,sizeof (port)) ==-1 )return -1 ;return port; } -int xc_evtchn_unmask (xc_evtchn *xce,evtchn_port_t port) +static int netbsd_evtchn_unmask (xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port) { -return write_exact (xce->fd, (char *)&port,sizeof (port)); +int fd = (int )h; +return write_exact (fd, (char *)&port,sizeof (port)); }static struct xc_osdep_ops netbsd_evtchn_ops = {
@@ -312,6 +314,8 @@ static struct xc_osdep_ops netbsd_evtchn .bind_interdomain = &netbsd_evtchn_bind_interdomain, .bind_virq = &netbsd_evtchn_bind_virq, .unbind = &netbsd_evtchn_unbind, + .pending = &netbsd_evtchn_pending, + .unmask = &netbsd_evtchn_unmask, }, };
tools/libxc/xc_solaris.c +9 -5
@@ -262,20 +262,22 @@ static int solaris_evtchn_unbind(xc_evtcreturn ioctl (fd,IOCTL_EVTCHN_UNBIND , &unbind); } -evtchn_port_or_error_t -xc_evtchn_pending (xc_evtchn *xce) +static evtchn_port_or_error_t +solaris_evtchn_pending (xc_evtchn *xce,xc_osdep_handle h) { +int fd = (int )h;evtchn_port_t port; -if (read_exact (xce->fd, (char *)&port,sizeof (port)) ==-1 ) +if (read_exact (fd, (char *)&port,sizeof (port)) ==-1 )return -1 ;return port; } -int xc_evtchn_unmask (xc_evtchn *xce,evtchn_port_t port) +static int solaris_evtchn_unmask (xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port) { -return write_exact (xce->fd, (char *)&port,sizeof (port)); +int fd = (int )h; +return write_exact (fd, (char *)&port,sizeof (port)); }static struct xc_osdep_ops solaris_evtchn_ops = {
@@ -289,6 +291,8 @@ static struct xc_osdep_ops solaris_evtch .bind_interdomain = &solaris_evtchn_bind_interdomain, .bind_virq = &solaris_evtchn_bind_virq, .unbind = &solaris_evtchn_unbind, + .pending = &solaris_evtchn_pending, + .unmask = &solaris_evtchn_unmask, }, };
tools/libxc/xenctrlosdep.h +3 -0
@@ -85,6 +85,9 @@ struct xc_osdep_opsevtchn_port_or_error_t (*bind_virq)(xc_evtchn *xce,xc_osdep_handle h,unsigned int virq);int (*unbind)(xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port); + +evtchn_port_or_error_t (*pending)(xc_evtchn *xce,xc_osdep_handle h); +int (*unmask)(xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port); } evtchn; } u; };
PATCH 1/1 libxc: osdep: convert xc_gnttab_map_{grant_ref, grant_refs, domain_grant_refs}()
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1291369007 0
# Node ID 68996338758eabdecbdfc5cfb4aa82ab7589b4e6
# Parent 3e8cb37144eb01a1ebb843882f4c3f43d0b4bd26
libxc: osdep: convert xc_gnttab_map_{grant_ref,grant_refs,domain_grant_refs}()
tools/libxc/xc_gnttab.c +38 -0
@@ -145,3 +145,41 @@ grant_entry_v2_t *xc_gnttab_map_table_v2return _gnttab_map_table (xch, domid, gnt_num); } +void *xc_gnttab_map_grant_ref (xc_gnttab *xcg, +uint32_t domid, +uint32_t ref, +int prot) +{ +return xcg->ops->u.gnttab.map_grant_ref (xcg, xcg->ops_handle, + domid, ref, prot); +} + +void *xc_gnttab_map_grant_refs (xc_gnttab *xcg, +uint32_t count, +uint32_t *domids, +uint32_t *refs, +int prot) +{ +return xcg->ops->u.gnttab.map_grant_refs (xcg, xcg->ops_handle, + count, domids, refs, prot); +} + +void *xc_gnttab_map_domain_grant_refs (xc_gnttab *xcg, +uint32_t count, +uint32_t domid, +uint32_t *refs, +int prot) +{ +return xcg->ops->u.gnttab.map_domain_grant_refs (xcg, xcg->ops_handle, + count, domid, refs, prot); +} + +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxc/xc_linux.c +26 -14
@@ -508,8 +508,10 @@ static int linux_gnttab_close(xc_gnttabreturn close (fd); } -void *xc_gnttab_map_grant_ref (xc_gnttab *xch,uint32_t domid,uint32_t ref,int prot) +static void *linux_gnttab_map_grant_ref (xc_gnttab *xch,xc_osdep_handle h, +uint32_t domid,uint32_t ref,int prot) { +int fd = (int )h;struct ioctl_gntdev_map_grant_ref map;void *addr;
@@ -517,13 +519,13 @@ void *xc_gnttab_map_grant_ref(xc_gnttab map.refs[0 ].domid = domid; map.refs[0 ].ref = ref; -if (ioctl (xch->fd,IOCTL_GNTDEV_MAP_GRANT_REF , &map) ) { +if (ioctl (fd,IOCTL_GNTDEV_MAP_GRANT_REF , &map) ) {PERROR ("xc_gnttab_map_grant_ref: ioctl MAP_GRANT_REF failed" );return NULL ; } mmap_again: - addr =mmap (NULL ,PAGE_SIZE , prot,MAP_SHARED , xch->fd, map.index); + addr =mmap (NULL ,PAGE_SIZE , prot,MAP_SHARED , fd, map.index);if ( addr ==MAP_FAILED ) {int saved_errno = errno;
@@ -538,7 +540,7 @@ mmap_again:PERROR ("xc_gnttab_map_grant_ref: mmap failed" ); unmap_grant.index = map.index; unmap_grant.count =1 ; -ioctl (xch->fd,IOCTL_GNTDEV_UNMAP_GRANT_REF , &unmap_grant); +ioctl (fd,IOCTL_GNTDEV_UNMAP_GRANT_REF , &unmap_grant); errno = saved_errno;return NULL ; }
@@ -546,10 +548,12 @@ mmap_again:return addr; } -static void *do_gnttab_map_grant_refs (xc_gnttab *xch,uint32_t count, +static void *do_gnttab_map_grant_refs (xc_gnttab *xch,xc_osdep_handle h, +uint32_t count,uint32_t *domids,int domids_stride,uint32_t *refs,int prot) { +int fd = (int )h;struct ioctl_gntdev_map_grant_ref *map;void *addr =NULL ;int i;
@@ -567,12 +571,12 @@ static void *do_gnttab_map_grant_refs(xc map->count = count; -if (ioctl (xch->fd,IOCTL_GNTDEV_MAP_GRANT_REF , map) ) { +if (ioctl (fd,IOCTL_GNTDEV_MAP_GRANT_REF , map) ) {PERROR ("xc_gnttab_map_grant_refs: ioctl MAP_GRANT_REF failed" ); goto out; } - addr =mmap (NULL ,PAGE_SIZE * count, prot,MAP_SHARED , xch->fd, + addr =mmap (NULL ,PAGE_SIZE * count, prot,MAP_SHARED , fd, map->index);if ( addr ==MAP_FAILED ) {
@@ -583,7 +587,7 @@ static void *do_gnttab_map_grant_refs(xcPERROR ("xc_gnttab_map_grant_refs: mmap failed" ); unmap_grant.index = map->index; unmap_grant.count = count; -ioctl (xch->fd,IOCTL_GNTDEV_UNMAP_GRANT_REF , &unmap_grant); +ioctl (fd,IOCTL_GNTDEV_UNMAP_GRANT_REF , &unmap_grant); errno = saved_errno; addr =NULL ; }
@@ -594,16 +598,18 @@ static void *do_gnttab_map_grant_refs(xcreturn addr; } -void *xc_gnttab_map_grant_refs (xc_gnttab *xcg,uint32_t count,uint32_t *domids, -uint32_t *refs,int prot) +static void *linux_gnttab_map_grant_refs (xc_gnttab *xcg,xc_osdep_handle h, +uint32_t count,uint32_t *domids, +uint32_t *refs,int prot) { -return do_gnttab_map_grant_refs (xcg, count, domids,1 , refs, prot); +return do_gnttab_map_grant_refs (xcg, h, count, domids,1 , refs, prot); } -void *xc_gnttab_map_domain_grant_refs (xc_gnttab *xcg,uint32_t count, -uint32_t domid,uint32_t *refs,int prot) +static void *linux_gnttab_map_domain_grant_refs (xc_gnttab *xcg,xc_osdep_handle h, +uint32_t count, +uint32_t domid,uint32_t *refs,int prot) { -return do_gnttab_map_grant_refs (xcg, count, &domid,0 , refs, prot); +return do_gnttab_map_grant_refs (xcg, h, count, &domid,0 , refs, prot); }int xc_gnttab_munmap (xc_gnttab *xcg,void *start_address,uint32_t count)
@@ -660,6 +666,12 @@ static struct xc_osdep_ops linux_gnttab_static struct xc_osdep_ops linux_gnttab_ops = { .open = &linux_gnttab_open, .close = &linux_gnttab_close, + + .u.gnttab = { + .map_grant_ref = &linux_gnttab_map_grant_ref, + .map_grant_refs = &linux_gnttab_map_grant_refs, + .map_domain_grant_refs = &linux_gnttab_map_domain_grant_refs, + }, };static struct xc_osdep_ops *linux_osdep_init (xc_interface *xch,enum xc_osdep_type type)
tools/libxc/xc_minios.c +26 -17
70 lines not on this page · raw message
tools/libxc/xenctrlosdep.h +16 -0
@@ -89,6 +89,22 @@ struct xc_osdep_opsevtchn_port_or_error_t (*pending)(xc_evtchn *xce,xc_osdep_handle h);int (*unmask)(xc_evtchn *xce,xc_osdep_handle h,evtchn_port_t port); } evtchn; +struct { +void *(*map_grant_ref)(xc_gnttab *xcg,xc_osdep_handle h, +uint32_t domid, +uint32_t ref, +int prot); +void *(*map_grant_refs)(xc_gnttab *xcg,xc_osdep_handle h, +uint32_t count, +uint32_t *domids, +uint32_t *refs, +int prot); +void *(*map_domain_grant_refs)(xc_gnttab *xcg,xc_osdep_handle h, +uint32_t count, +uint32_t domid, +uint32_t *refs, +int prot); + } gnttab; } u; };typedef struct xc_osdep_ops xc_osdep_ops ;
PATCH 1/1 libxc: osdep: convert xc_gnttab_munmap()
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID c5abbf2d6709770c039f2a01712986b1e37ec118 # Parent 68996338758eabdecbdfc5cfb4aa82ab7589b4e6
libxc: osdep: convert xc_gnttab_munmap()
tools/libxc/xc_gnttab.c +9 -0
@@ -174,6 +174,15 @@ void *xc_gnttab_map_domain_grant_refs(xc count, domid, refs, prot); } +int xc_gnttab_munmap (xc_gnttab *xcg, +void *start_address, +uint32_t count) +{ +return xcg->ops->u.gnttab.munmap (xcg, xcg->ops_handle, + start_address, count); +} + +/* * Local variables: * mode: C
tools/libxc/xc_linux.c +6 -3
@@ -612,8 +612,10 @@ static void *linux_gnttab_map_domain_grareturn do_gnttab_map_grant_refs (xcg, h, count, &domid,0 , refs, prot); } -int xc_gnttab_munmap (xc_gnttab *xcg,void *start_address,uint32_t count) +static int linux_gnttab_munmap (xc_gnttab *xcg,xc_osdep_handle h, +void *start_address,uint32_t count) { +int fd = (int )h;struct ioctl_gntdev_get_offset_for_vaddr get_offset;struct ioctl_gntdev_unmap_grant_ref unmap_grant;int rc;
@@ -628,7 +630,7 @@ int xc_gnttab_munmap(xc_gnttab *xcg, voi* mmap() the pages. */ get_offset.vaddr = (unsigned long )start_address; -if ( (rc =ioctl (xcg->fd,IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR , +if ( (rc =ioctl (fd,IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR , &get_offset)) )return rc;
@@ -645,7 +647,7 @@ int xc_gnttab_munmap(xc_gnttab *xcg, voi/* Finally, unmap the driver slots used to store the grant information. */ unmap_grant.index = get_offset.offset; unmap_grant.count = count; -if ( (rc =ioctl (xcg->fd,IOCTL_GNTDEV_UNMAP_GRANT_REF , &unmap_grant)) ) +if ( (rc =ioctl (fd,IOCTL_GNTDEV_UNMAP_GRANT_REF , &unmap_grant)) )return rc;return 0 ;
@@ -671,6 +673,7 @@ static struct xc_osdep_ops linux_gnttab_ .map_grant_ref = &linux_gnttab_map_grant_ref, .map_grant_refs = &linux_gnttab_map_grant_refs, .map_domain_grant_refs = &linux_gnttab_map_domain_grant_refs, + .munmap = &linux_gnttab_munmap, }, };
tools/libxc/xc_minios.c +6 -4
@@ -488,12 +488,13 @@ static void *minios_gnttab_map_domain_gr prot & PROT_WRITE); } -int xc_gnttab_munmap (xc_gnttab *xcg, -void *start_address, -uint32_t count) +static int minios_gnttab_munmap (xc_gnttab *xcg,xc_osdep_handle h, +void *start_address, +uint32_t count) { +int fd = (int )h;int ret; - ret =gntmap_munmap (&files[xcg->fd].gntmap, + ret =gntmap_munmap (&files[fd].gntmap, (unsigned long ) start_address, count);if (ret <0 ) {
@@ -524,6 +525,7 @@ static struct xc_osdep_ops minios_gnttab .map_grant_ref = &minios_gnttab_map_grant_ref, .map_grant_refs = &minios_gnttab_map_grant_refs, .map_domain_grant_refs = &minios_gnttab_map_domain_grant_refs, + .munmap = &minios_gnttab_munmap, }, };
tools/libxc/xenctrlosdep.h +3 -0
@@ -104,6 +104,9 @@ struct xc_osdep_opsuint32_t domid, uint32_t *refs, int prot); +int (*munmap)(xc_gnttab *xcg,xc_osdep_handle h, +void *start_address, +uint32_t count); } gnttab; } u; };
PATCH 1/1 libxc: osdep: convert xc_gnttab_set_max_grants()
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID 384d9d7ca3063a32623cb0d6ccdbc258e3541749 # Parent c5abbf2d6709770c039f2a01712986b1e37ec118
libxc: osdep: convert xc_gnttab_set_max_grants()
tools/libxc/xc_gnttab.c +4 -0
@@ -182,6 +182,10 @@ int xc_gnttab_munmap(xc_gnttab *xcg, start_address, count); } +int xc_gnttab_set_max_grants (xc_gnttab *xcg,uint32_t count) +{ +return xcg->ops->u.gnttab.set_max_grants (xcg, xcg->ops_handle, count); +}/* * Local variables:
tools/libxc/xc_linux.c +4 -2
@@ -653,13 +653,14 @@ static int linux_gnttab_munmap(xc_gnttabreturn 0 ; } -int xc_gnttab_set_max_grants (xc_gnttab *xcg,uint32_t count) +static int linux_gnttab_set_max_grants (xc_gnttab *xcg,xc_osdep_handle h,uint32_t count) { +int fd = (int )h;struct ioctl_gntdev_set_max_grants set_max;int rc; set_max.count = count; -if ( (rc =ioctl (xcg->fd,IOCTL_GNTDEV_SET_MAX_GRANTS , &set_max)) ) +if ( (rc =ioctl (fd,IOCTL_GNTDEV_SET_MAX_GRANTS , &set_max)) )return rc;return 0 ;
@@ -674,6 +675,7 @@ static struct xc_osdep_ops linux_gnttab_ .map_grant_refs = &linux_gnttab_map_grant_refs, .map_domain_grant_refs = &linux_gnttab_map_domain_grant_refs, .munmap = &linux_gnttab_munmap, + .set_max_grants = &linux_gnttab_set_max_grants, }, };
tools/libxc/xc_minios.c +4 -2
@@ -504,11 +504,12 @@ static int minios_gnttab_munmap(xc_gnttareturn ret; } -int xc_gnttab_set_max_grants (xc_gnttab *xcg, +static int minios_gnttab_set_max_grants (xc_gnttab *xcg,xc_osdep_handle h,uint32_t count) { +int fd = (int )h;int ret; - ret =gntmap_set_max_grants (&files[xcg->fd].gntmap, + ret =gntmap_set_max_grants (&files[fd].gntmap, count);if (ret <0 ) { errno = -ret;
@@ -526,6 +527,7 @@ static struct xc_osdep_ops minios_gnttab .map_grant_refs = &minios_gnttab_map_grant_refs, .map_domain_grant_refs = &minios_gnttab_map_domain_grant_refs, .munmap = &minios_gnttab_munmap, + .set_max_grants = &minios_gnttab_set_max_grants, }, };
tools/libxc/xenctrlosdep.h +1 -0
@@ -107,6 +107,7 @@ struct xc_osdep_opsint (*munmap)(xc_gnttab *xcg,xc_osdep_handle h,void *start_address,uint32_t count); +int (*set_max_grants)(xc_gnttab *xcg,xc_osdep_handle h,uint32_t count); } gnttab; } u; };
PATCH 1/1 libxc: add ability to query OS interface for "fakeness"
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID 2cca9651106419dc04b2dfebc51da4b3f9143482 # Parent 384d9d7ca3063a32623cb0d6ccdbc258e3541749
libxc: add ability to query OS interface for "fakeness"
i.e. not running on a real hypervisor
Allows users of the library to adjust behaviour. I don't especially like this violation of the abstraction but both oxenstored and xapi use this to avoid difficult to simulate operations when running on the simulator.
tools/libxc/xc_linux.c +1 -0
@@ -697,6 +697,7 @@ xc_osdep_info_t xc_osdep_info = {xc_osdep_info_t xc_osdep_info = { .name ="Linux Native OS interface" , .init = &linux_osdep_init, + .fake =0 , };/*
tools/libxc/xc_minios.c +1 -0
@@ -549,6 +549,7 @@ xc_osdep_info_t xc_osdep_info = {xc_osdep_info_t xc_osdep_info = { .name ="Minios Native OS interface" , .init = &minios_osdep_init, + .fake =0 , };/*
tools/libxc/xc_netbsd.c +1 -0
@@ -348,6 +348,7 @@ xc_osdep_info_t xc_osdep_info = {xc_osdep_info_t xc_osdep_info = { .name ="Netbsd Native OS interface" , .init = &netbsd_osdep_init, + .fake =0 , };/*
tools/libxc/xc_private.c +13 -0
@@ -120,6 +120,19 @@ static int xc_interface_close_common(xc_free (xch);return rc; +} + +int xc_interface_is_fake (void ) +{ +xc_osdep_info_t info; + +if (xc_osdep_get_info (NULL , &info) <0 ) +return -1 ; + +/* Have a copy of info so can release the interface now. */ +xc_osdep_put (&info); + +return info.fake; } xc_interface *xc_interface_open(xentoollog_logger *logger,
tools/libxc/xc_solaris.c +1 -0
@@ -321,6 +321,7 @@ xc_osdep_info_t xc_osdep_info = {xc_osdep_info_t xc_osdep_info = { .name ="Solaris Native OS interface" , .init = &solaris_osdep_init, + .fake =0 , };/*
tools/libxc/xenctrl.h +9 -0
@@ -158,6 +158,15 @@ enum xc_open_flags {* @return 0 on success, -1 otherwise. */ int xc_interface_close (xc_interface *xch); + +/** +* Query the active OS interface (i.e. that which would be returned by +* xc_interface_open) to find out if it is fake (i.e. backends onto +* something other than an actual Xen hypervisor). +* +* @return 0 is "real", >0 if fake, -1 on error. +*/ +int xc_interface_is_fake (void );/* * HYPERCALL SAFE MEMORY BUFFER
tools/libxc/xenctrlosdep.h +3 -0
@@ -122,6 +122,9 @@ struct xc_osdep_info/* Returns ops function. */ xc_osdep_init_fn init; + +/* True if this interface backs onto a fake Xen. */ +int fake; };typedef struct xc_osdep_info xc_osdep_info_t ;
PATCH 1/1 libxc: drop fd from xc_interface
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID 379a7ce920c996d3805f88e8ba719e9a543fbc35 # Parent 2cca9651106419dc04b2dfebc51da4b3f9143482
libxc: drop fd from xc_interface
Transition to xc_osdep_handle is now complete and nothing uses (or should be using) it.
tools/libxc/xc_linux.c +0 -4
@@ -57,8 +57,6 @@ static xc_osdep_handle linux_privcmd_opePERROR ("Could not set file handle flags" ); goto error; } - - xch->fd = fd;/* Remove after transition to full xc_osdep_ops. */ return (xc_osdep_handle )fd;
@@ -350,7 +348,6 @@ static xc_osdep_handle linux_evtchn_openif ( fd ==-1 )return XC_OSDEP_OPEN_ERROR ; - xce->fd = fd;/* Remove after transition to full xc_osdep_ops. */ return (xc_osdep_handle )fd; }
@@ -498,7 +495,6 @@ static xc_osdep_handle linux_gnttab_openif ( fd ==-1 )return XC_OSDEP_OPEN_ERROR ; - xcg->fd = fd;/* Remove after transition to full xc_osdep_ops. */ return (xc_osdep_handle )fd; }
tools/libxc/xc_minios.c +0 -3
@@ -56,7 +56,6 @@ static xc_osdep_handle minios_privcmd_opif ( fd ==-1 )return XC_OSDEP_OPEN_ERROR ; - xch->fd = fd;/* Remove after transition to full xc_osdep_ops. */ return (xc_osdep_handle )fd; }
@@ -207,7 +206,6 @@ static xc_osdep_handle minios_evtchn_ope files[fd].evtchn.ports[i].bound =0 ; }printf ("evtchn_open() -> %d\n" , fd); - xce->fd = fd;/* Remove after transition to full xc_osdep_ops. */ return (xc_osdep_handle )fd; }
@@ -431,7 +429,6 @@ static xc_osdep_handle minios_gnttab_opeif ( fd ==-1 )return XC_OSDEP_OPEN_ERROR ;gntmap_init (&files[fd].gntmap); - xcg->fd = fd;/* Remove after transition to full xc_osdep_ops. */ return (xc_osdep_handle )fd; }
tools/libxc/xc_netbsd.c +0 -3
@@ -50,8 +50,6 @@ static xc_osdep_handle netbsd_privcmd_opPERROR ("Could not set file handle flags" ); goto error; } - - xch->fd = fd;/* Remove after transition to full xc_osdep_ops. */ return (xc_osinteface_handle )fd;
@@ -200,7 +198,6 @@ static xc_osdep_handle netbsd_evtchn_opeif ( fd ==-1 )return XC_OSDEP_OPEN_ERROR ; - xce->fd = fd;/* Remove after transition to full xc_osdep_ops. */ return (xc_osdep_handle )fd; }
tools/libxc/xc_private.c +0 -1
@@ -59,7 +59,6 @@ static struct xc_interface_core *xc_inte xch->type = type; xch->flags = open_flags; - xch->fd =-1 ; xch->dombuild_logger_file =0 ;xc_clear_last_error (xch);
tools/libxc/xc_private.h +0 -1
@@ -68,7 +68,6 @@struct xc_interface_core {enum xc_osdep_type type; -int fd;int flags;xentoollog_logger *error_handler, *error_handler_tofree;xentoollog_logger *dombuild_logger, *dombuild_logger_tofree;
tools/libxc/xc_solaris.c +0 -2
@@ -52,7 +52,6 @@ static xc_osdep_handle solaris_privcmd_o goto error; } - xch->fd = fd;/* Remove after transition to full xc_osdep_ops. */ return (xc_osdep_handle )fd; error:
@@ -192,7 +191,6 @@ static xc_osdep_handle solaris_evtchn_opreturn XC_OSDEP_OPEN_ERROR ; } - xce->fd = fd;/* Remove after transition to full xc_osdep_ops. */ return (xc_osdep_handle )fd; }
PATCH 1/1 libxc: allow osdep backends to log via the xc infrastructure
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1291369007 0
# Node ID ba7854a6f15b606a5285a786597bbdb452c9d360 # Parent 379a7ce920c996d3805f88e8ba719e9a543fbc35
libxc: allow osdep backends to log via the xc infrastructure.
tools/libxc/xc_private.c +8 -0
@@ -268,6 +268,14 @@ void xc_report_error(xc_interface *xch,va_list args;va_start (args, fmt);xc_reportv (xch, xch->error_handler,XTL_ERROR , code, fmt, args); +va_end (args); +} + +void xc_osdep_log (xc_interface *xch,xentoollog_level level,int code,const char *fmt, ...) +{ +va_list args; +va_start (args, fmt); +xc_reportv (xch, xch->error_handler, level, code, fmt, args);va_end (args); }
tools/libxc/xenctrlosdep.h +3 -0
@@ -136,6 +136,9 @@ void *xc_map_foreign_bulk_compat(xc_inte uint32_t dom, int prot, const xen_pfn_t *arr, int *err, unsigned int num); +/* Report errors through xc_interface */ +void xc_osdep_log (xc_interface *xch,xentoollog_level level,int code,const char *fmt, ...); +#endif /*
PATCH 1/1 libxc: osdep: Use XC_PAGE_{SHIFT, MASK}
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID fd025a5043072ae2684f55e5c4ffdb86f6cda042 # Parent ba7854a6f15b606a5285a786597bbdb452c9d360
libxc: osdep: Use XC_PAGE_{SHIFT,MASK}.
Avoid dependency on xc_private.h
tools/libxc/xc_linux.c +12 -12
@@ -110,7 +110,7 @@ static void *linux_privcmd_map_foreign_bvoid *addr;int rc; - addr =mmap (NULL , num <<PAGE_SHIFT , prot,MAP_SHARED , fd,0 ); + addr =mmap (NULL , num <<XC_PAGE_SHIFT , prot,MAP_SHARED , fd,0 );if ( addr ==MAP_FAILED ) {PERROR ("xc_map_foreign_batch: mmap failed" );
@@ -132,7 +132,7 @@ static void *linux_privcmd_map_foreign_bif ( (arr[i] &XEN_DOMCTL_PFINFO_LTAB_MASK ) ==XEN_DOMCTL_PFINFO_PAGEDTAB ) { -unsigned long paged_addr = (unsigned long )addr + (i <<PAGE_SHIFT ); +unsigned long paged_addr = (unsigned long )addr + (i <<XC_PAGE_SHIFT ); rc =xc_map_foreign_batch_single (fd, dom, &arr[i], paged_addr);if ( rc <0 )
@@ -146,7 +146,7 @@ static void *linux_privcmd_map_foreign_b {int saved_errno = errno;PERROR ("xc_map_foreign_batch: ioctl failed" ); - (void )munmap (addr, num <<PAGE_SHIFT ); + (void )munmap (addr, num <<XC_PAGE_SHIFT ); errno = saved_errno;return NULL ; }
@@ -164,7 +164,7 @@ static void *linux_privcmd_map_foreign_bunsigned int i;int rc; - addr =mmap (NULL , (unsigned long )num <<PAGE_SHIFT , prot,MAP_SHARED , + addr =mmap (NULL , (unsigned long )num <<XC_PAGE_SHIFT , prot,MAP_SHARED , fd,0 );if ( addr ==MAP_FAILED ) {
@@ -189,7 +189,7 @@ static void *linux_privcmd_map_foreign_b ioctlx.num =1 ; ioctlx.dom = dom; - ioctlx.addr = (unsigned long )addr + ((unsigned long )i<<PAGE_SHIFT ); + ioctlx.addr = (unsigned long )addr + ((unsigned long )i<<XC_PAGE_SHIFT ); ioctlx.arr = arr + i; ioctlx.err = err + i; do {
@@ -239,7 +239,7 @@ static void *linux_privcmd_map_foreign_bcontinue ; } rc =xc_map_foreign_batch_single (fd, dom, pfn + i, - (unsigned long )addr + ((unsigned long )i<<PAGE_SHIFT )); + (unsigned long )addr + ((unsigned long )i<<XC_PAGE_SHIFT ));if ( rc <0 ) { rc = -errno;
@@ -273,7 +273,7 @@ static void *linux_privcmd_map_foreign_bint saved_errno = errno;PERROR ("xc_map_foreign_bulk: ioctl failed" ); - (void )munmap (addr, (unsigned long )num <<PAGE_SHIFT ); + (void )munmap (addr, (unsigned long )num <<XC_PAGE_SHIFT ); errno = saved_errno;return NULL ; }
@@ -290,7 +290,7 @@ static void *linux_privcmd_map_foreign_rint i;void *ret; - num = (size +PAGE_SIZE -1 ) >>PAGE_SHIFT ; + num = (size +XC_PAGE_SIZE -1 ) >>XC_PAGE_SHIFT ; arr =calloc (num,sizeof (xen_pfn_t));for ( i =0 ; i < num; i++ )
@@ -313,7 +313,7 @@ static void *linux_privcmd_map_foreign_rint j;void *ret; - num_per_entry = chunksize >>PAGE_SHIFT ; + num_per_entry = chunksize >>XC_PAGE_SHIFT ; num = num_per_entry * nentries; arr =calloc (num,sizeof (xen_pfn_t));
@@ -474,7 +474,7 @@ void discard_file_cache(xc_interface *xc {if ( (cur =lseek (fd,0 ,SEEK_CUR )) == (off_t)-1 ) cur =0 ; - cur &= ~(PAGE_SIZE -1 ); + cur &= ~(XC_PAGE_SIZE -1 ); }/* Discard from the buffer cache. */
@@ -521,7 +521,7 @@ static void *linux_gnttab_map_grant_ref( } mmap_again: - addr =mmap (NULL ,PAGE_SIZE , prot,MAP_SHARED , fd, map.index); + addr =mmap (NULL ,XC_PAGE_SIZE , prot,MAP_SHARED , fd, map.index);if ( addr ==MAP_FAILED ) {int saved_errno = errno;
@@ -572,7 +572,7 @@ static void *do_gnttab_map_grant_refs(xc goto out; } - addr =mmap (NULL ,PAGE_SIZE * count, prot,MAP_SHARED , fd, + addr =mmap (NULL ,XC_PAGE_SIZE * count, prot,MAP_SHARED , fd, map->index);if ( addr ==MAP_FAILED ) {
tools/libxc/xc_minios.c +2 -2
@@ -169,11 +169,11 @@ static void *minios_privcmd_map_foreign_ pt_prot =L1_PROT ;#endif - mfns =malloc ((size /PAGE_SIZE ) *sizeof (*mfns)); + mfns =malloc ((size /XC_PAGE_SIZE ) *sizeof (*mfns)); n =0 ;for (i =0 ; i < nentries; i++) -for (j =0 ; j < chunksize /PAGE_SIZE ; j++) +for (j =0 ; j < chunksize /XC_PAGE_SIZE ; j++) mfns[n++] = entries[i].mfn + j; ret =map_frames_ex (mfns, n,1 ,0 ,1 , dom,NULL , pt_prot);
tools/libxc/xc_netbsd.c +4 -4
@@ -84,7 +84,7 @@ static void *netbsd_privcmd_map_foreign_int fd = (int )h;privcmd_mmapbatch_t ioctlx;void *addr; - addr =mmap (NULL , num*PAGE_SIZE , prot,MAP_ANON |MAP_SHARED ,-1 ,0 ); + addr =mmap (NULL , num*XC_PAGE_SIZE , prot,MAP_ANON |MAP_SHARED ,-1 ,0 );if ( addr ==MAP_FAILED ) {PERROR ("xc_map_foreign_batch: mmap failed" );return NULL ;
@@ -98,7 +98,7 @@ static void *netbsd_privcmd_map_foreign_ {int saved_errno = errno;PERROR ("xc_map_foreign_batch: ioctl failed" ); - (void )munmap (addr, num*PAGE_SIZE ); + (void )munmap (addr, num*XC_PAGE_SIZE ); errno = saved_errno;return NULL ; }
@@ -126,7 +126,7 @@ static void *netbsd_privcmd_map_foreign_ ioctlx.entry=&entry; entry.va=(unsigned long ) addr; entry.mfn=mfn; - entry.npages=(size+PAGE_SIZE -1 )>>PAGE_SHIFT ; + entry.npages=(size+XC_PAGE_SIZE -1 )>>XC_PAGE_SHIFT ;if (ioctl (fd,IOCTL_PRIVCMD_MMAP , &ioctlx) <0 ) {int saved_errno = errno;
@@ -154,7 +154,7 @@ static void *netbsd_privcmd_map_foreign_for (i =0 ; i < nentries; i++) { entries[i].va = (uintptr_t )addr + (i * chunksize); - entries[i].npages = chunksize >>PAGE_SHIFT ; + entries[i].npages = chunksize >>XC_PAGE_SHIFT ; } ioctlx.num = nentries;
tools/libxc/xc_private.h +2 -2
@@ -53,8 +53,8 @@#undef PAGE_SIZE#undef PAGE_MASK#define PAGE_SHIFT XC_PAGE_SHIFT -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE-1)) +#define PAGE_SIZE XC_PAGE_SIZE +#define PAGE_MASK XC_PAGE_MASK/* Force a compilation error if condition is true */ #define XC_BUILD_BUG_ON (p) ((void)sizeof(struct { int:-!!(p); }))
tools/libxc/xc_solaris.c +4 -4
@@ -80,7 +80,7 @@ static void *solaris_privcmd_map_foreignint fd = (int )h;privcmd_mmapbatch_t ioctlx;void *addr; - addr =mmap (NULL , num*PAGE_SIZE , prot,MAP_SHARED , fd,0 ); + addr =mmap (NULL , num*XC_PAGE_SIZE , prot,MAP_SHARED , fd,0 );if ( addr ==MAP_FAILED )return NULL ;
@@ -92,7 +92,7 @@ static void *solaris_privcmd_map_foreign {int saved_errno = errno;PERROR ("XXXXXXXX" ); - (void )munmap (addr, num*PAGE_SIZE ); + (void )munmap (addr, num*XC_PAGE_SIZE ); errno = saved_errno;return NULL ; }
@@ -118,7 +118,7 @@ static void *xc_map_foreign_range(xc_int ioctlx.entry=&entry; entry.va=(unsigned long ) addr; entry.mfn=mfn; - entry.npages=(size+PAGE_SIZE -1 )>>PAGE_SHIFT ; + entry.npages=(size+XC_PAGE_SIZE -1 )>>XC_PAGE_SHIFT ;if (ioctl (fd,IOCTL_PRIVCMD_MMAP , &ioctlx) <0 ) {int saved_errno = errno;
@@ -145,7 +145,7 @@ static void *solaric_privcmd_map_foreignfor (i =0 ; i < nentries; i++) { entries[i].va = (uintptr_t )addr + (i * chunksize); - entries[i].npages = chunksize >>PAGE_SHIFT ; + entries[i].npages = chunksize >>XC_PAGE_SHIFT ; } ioctlx.num = nentries;
PATCH 1/1 libxc: add abitility to dynamically load osdep
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]> # Date 1291369007 0
# Node ID a4d3be2e38ea883d3d2404078adc94960692d022 # Parent fd025a5043072ae2684f55e5c4ffdb86f6cda042
libxc: add abitility to dynamically load osdep.
Add a dummy backend which always returns ENOSYS. Mainly as a compile time testbed rather than because it is a useful backend.
tools/libxc/Makefile +8 -1
@@ -92,6 +92,10 @@ LIB += libxenguest.so libxenguest.so.$(M LIB += libxenguest.so libxenguest.so.$(MAJOR) libxenguest.so.$(MAJOR).$(MINOR) endif +ifneq ($(stubdom),y) +LIB += xenctrl_osdep_ENOSYS.so +endif + .PHONY: all all: build
@@ -148,7 +152,7 @@ libxenctrl.so.$(MAJOR): libxenctrl.so.$( ln -sf $< $@ libxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(PTHREAD_LIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) -ldl $(SHLIB_LDFLAGS) -o $@ $^ $(PTHREAD_LIBS) # libxenguest
@@ -186,5 +190,8 @@ libxenguest.so.$(MAJOR).$(MINOR): $(GUES libxenguest.so.$(MAJOR).$(MINOR): $(GUEST_PIC_OBJS) libxenctrl.so $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenguest.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(GUEST_PIC_OBJS) $(COMPRESSION_LIBS) -lz -lxenctrl $(PTHREAD_LIBS) +xenctrl_osdep_ENOSYS.so: xenctrl_osdep_ENOSYS.o libxenctrl.so + $(CC) -g $(CFLAGS) $(LDFLAGS) $(SHLIB_LDFLAGS) -o $@ xenctrl_osdep_ENOSYS.o -lxenctrl + -include $(DEPS)
tools/libxc/xc_private.c +62 -1
87 lines not on this page · raw message
tools/libxc/xenctrl_osdep_ENOSYS.c new file +206 -0
206 lines not on this page · raw message
tools/libxc/xenctrlosdep.h +15 -0
@@ -23,6 +23,18 @@* This interface defines the interactions between the Xen control * libraries and the OS facilities used to communicate with the * hypervisor. +* +* It is possible to override the default (native) implementation by +* setting the XENCTRL_OSDEP environment variable to point to a +* plugin library. Userspace can use this facility to intercept +* hypervisor operations. This can be used e.g. to implement a +* userspace simulator for Xen hypercalls. +* +* The plugin must contain a data structure: +* xc_osdep_info_t xc_osdep_info; +* +* xc_osdep_init: +* Must return a suitable struct xc_osdep_ops pointer or NULL on failure. */ #ifndef XC_OSDEP_H
@@ -125,6 +137,9 @@ struct xc_osdep_info/* True if this interface backs onto a fake Xen. */ int fake; + +/* For internal use by loader. */ +void *dl_handle; };typedef struct xc_osdep_info xc_osdep_info_t ;
PATCH 1/1 libxc: move foreign memory functions to xc_foreign_memory.c
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1291369007 0
# Node ID 4ffab774457dc03d8956113799076cb173522811 # Parent a4d3be2e38ea883d3d2404078adc94960692d022
libxc: move foreign memory functions to xc_foreign_memory.c
Now that this file exists it is a better home for these than xc_misc.c
tools/libxc/xc_foreign_memory.c +72 -0
@@ -19,6 +19,37 @@*/ #include "xc_private.h" + +void *xc_map_foreign_pages (xc_interface *xch,uint32_t dom,int prot, +const xen_pfn_t *arr,int num) +{ +void *res; +int i, *err; + +if (num <0 ) { + errno = -EINVAL ; +return NULL ; + } + + err =malloc (num *sizeof (*err)); +if (!err) +return NULL ; + + res =xc_map_foreign_bulk (xch, dom, prot, arr, err, num); +if (res) { +for (i =0 ; i < num; i++) { +if (err[i]) { + errno = -err[i]; +munmap (res, num *PAGE_SIZE ); + res =NULL ; +break ; + } + } + } + +free (err); +return res; +}void *xc_map_foreign_range (xc_interface *xch,uint32_t dom,int size,int prot,unsigned long mfn)
@@ -49,6 +80,47 @@ void *xc_map_foreign_bulk(xc_interface * dom, prot, arr, err, num); } +/* stub for all not yet converted OSes */ +void *xc_map_foreign_bulk_compat (xc_interface *xch,xc_osdep_handle h, +uint32_t dom,int prot, +const xen_pfn_t *arr,int *err,unsigned int num) +{ +xen_pfn_t *pfn; +unsigned int i; +void *ret; + +if ((int )num <=0 ) { + errno =EINVAL ; +return NULL ; + } + + pfn =malloc (num *sizeof (*pfn)); +if (!pfn) { + errno =ENOMEM ; +return NULL ; + } + +memcpy (pfn, arr, num *sizeof (*arr)); + ret =xc_map_foreign_batch (xch, dom, prot, pfn, num); + +if (ret) { +for (i =0 ; i < num; ++i) +switch (pfn[i] ^ arr[i]) { +case 0 : + err[i] =0 ; +break ; +default : + err[i] = -EINVAL ; +break ; + } + }else +memset (err,0 , num *sizeof (*err)); + +free (pfn); + +return ret; +} +/* * Local variables: * mode: C
tools/libxc/xc_misc.c +0 -72
78 lines not on this page · raw message
PATCH 1/1 libxc: refactor Linux OS interface into a separate file
In reply to Ian Campbell# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1291369007 0
# Node ID 96554e113aa1b7de6ba5296fcd438d63a6b7179a # Parent 4ffab774457dc03d8956113799076cb173522811
libxc: refactor Linux OS interface into a separate file.
This helps ensure that the osdep abstraction is complete by allowing us to avoid including xc_private.h.
All the other OS backends could benefit from the same treatment but since I cannot compile test I did not do this.
tools/libxc/Makefile +1 -1
@@ -34,7 +34,7 @@ CTRL_SRCS-y += xtl_core.c CTRL_SRCS-y += xtl_core.c CTRL_SRCS-y += xtl_logger_stdio.c CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c -CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c +CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c xc_linux_osdep.c CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c
tools/libxc/xc_linux.c +0 -641
659 lines not on this page · raw message
tools/libxc/xc_linux_osdep.c new file +685 -0
685 lines not on this page · raw message
PATCH 1/1 qemu-xen: update for libxc evtchn interface change.
In reply to Ian Campbell--- hw/xen_backend.c | 6 +++--- hw/xen_backend.h | 2 +- i386-dm/helper2.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-)
hw/xen_backend.c +3 -3
@@ -208,8 +208,8 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev, xendev->debug = debug; xendev->local_port =-1 ; - xendev->evtchndev =xc_evtchn_open (); -if (xendev->evtchndev <0 ) { + xendev->evtchndev =xc_evtchn_open (NULL ,0 ); +if (xendev->evtchndev ==NULL ) {xen_be_printf (NULL ,0 ,"can't open evtchn device\n" );qemu_free (xendev);return NULL ;
@@ -267,7 +267,7 @@ static struct XenDevice *xen_be_del_xendev(int dom, int dev)qemu_free (xendev->fe); } -if (xendev->evtchndev >=0 ) +if (xendev->evtchndev !=NULL )xc_evtchn_close (xendev->evtchndev);if (xendev->gnttabdev >=0 )xc_gnttab_close (xc_handle, xendev->gnttabdev);
hw/xen_backend.h +1 -1
@@ -44,7 +44,7 @@ struct XenDevice {int remote_port;int local_port; -int evtchndev; +xc_evtchn *evtchndev;int gnttabdev;struct XenDevOps *ops;
i386-dm/helper2.c +4 -4
@@ -104,7 +104,7 @@ buffered_iopage_t *buffered_io_page = NULL;QEMUTimer *buffered_io_timer;/* the evtchn fd for polling */ -int xce_handle =-1 ; +xc_interface *xce_handle =NULL ;/* which vcpu we are serving */ int send_vcpu =0 ;
@@ -138,8 +138,8 @@ CPUX86State *cpu_x86_init(const char *cpu_model) cpu_single_env = env; - xce_handle =xc_evtchn_open (); -if (xce_handle ==-1 ) { + xce_handle =xc_evtchn_open (NULL ,0 ); +if (xce_handle ==NULL ) {perror ("open" );return NULL ; }
@@ -553,7 +553,7 @@ int xen_pause_requested;int main_loop (void ) {CPUState *env = cpu_single_env; -int evtchn_fd = xce_handle ==-1 ?-1 :xc_evtchn_fd (xce_handle); +int evtchn_fd = xce_handle ==NULL ?-1 :xc_evtchn_fd (xce_handle);char *qemu_file;fd_set fds;
Signature · 1 line
1.5.6.5
PATCH 1/1 qemu-xen: update for libxc gnttab interface change.
In reply to Ian Campbell--- hw/xen_backend.c | 10 +++++----- hw/xen_backend.h | 2 +- hw/xen_console.c | 4 ++-- hw/xen_disk.c | 16 ++++++++-------- 4 files changed, 16 insertions(+), 16 deletions(-)
hw/xen_backend.c +5 -5
@@ -217,15 +217,15 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,fcntl (xc_evtchn_fd (xendev->evtchndev),F_SETFD ,FD_CLOEXEC );if (ops->flags &DEVOPS_FLAG_NEED_GNTDEV ) { - xendev->gnttabdev =xc_gnttab_open (xc_handle); -if (xendev->gnttabdev <0 ) { + xendev->gnttabdev =xc_gnttab_open (NULL ,0 ); +if (xendev->gnttabdev ==NULL ) {xen_be_printf (NULL ,0 ,"can't open gnttab device\n" );xc_evtchn_close (xendev->evtchndev);qemu_free (xendev);return NULL ; } }else { - xendev->gnttabdev =-1 ; + xendev->gnttabdev =NULL ; }TAILQ_INSERT_TAIL (&xendevs, xendev, next);
@@ -269,8 +269,8 @@ static struct XenDevice *xen_be_del_xendev(int dom, int dev)if (xendev->evtchndev !=NULL )xc_evtchn_close (xendev->evtchndev); -if (xendev->gnttabdev >=0 ) -xc_gnttab_close (xc_handle, xendev->gnttabdev); +if (xendev->gnttabdev !=NULL ) +xc_gnttab_close (xendev->gnttabdev);TAILQ_REMOVE (&xendevs, xendev, next);qemu_free (xendev);
hw/xen_backend.h +1 -1
@@ -45,7 +45,7 @@ struct XenDevice {int local_port;xc_evtchn *evtchndev; -int gnttabdev; +xc_gnttab *gnttabdev;struct XenDevOps *ops;TAILQ_ENTRY (XenDevice) next;
hw/xen_console.c +2 -2
@@ -230,7 +230,7 @@ static int con_initialise(struct XenDevice *xendev)PROT_READ |PROT_WRITE , con->ring_ref); else - con->sring = xc_gnttab_map_grant_ref(xen_xc, xendev->gnttabdev, con->xendev.dom, + con->sring = xc_gnttab_map_grant_ref(xendev->gnttabdev, con->xendev.dom, con->ring_ref,PROT_READ |PROT_WRITE );if (!con->sring)
@@ -261,7 +261,7 @@ static void con_disconnect(struct XenDevice *xendev)if (!xendev->gnttabdev)munmap (con->sring,XC_PAGE_SIZE );else -xc_gnttab_munmap (xen_xc, xendev->gnttabdev, con->sring,1 ); +xc_gnttab_munmap (xendev->gnttabdev, con->sring,1 ); con->sring =NULL ; } }
hw/xen_disk.c +8 -8
@@ -236,7 +236,7 @@ err:static void ioreq_unmap (struct ioreq *ioreq) { -int gnt = ioreq->blkdev->xendev.gnttabdev; +xc_gnttab *gnt = ioreq->blkdev->xendev.gnttabdev;int i;if (ioreq->v.niov ==0 )
@@ -244,7 +244,7 @@ static void ioreq_unmap(struct ioreq *ioreq)if (batch_maps) {if (!ioreq->pages)return ; -if (xc_gnttab_munmap (xen_xc, gnt, ioreq->pages, ioreq->v.niov) !=0 ) +if (xc_gnttab_munmap (gnt, ioreq->pages, ioreq->v.niov) !=0 )xen_be_printf (&ioreq->blkdev->xendev,0 ,"xc_gnttab_munmap failed: %s\n" ,strerror (errno)); ioreq->blkdev->cnt_map -= ioreq->v.niov;
@@ -253,7 +253,7 @@ static void ioreq_unmap(struct ioreq *ioreq)for (i =0 ; i < ioreq->v.niov; i++) {if (!ioreq->page[i])continue ; -if (xc_gnttab_munmap (xen_xc, gnt, ioreq->page[i],1 ) !=0 ) +if (xc_gnttab_munmap (gnt, ioreq->page[i],1 ) !=0 )xen_be_printf (&ioreq->blkdev->xendev,0 ,"xc_gnttab_munmap failed: %s\n" ,strerror (errno)); ioreq->blkdev->cnt_map--;
@@ -264,14 +264,14 @@ static void ioreq_unmap(struct ioreq *ioreq)static int ioreq_map (struct ioreq *ioreq) { -int gnt = ioreq->blkdev->xendev.gnttabdev; +xc_gnttab *gnt = ioreq->blkdev->xendev.gnttabdev;int i;if (ioreq->v.niov ==0 )return 0 ;if (batch_maps) { ioreq->pages =xc_gnttab_map_grant_refs - (xen_xc, gnt, ioreq->v.niov, ioreq->domids, ioreq->refs, ioreq->prot); + (gnt, ioreq->v.niov, ioreq->domids, ioreq->refs, ioreq->prot);if (ioreq->pages ==NULL ) { xen_be_printf(&ioreq->blkdev->xendev, 0, "can't map %d grant refs (%s, %d maps)\n",
@@ -285,7 +285,7 @@ static int ioreq_map(struct ioreq *ioreq) }else {for (i =0 ; i < ioreq->v.niov; i++) { ioreq->page[i] =xc_gnttab_map_grant_ref - (xen_xc, gnt, ioreq->domids[i], ioreq->refs[i], ioreq->prot); + (gnt, ioreq->domids[i], ioreq->refs[i], ioreq->prot);if (ioreq->page[i] ==NULL ) { xen_be_printf(&ioreq->blkdev->xendev, 0, "can't map grant ref %d (%s, %d maps)\n",
@@ -684,7 +684,7 @@ static int blk_connect(struct XenDevice *xendev) blkdev->protocol =BLKIF_PROTOCOL_X86_64 ; } - blkdev->sring =xc_gnttab_map_grant_ref (xen_xc, blkdev->xendev.gnttabdev, + blkdev->sring =xc_gnttab_map_grant_ref (blkdev->xendev.gnttabdev, blkdev->xendev.dom, blkdev->ring_ref,PROT_READ |PROT_WRITE );
@@ -737,7 +737,7 @@ static void blk_disconnect(struct XenDevice *xendev)xen_be_unbind_evtchn (&blkdev->xendev);if (blkdev->sring) { -xc_gnttab_munmap (xen_xc, blkdev->xendev.gnttabdev, blkdev->sring,1 ); +xc_gnttab_munmap (blkdev->xendev.gnttabdev, blkdev->sring,1 ); blkdev->cnt_map--; blkdev->sring =NULL ; }
Signature · 1 line
1.5.6.5
Re: [PATCH 01 of 25] libxc: some xc_gnttab_* functions are not Linux specific
In reply to Ian CampbellSuccessfully tested with NetBSD.
Quoted 378 lines · On Friday 03 December 2010 10:57:05 Ian Campbell wrote:
# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1291369006 0
# Node ID7c6e87f167d47b2c0b850806d0e9fa298018ebd4# Parent9a40ab7a4347e4c49785d079a598a1bc22477739
libxc: some xc_gnttab_* functions are not Linux specificThey simply make hypercalls and perform other operations via the abstract interface. Create
xc_gnttab.cand move those functions there.Signed-off-by Ian Campbell <[email protected]>diff -r
9a40ab7a4347-r7c6e87f167d4tools/libxc/Makefiletools/libxc/Makefile Fri Dec 03 09:36:46 2010 +0000 +1
-0@@ -11,6 +11,7 @@ CTRL_SRCS-y += xc_cpupool.c CTRL_SRCS-y += xc_cpupool.c CTRL_SRCS-y += xc_domain.c CTRL_SRCS-y += xc_evtchn.c +CTRL_SRCS-y += xc_gnttab.c CTRL_SRCS-y += xc_misc.c CTRL_SRCS-y += xc_acm.c CTRL_SRCS-y += xc_flask.cdiff -r
9a40ab7a4347-r7c6e87f167d4tools/libxc/xc_gnttab.ctools/libxc/xc_gnttab.c Fri Dec 03 09:36:46 2010 +0000 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +1
-0@@ -0,0 +1,147 @@ +/****************************************************************************** + *
+ * Copyright (c) 2007-2008, D G Murray <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */tools/libxc/xc_gnttab.c Fri Dec 03 09:36:46 2010 +0000 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +4
-0+ +#include "xc_private.h" + +int xc_gnttab_op(xc_interface *xch, int cmd, void * op, int op_size, intcount) +{
tools/libxc/xc_gnttab.c Fri Dec 03 09:36:46 2010 +0000 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +3
-0+ int ret = 0; + DECLARE_HYPERCALL; + DECLARE_HYPERCALL_BOUNCE(op, count * op_size,
XC_HYPERCALL_BUFFER_BOUNCE_BOTH); +tools/libxc/xc_gnttab.c Fri Dec 03 09:36:46 2010 +0000 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +57
-0+ if ( xc_hypercall_bounce_pre(xch, op) ) + { + PERROR("Could not bounce buffer for grant table op hypercall"); + goto out1; + } + + hypercall.op = __HYPERVISOR_grant_table_op; + hypercall.arg[0] = cmd; + hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(op); + hypercall.arg[2] = count; + + ret = do_xen_hypercall(xch, &hypercall); + + xc_hypercall_bounce_post(xch, op); + + out1: + return ret; +} + +int xc_gnttab_get_version(xc_interface *xch, int domid) +{ + struct gnttab_get_version query; + int rc; + + query.dom = domid; + rc = xc_gnttab_op(xch, GNTTABOP_get_version, &query, sizeof(query), + 1); + if ( rc < 0 ) + return rc; + else + return query.version; +} + +static void *_gnttab_map_table(xc_interface *xch, int domid, int *gnt_num) +{ + int rc, i; + struct gnttab_query_size query; + struct gnttab_setup_table setup; + DECLARE_HYPERCALL_BUFFER(unsigned long, frame_list); + xen_pfn_t *pfn_list = NULL; + grant_entry_v1_t *gnt = NULL; + + if ( !gnt_num ) + return NULL; + + query.dom = domid; + rc = xc_gnttab_op(xch, GNTTABOP_query_size, &query, sizeof(query), 1); + + if ( rc || (query.status != GNTST_okay) ) + { + ERROR("Could not query dom's grant size\n", domid); + return NULL; + } + + *gnt_num = query.nr_frames * (PAGE_SIZE / sizeof(grant_entry_v1_t) ); + + frame_list = xc_hypercall_buffer_alloc(xch, frame_list,query.nr_frames * sizeof(unsigned long)); + if ( !frame_list )
tools/libxc/xc_gnttab.c Fri Dec 03 09:36:46 2010 +0000 renamed from dev/null Thu Jan 01 00:00:00 1970 +0000 +62
-0+ { + ERROR("Could not allocate frame_list in xc_gnttab_map_table\n"); + return NULL; + } + + pfn_list = malloc(query.nr_frames * sizeof(xen_pfn_t)); + if ( !pfn_list ) + { + ERROR("Could not allocate pfn_list in xc_gnttab_map_table\n"); + goto err; + } + + setup.dom = domid; + setup.nr_frames = query.nr_frames; + set_xen_guest_handle(setup.frame_list, frame_list); + + /* XXX Any race with other setup_table hypercall? */ + rc = xc_gnttab_op(xch, GNTTABOP_setup_table, &setup, sizeof(setup), + 1); + + if ( rc || (setup.status != GNTST_okay) ) + { + ERROR("Could not get grant table frame list\n"); + goto err; + } + + for ( i = 0; i < setup.nr_frames; i++ ) + pfn_list[i] = frame_list[i]; + + gnt = xc_map_foreign_pages(xch, domid, PROT_READ, pfn_list, + setup.nr_frames); + if ( !gnt ) + { + ERROR("Could not map grant table\n"); + goto err; + } + +err: + if ( frame_list ) + xc_hypercall_buffer_free(xch, frame_list); + if ( pfn_list ) + free(pfn_list); + + return gnt; +} + +grant_entry_v1_t *xc_gnttab_map_table_v1(xc_interface *xch, int domid, + int *gnt_num) +{ + if (xc_gnttab_get_version(xch, domid) == 2) + return NULL; + return _gnttab_map_table(xch, domid, gnt_num); +} + +grant_entry_v2_t *xc_gnttab_map_table_v2(xc_interface *xch, int domid, + int *gnt_num) +{ + if (xc_gnttab_get_version(xch, domid) != 2) + return NULL; + return _gnttab_map_table(xch, domid, gnt_num); +} +diff -r
9a40ab7a4347-r7c6e87f167d4tools/libxc/xc_linux.ctools/libxc/xc_linux.c Fri Dec 03 09:36:46 2010 +0000 +0
-4@@ -608,132 +608,6 @@ int xc_gnttab_set_max_grants(xc_interfac return 0; } -int xc_gnttab_op(xc_interface *xch, int cmd, void * op, int op_size, int count) -{ - int ret = 0; - DECLARE_HYPERCALL; - DECLARE_HYPERCALL_BOUNCE(op, count * op_size,
XC_HYPERCALL_BUFFER_BOUNCE_BOTH); -tools/libxc/xc_linux.c Fri Dec 03 09:36:46 2010 +0000 +0
-57- if ( xc_hypercall_bounce_pre(xch, op) ) - { - PERROR("Could not bounce buffer for grant table op hypercall"); - goto out1; - } - - hypercall.op = __HYPERVISOR_grant_table_op; - hypercall.arg[0] = cmd; - hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(op); - hypercall.arg[2] = count; - - ret = do_xen_hypercall(xch, &hypercall); - - xc_hypercall_bounce_post(xch, op); - - out1: - return ret; -} - -int xc_gnttab_get_version(xc_interface *xch, int domid) -{ - struct gnttab_get_version query; - int rc; - - query.dom = domid; - rc = xc_gnttab_op(xch, GNTTABOP_get_version, &query, sizeof(query), - 1); - if ( rc < 0 ) - return rc; - else - return query.version; -} - -static void *_gnttab_map_table(xc_interface *xch, int domid, int *gnt_num) -{ - int rc, i; - struct gnttab_query_size query; - struct gnttab_setup_table setup; - DECLARE_HYPERCALL_BUFFER(unsigned long, frame_list); - xen_pfn_t *pfn_list = NULL; - grant_entry_v1_t *gnt = NULL; - - if ( !gnt_num ) - return NULL; - - query.dom = domid; - rc = xc_gnttab_op(xch, GNTTABOP_query_size, &query, sizeof(query), 1); - - if ( rc || (query.status != GNTST_okay) ) - { - ERROR("Could not query dom's grant size\n", domid); - return NULL; - } - - *gnt_num = query.nr_frames * (PAGE_SIZE / sizeof(grant_entry_v1_t) ); - - frame_list = xc_hypercall_buffer_alloc(xch, frame_list,query.nr_frames * sizeof(unsigned long)); - if ( !frame_list )
tools/libxc/xc_linux.c Fri Dec 03 09:36:46 2010 +0000 +0
-62- { - ERROR("Could not allocate frame_list in xc_gnttab_map_table\n"); - return NULL; - } - - pfn_list = malloc(query.nr_frames * sizeof(xen_pfn_t)); - if ( !pfn_list ) - { - ERROR("Could not allocate pfn_list in xc_gnttab_map_table\n"); - goto err; - } - - setup.dom = domid; - setup.nr_frames = query.nr_frames; - set_xen_guest_handle(setup.frame_list, frame_list); - - /* XXX Any race with other setup_table hypercall? */ - rc = xc_gnttab_op(xch, GNTTABOP_setup_table, &setup, sizeof(setup), - 1); - - if ( rc || (setup.status != GNTST_okay) ) - { - ERROR("Could not get grant table frame list\n"); - goto err; - } - - for ( i = 0; i < setup.nr_frames; i++ ) - pfn_list[i] = frame_list[i]; - - gnt = xc_map_foreign_pages(xch, domid, PROT_READ, pfn_list, - setup.nr_frames); - if ( !gnt ) - { - ERROR("Could not map grant table\n"); - goto err; - } - -err: - if ( frame_list ) - xc_hypercall_buffer_free(xch, frame_list); - if ( pfn_list ) - free(pfn_list); - - return gnt; -} - -grant_entry_v1_t *xc_gnttab_map_table_v1(xc_interface *xch, int domid, - int *gnt_num) -{ - if (xc_gnttab_get_version(xch, domid) == 2) - return NULL; - return _gnttab_map_table(xch, domid, gnt_num); -} - -grant_entry_v2_t *xc_gnttab_map_table_v2(xc_interface *xch, int domid, - int *gnt_num) -{ - if (xc_gnttab_get_version(xch, domid) != 2) - return NULL; - return _gnttab_map_table(xch, domid, gnt_num); -} - /* * Local variables: * mode: Cdiff -r
9a40ab7a4347-r7c6e87f167d4tools/libxc/xc_minios.ctools/libxc/xc_minios.c Fri Dec 03 09:36:46 2010 +0000 +0
-12@@ -457,18 +457,6 @@ int xc_gnttab_set_max_grants(xc_interfac return ret; } -grant_entry_v1_t *xc_gnttab_map_table_v1( - xc_interface *xch, int domid, int *gnt_num) -{ - return NULL; -} - -grant_entry_v2_t *xc_gnttab_map_table_v2( - xc_interface *xch, int domid, int *gnt_num) -{ - return NULL; -} - /* * Local variables: * mode: Cdiff -r
9a40ab7a4347-r7c6e87f167d4tools/libxc/xc_netbsd.ctools/libxc/xc_netbsd.c Fri Dec 03 09:36:46 2010 +0000 +0
-12@@ -287,18 +287,6 @@ void discard_file_cache(xc_interface *xc } } -grant_entry_v1_t *xc_gnttab_map_table_v1( - xc_interface *xch, int domid, int *gnt_num) -{ - return NULL; -} - -grant_entry_v2_t *xc_gnttab_map_table_v2( - xc_interface *xch, int domid, int *gnt_num) -{ - return NULL; -} - /* * Local variables: * mode: Cdiff -r
9a40ab7a4347-r7c6e87f167d4tools/libxc/xc_solaris.ctools/libxc/xc_solaris.c Fri Dec 03 09:36:46 2010 +0000 +0
-12@@ -261,15 +261,3 @@ void discard_file_cache(xc_interface *xc { // TODO: Implement for Solaris! } - -grant_entry_v1_t *xc_gnttab_map_table_v1( - xc_interface *xch, int domid, int *gnt_num) -{ - return NULL; -} - -grant_entry_v2_t *xc_gnttab_map_table_v2( - xc_interface *xch, int domid, int *gnt_num) -{ - return NULL; -}_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
Re: [PATCH 01 of 25] libxc: some xc_gnttab_* functions are not Linux specific
Thanks, I have applied the whole 27-patch series including the two qemu patches with appropriate QEMU_TAG changes.
Ian.