direct-io.hg

changeset 7237:76a7a7aa27e4

User tools send evtchn notifications via /dev/xen/evtchn
rather than using hypercall directly.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Oct 06 17:02:38 2005 +0100 (2005-10-06)
parents 4083eb31def0
children 62190db89326
files linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c linux-2.6-xen-sparse/include/asm-xen/linux-public/evtchn.h tools/console/daemon/io.c tools/ioemu/target-i386-dm/helper2.c tools/libxc/xc_evtchn.c tools/libxc/xenctrl.h tools/python/xen/lowlevel/xc/xc.c tools/xenstore/Makefile tools/xenstore/fake_libxc.c tools/xenstore/xenstored_core.c tools/xenstore/xenstored_core.h tools/xenstore/xenstored_domain.c tools/xenstore/xenstored_domain.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Thu Oct 06 16:07:52 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Thu Oct 06 17:02:38 2005 +0100
     1.3 @@ -297,6 +297,24 @@ static int evtchn_ioctl(struct inode *in
     1.4  		break;
     1.5  	}
     1.6  
     1.7 +	case IOCTL_EVTCHN_NOTIFY: {
     1.8 +		struct ioctl_evtchn_notify notify;
     1.9 +
    1.10 +		rc = -EFAULT;
    1.11 +		if (copy_from_user(&notify, (void *)arg, sizeof(notify)))
    1.12 +			break;
    1.13 +
    1.14 +		if (notify.port >= NR_EVENT_CHANNELS) {
    1.15 +			rc = -EINVAL;
    1.16 +		} else if (port_user[notify.port] != u) {
    1.17 +			rc = -ENOTCONN;
    1.18 +		} else {
    1.19 +			notify_remote_via_evtchn(notify.port);
    1.20 +			rc = 0;
    1.21 +		}
    1.22 +		break;
    1.23 +	}
    1.24 +
    1.25  	case IOCTL_EVTCHN_RESET: {
    1.26  		/* Initialise the ring to empty. Clear errors. */
    1.27  		u->ring_cons = u->ring_prod = u->ring_overflow = 0;
     2.1 --- a/linux-2.6-xen-sparse/include/asm-xen/linux-public/evtchn.h	Thu Oct 06 16:07:52 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/linux-public/evtchn.h	Thu Oct 06 17:02:38 2005 +0100
     2.3 @@ -72,9 +72,18 @@ struct ioctl_evtchn_unbind {
     2.4  	unsigned int port;
     2.5  };
     2.6  
     2.7 +/*
     2.8 + * Unbind previously allocated @port.
     2.9 + */
    2.10 +#define IOCTL_EVTCHN_NOTIFY				\
    2.11 +	_IOC(_IOC_NONE, 'E', 4, sizeof(struct ioctl_evtchn_notify))
    2.12 +struct ioctl_evtchn_notify {
    2.13 +	unsigned int port;
    2.14 +};
    2.15 +
    2.16  /* Clear and reinitialise the event buffer. Clear error condition. */
    2.17  #define IOCTL_EVTCHN_RESET				\
    2.18 -	_IOC(_IOC_NONE, 'E', 4, 0)
    2.19 +	_IOC(_IOC_NONE, 'E', 5, 0)
    2.20  
    2.21  #endif /* __LINUX_PUBLIC_EVTCHN_H__ */
    2.22  
     3.1 --- a/tools/console/daemon/io.c	Thu Oct 06 16:07:52 2005 +0100
     3.2 +++ b/tools/console/daemon/io.c	Thu Oct 06 17:02:38 2005 +0100
     3.3 @@ -81,6 +81,13 @@ struct ring_head
     3.4  #define XENCONS_FULL(ring) (((ring)->prod - (ring)->cons) == XENCONS_RING_SIZE)
     3.5  #define XENCONS_SPACE(ring) (XENCONS_RING_SIZE - ((ring)->prod - (ring)->cons))
     3.6  
     3.7 +static void evtchn_notify(struct domain *dom)
     3.8 +{
     3.9 +	struct ioctl_evtchn_notify notify;
    3.10 +	notify.port = dom->local_port;
    3.11 +	(void)ioctl(dom->evtchn_fd, IOCTL_EVTCHN_NOTIFY, &notify);
    3.12 +}
    3.13 +
    3.14  static void buffer_append(struct domain *dom)
    3.15  {
    3.16  	struct buffer *buffer = &dom->buffer;
    3.17 @@ -121,7 +128,7 @@ static void buffer_append(struct domain 
    3.18  	}
    3.19  
    3.20  	if (notify)
    3.21 -		xc_evtchn_send(xc, dom->local_port);
    3.22 +		evtchn_notify(dom);
    3.23  }
    3.24  
    3.25  static bool buffer_empty(struct buffer *buffer)
    3.26 @@ -440,7 +447,7 @@ static void handle_tty_read(struct domai
    3.27  			inring->buf[XENCONS_IDX(inring->prod)] = msg[i];
    3.28  			inring->prod++;
    3.29  		}
    3.30 -		xc_evtchn_send(xc, dom->local_port);
    3.31 +		evtchn_notify(dom);
    3.32  	} else {
    3.33  		close(dom->tty_fd);
    3.34  		dom->tty_fd = -1;
     4.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Thu Oct 06 16:07:52 2005 +0100
     4.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Thu Oct 06 17:02:38 2005 +0100
     4.3 @@ -486,11 +486,9 @@ int main_loop(void)
     4.4                      do_ioapic();
     4.5  #endif
     4.6  		if (env->send_event) {
     4.7 -			int ret;
     4.8 -			ret = xc_evtchn_send(xc_handle, ioreq_local_port);
     4.9 -			if (ret == -1) {
    4.10 -				fprintf(logfile, "evtchn_send failed on port: %d\n", ioreq_local_port);
    4.11 -			}
    4.12 +			struct ioctl_evtchn_notify notify;
    4.13 +			notify.port = ioreq_local_port;
    4.14 +			(void)ioctl(evtchn_fd, IOCTL_EVTCHN_NOTIFY, &notify);
    4.15  		}
    4.16  	}
    4.17          destroy_vmx_domain();
     5.1 --- a/tools/libxc/xc_evtchn.c	Thu Oct 06 16:07:52 2005 +0100
     5.2 +++ b/tools/libxc/xc_evtchn.c	Thu Oct 06 17:02:38 2005 +0100
     5.3 @@ -33,95 +33,22 @@ static int do_evtchn_op(int xc_handle, e
     5.4  
     5.5  
     5.6  int xc_evtchn_alloc_unbound(int xc_handle,
     5.7 -                            u32 remote_dom,
     5.8                              u32 dom,
     5.9 -                            int *port)
    5.10 +                            u32 remote_dom)
    5.11  {
    5.12      int         rc;
    5.13      evtchn_op_t op = {
    5.14          .cmd = EVTCHNOP_alloc_unbound,
    5.15 -        .u.alloc_unbound.remote_dom = (domid_t)remote_dom,
    5.16 -        .u.alloc_unbound.dom  = (domid_t)dom,
    5.17 -        .u.alloc_unbound.port = (port != NULL) ? *port : 0 };
    5.18 +        .u.alloc_unbound.dom = (domid_t)dom,
    5.19 +        .u.alloc_unbound.remote_dom = (domid_t)remote_dom };
    5.20  
    5.21      if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
    5.22 -    {
    5.23 -        if ( port != NULL )
    5.24 -            *port = op.u.alloc_unbound.port;
    5.25 -    }
    5.26 -    
    5.27 -    return rc;
    5.28 -}
    5.29 -
    5.30 -
    5.31 -int xc_evtchn_bind_interdomain(int xc_handle,
    5.32 -                               u32 dom1,
    5.33 -                               u32 dom2,
    5.34 -                               int *port1,
    5.35 -                               int *port2)
    5.36 -{
    5.37 -    int         rc;
    5.38 -    evtchn_op_t op = {
    5.39 -        .cmd = EVTCHNOP_bind_interdomain,
    5.40 -        .u.bind_interdomain.dom1  = (domid_t)dom1,
    5.41 -        .u.bind_interdomain.dom2  = (domid_t)dom2,
    5.42 -        .u.bind_interdomain.port1 = (port1 != NULL) ? *port1 : 0,
    5.43 -        .u.bind_interdomain.port2 = (port2 != NULL) ? *port2 : 0 };
    5.44 -
    5.45 -    if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
    5.46 -    {
    5.47 -        if ( port1 != NULL )
    5.48 -            *port1 = op.u.bind_interdomain.port1;
    5.49 -        if ( port2 != NULL )
    5.50 -            *port2 = op.u.bind_interdomain.port2;
    5.51 -    }
    5.52 +        rc = op.u.alloc_unbound.port;
    5.53      
    5.54      return rc;
    5.55  }
    5.56  
    5.57  
    5.58 -int xc_evtchn_bind_virq(int xc_handle,
    5.59 -                        int virq,
    5.60 -                        int *port)
    5.61 -{
    5.62 -    int         rc;
    5.63 -    evtchn_op_t op = {
    5.64 -        .cmd = EVTCHNOP_bind_virq,
    5.65 -        .u.bind_virq.virq = (u32)virq,
    5.66 -        .u.bind_virq.vcpu = 0 };
    5.67 -
    5.68 -    if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
    5.69 -    {
    5.70 -        if ( port != NULL )
    5.71 -            *port = op.u.bind_virq.port;
    5.72 -    }
    5.73 -    
    5.74 -    return rc;
    5.75 -}
    5.76 -
    5.77 -
    5.78 -int xc_evtchn_close(int xc_handle,
    5.79 -                    u32 dom,
    5.80 -                    int port)
    5.81 -{
    5.82 -    evtchn_op_t op = {
    5.83 -        .cmd          = EVTCHNOP_close,
    5.84 -        .u.close.dom  = (domid_t)dom,
    5.85 -        .u.close.port = port };
    5.86 -    return do_evtchn_op(xc_handle, &op);
    5.87 -}
    5.88 -
    5.89 -
    5.90 -int xc_evtchn_send(int xc_handle,
    5.91 -                   int local_port)
    5.92 -{
    5.93 -    evtchn_op_t op = {
    5.94 -        .cmd = EVTCHNOP_send,
    5.95 -        .u.send.local_port = local_port };
    5.96 -    return do_evtchn_op(xc_handle, &op);
    5.97 -}
    5.98 -
    5.99 -
   5.100  int xc_evtchn_status(int xc_handle,
   5.101                       u32 dom,
   5.102                       int port,
     6.1 --- a/tools/libxc/xenctrl.h	Thu Oct 06 16:07:52 2005 +0100
     6.2 +++ b/tools/libxc/xenctrl.h	Thu Oct 06 17:02:38 2005 +0100
     6.3 @@ -306,68 +306,14 @@ typedef evtchn_status_t xc_evtchn_status
     6.4   * well-known port within a domain to receive events on.
     6.5   *
     6.6   * @parm xc_handle a handle to an open hypervisor interface
     6.7 - * @parm remote_dom the ID of the domain who will later bind
     6.8   * @parm dom the ID of the local domain (the 'allocatee')
     6.9 - * @parm port a pointer to a port.  This is an in/out parameter.  If *port is
    6.10 - *            0, then a new port will be assigned, if port is > 0 then that
    6.11 - *            port is allocated if the port is unallocated.
    6.12 - * @return 0 on success, -1 on failure
    6.13 + * @parm remote_dom the ID of the domain who will later bind
    6.14 + * @return allocated port (in @dom) on success, -1 on failure
    6.15   */
    6.16  int xc_evtchn_alloc_unbound(int xc_handle,
    6.17 -                            u32 remote_dom,
    6.18                              u32 dom,
    6.19 -                            int *port);
    6.20 -
    6.21 -/**
    6.22 - * This function creates a pair of ports between two domains.  A port can only
    6.23 - * be bound once within a domain.
    6.24 - *
    6.25 - * @parm xc_handle a handle to an open hypervisor interface
    6.26 - * @parm dom1 one of the two domains to connect.  Can be DOMID_SELF.
    6.27 - * @parm dom2 the other domain to connect.  Can be DOMID_SELF.
    6.28 - * @parm port1 an in/out parameter.  If > 0, then try to connect *port.  If
    6.29 - *             0, then allocate a new port and store the port in *port.
    6.30 - * @parm port2 the port connected on port2.  This parameter behaves the same
    6.31 - *             way as port1.
    6.32 - * @return 0 on success, -1 on error.
    6.33 - */
    6.34 -int xc_evtchn_bind_interdomain(int xc_handle,
    6.35 -                               u32 dom1,
    6.36 -                               u32 dom2,
    6.37 -                               int *port1,
    6.38 -                               int *port2);
    6.39 -int xc_evtchn_bind_virq(int xc_handle,
    6.40 -                        int virq,
    6.41 -                        int *port);
    6.42 +                            u32 remote_dom);
    6.43  
    6.44 -/**
    6.45 - * This function will close a single port on an event channel.
    6.46 - *
    6.47 - * @parm xc_handle a handle to an open hypervisor interface
    6.48 - * @parm dom the domain that the port exists on.  May be DOMID_SELF.
    6.49 - * @parm port the port to close
    6.50 - * @return 0 on success, -1 on error
    6.51 - */
    6.52 -int xc_evtchn_close(int xc_handle,
    6.53 -                    u32 dom,   /* may be DOMID_SELF */
    6.54 -                    int port);
    6.55 -
    6.56 -/**
    6.57 - * This function generates a notify event on a bound port.
    6.58 - *
    6.59 - * Notifies can be read within Linux by opening /dev/xen/evtchn and reading
    6.60 - * a 16 bit value.  The result will be the port the event occurred on.  When
    6.61 - * events occur, the port is masked until the 16 bit port value is written back
    6.62 - * to the file.  When /dev/xen/evtchn is opened, it has to be bound via an
    6.63 - * ioctl to each port to listen on.  The ioctl for binding is _IO('E', 2).  The
    6.64 - * parameter is the port to listen on.
    6.65 - *
    6.66 - * @parm xc_handle a handle to an open hypervisor interface
    6.67 - * @parm local_port the port to generate the notify on
    6.68 - * @return 0 on success, -1 on error
    6.69 - */
    6.70 -int xc_evtchn_send(int xc_handle,
    6.71 -                   int local_port);
    6.72  int xc_evtchn_status(int xc_handle,
    6.73                       u32 dom, /* may be DOMID_SELF */
    6.74                       int port,
     7.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Thu Oct 06 16:07:52 2005 +0100
     7.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Thu Oct 06 17:02:38 2005 +0100
     7.3 @@ -433,7 +433,7 @@ static PyObject *pyxc_evtchn_alloc_unbou
     7.4      XcObject *xc = (XcObject *)self;
     7.5  
     7.6      u32 dom = DOMID_SELF, remote_dom;
     7.7 -    int port = 0;
     7.8 +    int port;
     7.9  
    7.10      static char *kwd_list[] = { "remote_dom", "dom", NULL };
    7.11  
    7.12 @@ -441,97 +441,12 @@ static PyObject *pyxc_evtchn_alloc_unbou
    7.13                                        &remote_dom, &dom) )
    7.14          return NULL;
    7.15  
    7.16 -    if ( xc_evtchn_alloc_unbound(xc->xc_handle, remote_dom, dom, &port) != 0 )
    7.17 +    if ( (port = xc_evtchn_alloc_unbound(xc->xc_handle, dom, remote_dom)) < 0 )
    7.18          return PyErr_SetFromErrno(xc_error);
    7.19  
    7.20      return PyInt_FromLong(port);
    7.21  }
    7.22  
    7.23 -static PyObject *pyxc_evtchn_bind_interdomain(PyObject *self,
    7.24 -                                              PyObject *args,
    7.25 -                                              PyObject *kwds)
    7.26 -{
    7.27 -    XcObject *xc = (XcObject *)self;
    7.28 -
    7.29 -    u32 dom1 = DOMID_SELF, dom2 = DOMID_SELF;
    7.30 -    int port1 = 0, port2 = 0;
    7.31 -
    7.32 -    static char *kwd_list[] = { "dom1", "dom2", "port1", "port2", NULL };
    7.33 -
    7.34 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iiii", kwd_list, 
    7.35 -                                      &dom1, &dom2, &port1, &port2) )
    7.36 -        return NULL;
    7.37 -
    7.38 -    if ( xc_evtchn_bind_interdomain(xc->xc_handle, dom1, 
    7.39 -                                    dom2, &port1, &port2) != 0 )
    7.40 -        return PyErr_SetFromErrno(xc_error);
    7.41 -
    7.42 -    return Py_BuildValue("{s:i,s:i}", 
    7.43 -                         "port1", port1,
    7.44 -                         "port2", port2);
    7.45 -}
    7.46 -
    7.47 -static PyObject *pyxc_evtchn_bind_virq(PyObject *self,
    7.48 -                                       PyObject *args,
    7.49 -                                       PyObject *kwds)
    7.50 -{
    7.51 -    XcObject *xc = (XcObject *)self;
    7.52 -
    7.53 -    int virq, port;
    7.54 -
    7.55 -    static char *kwd_list[] = { "virq", NULL };
    7.56 -
    7.57 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &virq) )
    7.58 -        return NULL;
    7.59 -
    7.60 -    if ( xc_evtchn_bind_virq(xc->xc_handle, virq, &port) != 0 )
    7.61 -        return PyErr_SetFromErrno(xc_error);
    7.62 -
    7.63 -    return PyInt_FromLong(port);
    7.64 -}
    7.65 -
    7.66 -static PyObject *pyxc_evtchn_close(PyObject *self,
    7.67 -                                   PyObject *args,
    7.68 -                                   PyObject *kwds)
    7.69 -{
    7.70 -    XcObject *xc = (XcObject *)self;
    7.71 -
    7.72 -    u32 dom = DOMID_SELF;
    7.73 -    int port;
    7.74 -
    7.75 -    static char *kwd_list[] = { "port", "dom", NULL };
    7.76 -
    7.77 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list, 
    7.78 -                                      &port, &dom) )
    7.79 -        return NULL;
    7.80 -
    7.81 -    if ( xc_evtchn_close(xc->xc_handle, dom, port) != 0 )
    7.82 -        return PyErr_SetFromErrno(xc_error);
    7.83 -
    7.84 -    Py_INCREF(zero);
    7.85 -    return zero;
    7.86 -}
    7.87 -
    7.88 -static PyObject *pyxc_evtchn_send(PyObject *self,
    7.89 -                                  PyObject *args,
    7.90 -                                  PyObject *kwds)
    7.91 -{
    7.92 -    XcObject *xc = (XcObject *)self;
    7.93 -
    7.94 -    int port;
    7.95 -
    7.96 -    static char *kwd_list[] = { "port", NULL };
    7.97 -
    7.98 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &port) )
    7.99 -        return NULL;
   7.100 -
   7.101 -    if ( xc_evtchn_send(xc->xc_handle, port) != 0 )
   7.102 -        return PyErr_SetFromErrno(xc_error);
   7.103 -
   7.104 -    Py_INCREF(zero);
   7.105 -    return zero;
   7.106 -}
   7.107 -
   7.108  static PyObject *pyxc_evtchn_status(PyObject *self,
   7.109                                      PyObject *args,
   7.110                                      PyObject *kwds)
   7.111 @@ -1032,38 +947,6 @@ static PyMethodDef pyxc_methods[] = {
   7.112        " dom [int]: Remote domain to accept connections from.\n\n"
   7.113        "Returns: [int] Unbound event-channel port.\n" },
   7.114  
   7.115 -    { "evtchn_bind_interdomain", 
   7.116 -      (PyCFunction)pyxc_evtchn_bind_interdomain, 
   7.117 -      METH_VARARGS | METH_KEYWORDS, "\n"
   7.118 -      "Open an event channel between two domains.\n"
   7.119 -      " dom1 [int, SELF]: First domain to be connected.\n"
   7.120 -      " dom2 [int, SELF]: Second domain to be connected.\n\n"
   7.121 -      "Returns: [dict] dictionary is empty on failure.\n"
   7.122 -      " port1 [int]: Port-id for endpoint at dom1.\n"
   7.123 -      " port2 [int]: Port-id for endpoint at dom2.\n" },
   7.124 -
   7.125 -    { "evtchn_bind_virq", 
   7.126 -      (PyCFunction)pyxc_evtchn_bind_virq, 
   7.127 -      METH_VARARGS | METH_KEYWORDS, "\n"
   7.128 -      "Bind an event channel to the specified VIRQ.\n"
   7.129 -      " virq [int]: VIRQ to bind.\n\n"
   7.130 -      "Returns: [int] Bound event-channel port.\n" },
   7.131 -
   7.132 -    { "evtchn_close", 
   7.133 -      (PyCFunction)pyxc_evtchn_close, 
   7.134 -      METH_VARARGS | METH_KEYWORDS, "\n"
   7.135 -      "Close an event channel. If interdomain, sets remote end to 'unbound'.\n"
   7.136 -      " dom  [int, SELF]: Dom-id of one endpoint of the channel.\n"
   7.137 -      " port [int]:       Port-id of one endpoint of the channel.\n\n"
   7.138 -      "Returns: [int] 0 on success; -1 on error.\n" },
   7.139 -
   7.140 -    { "evtchn_send", 
   7.141 -      (PyCFunction)pyxc_evtchn_send, 
   7.142 -      METH_VARARGS | METH_KEYWORDS, "\n"
   7.143 -      "Send an event along a locally-connected event channel.\n"
   7.144 -      " port [int]: Port-id of a local channel endpoint.\n\n"
   7.145 -      "Returns: [int] 0 on success; -1 on error.\n" },
   7.146 -
   7.147      { "evtchn_status", 
   7.148        (PyCFunction)pyxc_evtchn_status, 
   7.149        METH_VARARGS | METH_KEYWORDS, "\n"
     8.1 --- a/tools/xenstore/Makefile	Thu Oct 06 16:07:52 2005 +0100
     8.2 +++ b/tools/xenstore/Makefile	Thu Oct 06 17:02:38 2005 +0100
     8.3 @@ -29,7 +29,7 @@ CLIENTS_OBJS := $(patsubst xenstore-%,xe
     8.4  
     8.5  all: libxenstore.so xenstored $(CLIENTS) xs_tdb_dump
     8.6  
     8.7 -testcode: xs_test xenstored_test xs_random xs_dom0_test
     8.8 +testcode: xs_test xenstored_test xs_random
     8.9  
    8.10  xenstored: xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o
    8.11  	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxenctrl -o $@
    8.12 @@ -74,7 +74,7 @@ libxenstore.so: xs.opic xs_lib.opic
    8.13  clean: testsuite-clean
    8.14  	rm -f *.o *.opic *.so
    8.15  	rm -f xenstored xs_random xs_stress xs_crashme
    8.16 -	rm -f xs_test xenstored_test xs_dom0_test
    8.17 +	rm -f xs_test xenstored_test
    8.18  	$(RM) $(PROG_DEP)
    8.19  
    8.20  print-dir:
    8.21 @@ -120,9 +120,6 @@ stresstest: xs_stress xenstored_test $(T
    8.22  	rm -rf $(TESTDIR)/store $(TESTDIR)/transactions
    8.23  	export $(TESTENV); PID=`./xenstored_test --output-pid --trace-file=/tmp/trace`; ./xs_stress 5000; ret=$$?; kill $$PID; exit $$ret
    8.24  
    8.25 -xs_dom0_test: xs_dom0_test.o utils.o
    8.26 -	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxenctrl -o $@
    8.27 -
    8.28  TAGS:
    8.29  	etags `find . -name '*.[ch]'`
    8.30  
     9.1 --- a/tools/xenstore/fake_libxc.c	Thu Oct 06 16:07:52 2005 +0100
     9.2 +++ b/tools/xenstore/fake_libxc.c	Thu Oct 06 17:02:38 2005 +0100
     9.3 @@ -36,12 +36,11 @@ static int xs_test_pid;
     9.4  static u16 port;
     9.5  
     9.6  /* The event channel maps to a signal, shared page to an mmapped file. */
     9.7 -int xc_evtchn_send(int xc_handle __attribute__((unused)), int local_port)
     9.8 +void evtchn_notify(int local_port)
     9.9  {
    9.10  	assert(local_port == port);
    9.11  	if (kill(xs_test_pid, SIGUSR2) != 0)
    9.12  		barf_perror("fake event channel failed");
    9.13 -	return 0;
    9.14  }
    9.15  
    9.16  void *xc_map_foreign_range(int xc_handle, u32 dom __attribute__((unused)),
    9.17 @@ -107,15 +106,6 @@ int xc_domain_getinfo(int xc_handle __at
    9.18  	return 1;
    9.19  }
    9.20  
    9.21 -int xc_evtchn_bind_virq(int xc_handle __attribute__((unused)),
    9.22 -			int virq __attribute__((unused)),
    9.23 -			int *port)
    9.24 -{
    9.25 -	if (port)
    9.26 -		*port = 0;
    9.27 -	return 0;
    9.28 -}
    9.29 -
    9.30  static void send_to_fd(int signo __attribute__((unused)))
    9.31  {
    9.32  	int saved_errno = errno;
    10.1 --- a/tools/xenstore/xenstored_core.c	Thu Oct 06 16:07:52 2005 +0100
    10.2 +++ b/tools/xenstore/xenstored_core.c	Thu Oct 06 17:02:38 2005 +0100
    10.3 @@ -52,6 +52,8 @@
    10.4  #include "xenctrl.h"
    10.5  #include "tdb.h"
    10.6  
    10.7 +int event_fd;
    10.8 +
    10.9  static bool verbose;
   10.10  LIST_HEAD(connections);
   10.11  static int tracefd = -1;
   10.12 @@ -309,8 +311,7 @@ static int destroy_conn(void *_conn)
   10.13  	return 0;
   10.14  }
   10.15  
   10.16 -static int initialize_set(fd_set *inset, fd_set *outset, int sock, int ro_sock,
   10.17 -			  int event_fd)
   10.18 +static int initialize_set(fd_set *inset, fd_set *outset, int sock, int ro_sock)
   10.19  {
   10.20  	struct connection *i;
   10.21  	int max;
   10.22 @@ -1464,7 +1465,7 @@ static struct option options[] = {
   10.23  
   10.24  int main(int argc, char *argv[])
   10.25  {
   10.26 -	int opt, *sock, *ro_sock, event_fd, max;
   10.27 +	int opt, *sock, *ro_sock, max;
   10.28  	struct sockaddr_un addr;
   10.29  	fd_set inset, outset;
   10.30  	bool dofork = true;
   10.31 @@ -1568,7 +1569,7 @@ int main(int argc, char *argv[])
   10.32  #endif
   10.33  
   10.34  	/* Get ready to listen to the tools. */
   10.35 -	max = initialize_set(&inset, &outset, *sock, *ro_sock, event_fd);
   10.36 +	max = initialize_set(&inset, &outset, *sock, *ro_sock);
   10.37  
   10.38  	/* Main loop. */
   10.39  	/* FIXME: Rewrite so noone can starve. */
   10.40 @@ -1588,7 +1589,7 @@ int main(int argc, char *argv[])
   10.41  			accept_connection(*ro_sock, false);
   10.42  
   10.43  		if (FD_ISSET(event_fd, &inset))
   10.44 -			handle_event(event_fd);
   10.45 +			handle_event();
   10.46  
   10.47  		list_for_each_entry(i, &connections, list) {
   10.48  			if (i->domain)
   10.49 @@ -1624,7 +1625,6 @@ int main(int argc, char *argv[])
   10.50  			}
   10.51  		}
   10.52  
   10.53 -		max = initialize_set(&inset, &outset, *sock, *ro_sock,
   10.54 -				     event_fd);
   10.55 +		max = initialize_set(&inset, &outset, *sock, *ro_sock);
   10.56  	}
   10.57  }
    11.1 --- a/tools/xenstore/xenstored_core.h	Thu Oct 06 16:07:52 2005 +0100
    11.2 +++ b/tools/xenstore/xenstored_core.h	Thu Oct 06 17:02:38 2005 +0100
    11.3 @@ -173,4 +173,6 @@ void trace_destroy(const void *data, con
    11.4  void trace_watch_timeout(const struct connection *conn, const char *node, const char *token);
    11.5  void trace(const char *fmt, ...);
    11.6  
    11.7 +extern int event_fd;
    11.8 +
    11.9  #endif /* _XENSTORED_CORE_H */
    12.1 --- a/tools/xenstore/xenstored_domain.c	Thu Oct 06 16:07:52 2005 +0100
    12.2 +++ b/tools/xenstore/xenstored_domain.c	Thu Oct 06 17:02:38 2005 +0100
    12.3 @@ -79,6 +79,17 @@ struct ringbuf_head
    12.4  	char buf[0];
    12.5  } __attribute__((packed));
    12.6  
    12.7 +#ifndef TESTING
    12.8 +static void evtchn_notify(int port)
    12.9 +{
   12.10 +	struct ioctl_evtchn_notify notify;
   12.11 +	notify.port = port;
   12.12 +	(void)ioctl(event_fd, IOCTL_EVTCHN_NOTIFY, &notify);
   12.13 +}
   12.14 +#else
   12.15 +extern void evtchn_notify(int port);
   12.16 +#endif
   12.17 +
   12.18  /* FIXME: Mark connection as broken (close it?) when this happens. */
   12.19  static bool check_buffer(const struct ringbuf_head *h)
   12.20  {
   12.21 @@ -164,9 +175,7 @@ static int writechn(struct connection *c
   12.22  	memcpy(dest, data, len);
   12.23  	mb();
   12.24  	update_output_chunk(conn->domain->output, len);
   12.25 -	/* FIXME: Probably not neccessary. */
   12.26 -	mb();
   12.27 -	xc_evtchn_send(*xc_handle, conn->domain->port);
   12.28 +	evtchn_notify(conn->domain->port);
   12.29  	return len;
   12.30  }
   12.31  
   12.32 @@ -199,7 +208,7 @@ static int readchn(struct connection *co
   12.33  
   12.34  	/* If it was full, tell them we've taken some. */
   12.35  	if (was_full)
   12.36 -		xc_evtchn_send(*xc_handle, conn->domain->port);
   12.37 +		evtchn_notify(conn->domain->port);
   12.38  	return len;
   12.39  }
   12.40  
   12.41 @@ -249,7 +258,7 @@ static void domain_cleanup(void)
   12.42  }
   12.43  
   12.44  /* We scan all domains rather than use the information given here. */
   12.45 -void handle_event(int event_fd)
   12.46 +void handle_event(void)
   12.47  {
   12.48  	u16 port;
   12.49  
    13.1 --- a/tools/xenstore/xenstored_domain.h	Thu Oct 06 16:07:52 2005 +0100
    13.2 +++ b/tools/xenstore/xenstored_domain.h	Thu Oct 06 17:02:38 2005 +0100
    13.3 @@ -20,7 +20,7 @@
    13.4  #ifndef _XENSTORED_DOMAIN_H
    13.5  #define _XENSTORED_DOMAIN_H
    13.6  
    13.7 -void handle_event(int event_fd);
    13.8 +void handle_event(void);
    13.9  
   13.10  /* domid, mfn, eventchn, path */
   13.11  void do_introduce(struct connection *conn, struct buffered_data *in);
    14.1 --- a/tools/xenstore/xs_dom0_test.c	Thu Oct 06 16:07:52 2005 +0100
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,43 +0,0 @@
    14.4 -/* Test introduction of domain 0 */
    14.5 -#include <linux/ioctl.h>
    14.6 -#include <sys/ioctl.h>
    14.7 -#include "xs.h"
    14.8 -#include "utils.h"
    14.9 -#include <xenctrl.h>
   14.10 -#include <xen/linux/privcmd.h>
   14.11 -#include <stdio.h>
   14.12 -#include <unistd.h>
   14.13 -#include <sys/mman.h>
   14.14 -
   14.15 -int main()
   14.16 -{
   14.17 -	int h, local = 0, kernel = 0;
   14.18 -	long err;
   14.19 -	void *page;
   14.20 -
   14.21 -	h = xc_interface_open();
   14.22 -	if (h < 0)
   14.23 -		barf_perror("Failed to open xc");
   14.24 -
   14.25 -	if (xc_evtchn_bind_interdomain(h, DOMID_SELF, 0, &local, &kernel) != 0)
   14.26 -		barf_perror("Failed to bind interdomain");
   14.27 -
   14.28 -	printf("Got ports %i & %i\n", local, kernel);
   14.29 -
   14.30 -	err = ioctl(h, IOCTL_PRIVCMD_INITDOMAIN_STORE, kernel);
   14.31 -	if (err < 0)
   14.32 -		barf_perror("Failed to initialize store");
   14.33 -	printf("Got mfn %li\n", err);
   14.34 -
   14.35 -	page = xc_map_foreign_range(h, 0, getpagesize(), PROT_READ|PROT_WRITE,
   14.36 -				    err);
   14.37 -	if (!page)
   14.38 -		barf_perror("Failed to map page %li", err);
   14.39 -	printf("Mapped page at %p\n", page);
   14.40 -	printf("Page says %s\n", (char *)page);
   14.41 -	munmap(page, getpagesize());
   14.42 -	printf("unmapped\n");
   14.43 -	
   14.44 -	return 0;
   14.45 -}
   14.46 -