ia64/xen-unstable

changeset 1474:3cf2ba082a24

bitkeeper revision 1.959.1.1 (40cdc96bIe1WZJx-cKTSpa-TOaS14w)

Merge xenbk@gandalf:/var/bk/xeno-unstable.bk
into wray-m-3.hpl.hp.com:/home/mjw/repos-bk/xeno-unstable.bk
author mjw@wray-m-3.hpl.hp.com
date Mon Jun 14 15:51:07 2004 +0000 (2004-06-14)
parents 225b184bd62d 961d5215a403
children cda612df4651 459daba5f498
files BitKeeper/etc/ignore linux-2.4.26-xen-sparse/arch/xen/kernel/ctrl_if.c tools/examples/xm_dom_create.py tools/xend/lib/utils.c tools/xenmgr/lib/server/blkif.py tools/xenmgr/lib/server/channel.py tools/xenmgr/lib/server/messages.py tools/xenmgr/lib/server/netif.py
line diff
     1.1 --- a/BitKeeper/etc/ignore	Fri Jun 11 22:32:04 2004 +0000
     1.2 +++ b/BitKeeper/etc/ignore	Mon Jun 14 15:51:07 2004 +0000
     1.3 @@ -3,6 +3,7 @@
     1.4  *.pyc
     1.5  *.so
     1.6  *.so.*
     1.7 +*~
     1.8  BitKeeper/*/*
     1.9  PENDING/*
    1.10  TAGS
    1.11 @@ -18,6 +19,7 @@ tools/misc/miniterm/miniterm
    1.12  tools/misc/xen_cpuperf
    1.13  tools/misc/xen_log
    1.14  tools/misc/xen_read_console
    1.15 +tools/xend-2004-06-10_1309.tgz
    1.16  tools/xentrace/xentrace
    1.17  xen/drivers/pci/classlist.h
    1.18  xen/drivers/pci/devlist.h
     2.1 --- a/linux-2.4.26-xen-sparse/arch/xen/kernel/ctrl_if.c	Fri Jun 11 22:32:04 2004 +0000
     2.2 +++ b/linux-2.4.26-xen-sparse/arch/xen/kernel/ctrl_if.c	Mon Jun 14 15:51:07 2004 +0000
     2.3 @@ -330,6 +330,19 @@ void ctrl_if_suspend(void)
     2.4      unbind_evtchn_from_irq(ctrl_if_evtchn);
     2.5  }
     2.6  
     2.7 +/** Reset the control interface progress pointers.
     2.8 + * Marks the queues empty if 'clear' non-zero.
     2.9 + */
    2.10 +void ctrl_if_reset(int clear){
    2.11 +    control_if_t *ctrl_if = get_ctrl_if();
    2.12 +
    2.13 +    if(clear){
    2.14 +        *ctrl_if = (control_if_t){};
    2.15 +    }
    2.16 +    ctrl_if_tx_resp_cons = ctrl_if->tx_resp_prod;
    2.17 +    ctrl_if_rx_req_cons  = ctrl_if->rx_resp_prod;
    2.18 +}
    2.19 +
    2.20  void ctrl_if_resume(void)
    2.21  {
    2.22      if ( start_info.flags & SIF_INITDOMAIN )
    2.23 @@ -349,8 +362,7 @@ void ctrl_if_resume(void)
    2.24          initdom_ctrlif_domcontroller_port   = op.u.bind_interdomain.port2;
    2.25      }
    2.26  
    2.27 -    ctrl_if_tx_resp_cons = 0;
    2.28 -    ctrl_if_rx_req_cons  = 0;
    2.29 +    ctrl_if_reset(0);
    2.30  
    2.31      ctrl_if_evtchn = start_info.domain_controller_evtchn;
    2.32      ctrl_if_irq    = bind_evtchn_to_irq(ctrl_if_evtchn);
    2.33 @@ -365,7 +377,7 @@ void ctrl_if_resume(void)
    2.34  
    2.35  void __init ctrl_if_init(void)
    2.36  {
    2.37 -    int i;
    2.38 +        int i;
    2.39  
    2.40      for ( i = 0; i < 256; i++ )
    2.41          ctrl_if_rxmsg_handler[i] = ctrl_if_rxmsg_default_handler;
    2.42 @@ -373,6 +385,7 @@ void __init ctrl_if_init(void)
    2.43  
    2.44      spin_lock_init(&ctrl_if_lock);
    2.45  
    2.46 +    ctrl_if_reset(1);
    2.47      ctrl_if_resume();
    2.48  }
    2.49  
     3.1 --- a/tools/examples/xm_dom_create.py	Fri Jun 11 22:32:04 2004 +0000
     3.2 +++ b/tools/examples/xm_dom_create.py	Mon Jun 14 15:51:07 2004 +0000
     3.3 @@ -253,6 +253,9 @@ def make_domain_config():
     3.4                        ['func', func] ]
     3.5          config_devs.append(['device', config_pci])
     3.6  
     3.7 +    # Add one vif with unspecified MAC.
     3.8 +    config_devs.append(['device', ['vif']])
     3.9 +
    3.10      config += config_devs
    3.11      
    3.12      config_vfr = ['vfr']
     4.1 --- a/tools/xend/lib/utils.c	Fri Jun 11 22:32:04 2004 +0000
     4.2 +++ b/tools/xend/lib/utils.c	Mon Jun 14 15:51:07 2004 +0000
     4.3 @@ -670,7 +670,7 @@ static void unmap_control_interface(int 
     4.4      (void)munmap(vaddr, PAGE_SIZE);
     4.5  }
     4.6  
     4.7 -typedef struct {
     4.8 +typedef struct xu_port_object {
     4.9      PyObject_HEAD;
    4.10      int mem_fd;
    4.11      int xc_handle;
    4.12 @@ -683,6 +683,42 @@ typedef struct {
    4.13  
    4.14  static PyObject *port_error;
    4.15  
    4.16 +static int xup_connect(xu_port_object *xup, domid_t dom,
    4.17 +                       int local_port, int remote_port){
    4.18 +    // From our prespective rx = producer, tx = consumer.
    4.19 +    int err = 0;
    4.20 +    printf("%s> dom=%u %d:%d\n", __FUNCTION__, dom, local_port, remote_port);
    4.21 +
    4.22 +    // Consumer = tx.
    4.23 +    //xup->interface->tx_resp_prod = 0;
    4.24 +    //xup->interface->tx_req_prod = 0;
    4.25 +    xup->tx_resp_prod = xup->interface->tx_resp_prod;
    4.26 +    xup->tx_req_cons = xup->interface->tx_resp_prod;
    4.27 +    printf("%s> tx: %p %p : %p %p\n", __FUNCTION__,
    4.28 +           xup->interface->tx_resp_prod,
    4.29 +           xup->tx_resp_prod,
    4.30 +           xup->tx_req_cons,
    4.31 +           xup->interface->tx_req_prod);
    4.32 +
    4.33 +    // Producer = rx.
    4.34 +    //xup->interface->rx_req_prod  = 0;
    4.35 +    //xup->interface->rx_resp_prod = 0;
    4.36 +    xup->rx_req_prod  = xup->interface->rx_req_prod;
    4.37 +    xup->rx_resp_cons = xup->interface->rx_resp_prod;
    4.38 +    printf("%s> rx: %p %p : %p %p\n", __FUNCTION__,
    4.39 +           xup->rx_resp_cons,
    4.40 +           xup->interface->rx_resp_prod,
    4.41 +           xup->interface->rx_req_prod,
    4.42 +           xup->rx_req_prod);
    4.43 +
    4.44 +    xup->remote_dom   = dom;
    4.45 +    xup->local_port   = local_port;
    4.46 +    xup->remote_port  = remote_port;
    4.47 +
    4.48 +    printf("%s< err=%d\n", __FUNCTION__, err);
    4.49 +    return err;
    4.50 +}
    4.51 +
    4.52  static PyObject *xu_port_notify(PyObject *self, PyObject *args)
    4.53  {
    4.54      xu_port_object *xup = (xu_port_object *)self;
    4.55 @@ -988,19 +1024,7 @@ static PyObject *xu_port_new(PyObject *s
    4.56          goto fail4;
    4.57      }
    4.58  
    4.59 -    xup->interface->tx_resp_prod = 0;
    4.60 -    xup->interface->rx_req_prod  = 0;
    4.61 -    xup->interface->tx_req_prod = 0;
    4.62 -    xup->interface->rx_resp_prod = 0;
    4.63 -
    4.64 -    xup->tx_req_cons  = 0;
    4.65 -    xup->tx_resp_prod = 0;
    4.66 -    xup->rx_req_prod  = 0;
    4.67 -    xup->rx_resp_cons = 0;
    4.68 -    xup->remote_dom   = dom;
    4.69 -    xup->local_port   = port1;
    4.70 -    xup->remote_port  = port2;
    4.71 -
    4.72 +    xup_connect(xup, dom, port1, port2);
    4.73      return (PyObject *)xup;
    4.74  
    4.75      
     5.1 --- a/tools/xenmgr/lib/server/blkif.py	Fri Jun 11 22:32:04 2004 +0000
     5.2 +++ b/tools/xenmgr/lib/server/blkif.py	Mon Jun 14 15:51:07 2004 +0000
     5.3 @@ -4,12 +4,9 @@ from messages import *
     5.4  
     5.5  class BlkifControllerFactory(controller.ControllerFactory):
     5.6      """Factory for creating block device interface controllers.
     5.7 -    Also handles the 'back-end' channel to dom0.
     5.8 +    Also handles the 'back-end' channel to the device driver domain.
     5.9      """
    5.10  
    5.11 -    # todo: add support for setting dom controlling blkifs (don't assume 0).
    5.12 -    # todo: add support for 'recovery'.
    5.13 -
    5.14      def __init__(self):
    5.15          controller.ControllerFactory.__init__(self)
    5.16  
    5.17 @@ -98,7 +95,7 @@ class BlkifControllerFactory(controller.
    5.18              blkif.reattached()
    5.19  
    5.20      def recv_be_driver_status_changed(self, msg, req):
    5.21 -        val = unpackMsg('blkif_be_driver_status_changed_t'. msg)
    5.22 +        val = unpackMsg('blkif_be_driver_status_changed_t', msg)
    5.23          status = val['status']
    5.24          if status == BLKIF_DRIVER_STATUS_UP and not self.attached:
    5.25              for blkif in self.getInstances():
     6.1 --- a/tools/xenmgr/lib/server/channel.py	Fri Jun 11 22:32:04 2004 +0000
     6.2 +++ b/tools/xenmgr/lib/server/channel.py	Mon Jun 14 15:51:07 2004 +0000
     6.3 @@ -9,13 +9,17 @@ class ChannelFactory:
     6.4      """Factory for creating channels.
     6.5      Maintains a table of channels.
     6.6      """
     6.7 -    
     6.8 +
     6.9 +    """ Channels indexed by index. """
    6.10      channels = {}
    6.11  
    6.12      def __init__(self):
    6.13 +        """Constructor - do not use. Use the channelFactory function."""
    6.14          self.notifier = xend.utils.notifier()
    6.15      
    6.16      def addChannel(self, channel):
    6.17 +        """Add a channel.
    6.18 +        """
    6.19          idx = channel.idx
    6.20          self.channels[idx] = channel
    6.21          self.notifier.bind(idx)
    6.22 @@ -24,14 +28,20 @@ class ChannelFactory:
    6.23          #channel.notify()
    6.24  
    6.25      def getChannel(self, idx):
    6.26 +        """Get the channel with the given index (if any).
    6.27 +        """
    6.28          return self.channels.get(idx)
    6.29  
    6.30      def delChannel(self, idx):
    6.31 +        """Remove the channel with the given index (if any).
    6.32 +        """
    6.33          if idx in self.channels:
    6.34              del self.channels[idx]
    6.35              self.notifier.unbind(idx)
    6.36  
    6.37      def domChannel(self, dom):
    6.38 +        """Get the channel for the given domain.
    6.39 +        """
    6.40          for chan in self.channels.values():
    6.41              if chan.dom == dom:
    6.42                  return chan
    6.43 @@ -40,12 +50,19 @@ class ChannelFactory:
    6.44          return chan
    6.45  
    6.46      def channelClosed(self, channel):
    6.47 +        """The given channel has been closed - remove it.
    6.48 +        """
    6.49          self.delChannel(channel.idx)
    6.50  
    6.51      def createPort(self, dom):
    6.52 +        """Create a port for a channel to the given domain.
    6.53 +        """
    6.54          return xend.utils.port(dom)
    6.55  
    6.56  def channelFactory():
    6.57 +    """Singleton constructor for the channel factory.
    6.58 +    Use this instead of the class constructor.
    6.59 +    """
    6.60      global inst
    6.61      try:
    6.62          inst
    6.63 @@ -59,6 +76,8 @@ class Channel:
    6.64      """
    6.65  
    6.66      def __init__(self, factory, dom):
    6.67 +        """Create a channel to the given domain using the given factory.
    6.68 +        """
    6.69          self.factory = factory
    6.70          self.dom = dom
    6.71          self.port = self.factory.createPort(dom)
    6.72 @@ -69,15 +88,24 @@ class Channel:
    6.73          self.queue = []
    6.74  
    6.75      def getIndex(self):
    6.76 +        """Get the channel index.
    6.77 +        """
    6.78          return self.idx
    6.79  
    6.80      def getLocalPort(self):
    6.81 +        """Get the local port.
    6.82 +        """
    6.83          return self.port.local_port
    6.84  
    6.85      def getRemotePort(self):
    6.86 +        """Get the remote port.
    6.87 +        """
    6.88          return self.port.remote_port
    6.89  
    6.90      def close(self):
    6.91 +        """Close the channel. Calls lostChannel() on all its devices and
    6.92 +        channelClosed() on the factory.
    6.93 +        """
    6.94          for d in self.devs:
    6.95              d.lostChannel()
    6.96          self.factory.channelClosed(self)
    6.97 @@ -114,6 +142,8 @@ class Channel:
    6.98          return self.devs_by_type.get(type)
    6.99  
   6.100      def getMessageType(self, msg):
   6.101 +        """Get a 2-tuple of the message type and subtype.
   6.102 +        """
   6.103          hdr = msg.get_header()
   6.104          return (hdr['type'], hdr.get('subtype'))
   6.105  
   6.106 @@ -142,25 +172,19 @@ class Channel:
   6.107          #print 'notificationReceived<', work
   6.108  
   6.109      def notify(self):
   6.110 -        #print 'notify>', self
   6.111          self.port.notify()
   6.112  
   6.113      def handleRequests(self):
   6.114 -        #print 'handleRequests>'
   6.115          work = 0
   6.116          while 1:
   6.117 -            #print 'handleRequests>', work
   6.118              msg = self.readRequest()
   6.119 -            #print 'handleRequests> msg=', msg
   6.120              if not msg: break
   6.121              self.requestReceived(msg)
   6.122              work += 1
   6.123 -        #print 'handleRequests<', work
   6.124          return work
   6.125  
   6.126      def requestReceived(self, msg):
   6.127          (ty, subty) = self.getMessageType(msg)
   6.128 -        #print 'requestReceived>', ty, subty, self
   6.129          #todo:  Must respond before writing any more messages.
   6.130          #todo:  Should automate this (respond on write)
   6.131          self.port.write_response(msg)
   6.132 @@ -172,21 +196,16 @@ class Channel:
   6.133                     % (msgTypeName(ty, subty), ty, subty)), self
   6.134  
   6.135      def handleResponses(self):
   6.136 -        #print 'handleResponses>', self
   6.137          work = 0
   6.138          while 1:
   6.139 -            #print 'handleResponses>', work
   6.140              msg = self.readResponse()
   6.141 -            #print 'handleResponses> msg=', msg
   6.142              if not msg: break
   6.143              self.responseReceived(msg)
   6.144              work += 1
   6.145 -        #print 'handleResponses<', work
   6.146          return work
   6.147  
   6.148      def responseReceived(self, msg):
   6.149          (ty, subty) = self.getMessageType(msg)
   6.150 -        #print 'responseReceived>', ty, subty
   6.151          dev = self.getDevice(ty)
   6.152          if dev:
   6.153              dev.responseReceived(msg, ty, subty)
   6.154 @@ -195,23 +214,18 @@ class Channel:
   6.155                     % (msgTypeName(ty, subty), ty, subty)), self
   6.156  
   6.157      def handleWrites(self):
   6.158 -        #print 'handleWrites>', self
   6.159          work = 0
   6.160          # Pull data from producers.
   6.161 -        #print 'handleWrites> pull...'
   6.162          for dev in self.devs:
   6.163              work += dev.produceRequests()
   6.164          # Flush the queue.
   6.165 -        #print 'handleWrites> flush...'
   6.166          while self.queue and self.port.space_to_write_request():
   6.167              msg = self.queue.pop(0)
   6.168              self.port.write_request(msg)
   6.169              work += 1
   6.170 -        #print 'handleWrites<', work
   6.171          return work
   6.172  
   6.173      def writeRequest(self, msg, notify=1):
   6.174 -        #print 'writeRequest>', self
   6.175          if self.closed:
   6.176              val = -1
   6.177          elif self.writeReady():
   6.178 @@ -221,11 +235,9 @@ class Channel:
   6.179          else:
   6.180              self.queue.append(msg)
   6.181              val = 0
   6.182 -        #print 'writeRequest<', val
   6.183          return val
   6.184  
   6.185      def writeResponse(self, msg):
   6.186 -        #print 'writeResponse>', self
   6.187          if self.closed: return -1
   6.188          self.port.write_response(msg)
   6.189          return 1
   6.190 @@ -235,25 +247,19 @@ class Channel:
   6.191          return self.port.space_to_write_request()
   6.192  
   6.193      def readRequest(self):
   6.194 -        #print 'readRequest>', self
   6.195          if self.closed:
   6.196 -            #print 'readRequest> closed'
   6.197              return None
   6.198          if self.port.request_to_read():
   6.199              val = self.port.read_request()
   6.200          else:
   6.201              val = None
   6.202 -        #print 'readRequest< ', val
   6.203          return val
   6.204          
   6.205      def readResponse(self):
   6.206 -        #print 'readResponse>', self
   6.207          if self.closed:
   6.208 -            #print 'readResponse> closed'
   6.209              return None
   6.210          if self.port.response_to_read():
   6.211              val = self.port.read_response()
   6.212          else:
   6.213              val = None
   6.214 -        #print 'readResponse<', val
   6.215          return val
     7.1 --- a/tools/xenmgr/lib/server/messages.py	Fri Jun 11 22:32:04 2004 +0000
     7.2 +++ b/tools/xenmgr/lib/server/messages.py	Mon Jun 14 15:51:07 2004 +0000
     7.3 @@ -2,6 +2,8 @@ import struct
     7.4  
     7.5  import xend.utils
     7.6  
     7.7 +DEBUG = 0
     7.8 +
     7.9  """ All message formats.
    7.10  Added to incrementally for the various message types.
    7.11  See below.
    7.12 @@ -145,7 +147,7 @@ class Msg:
    7.13      pass
    7.14  
    7.15  def packMsg(ty, params):
    7.16 -    print '>packMsg', ty, params
    7.17 +    if DEBUG: print '>packMsg', ty, params
    7.18      (major, minor, packing) = msg_formats[ty]
    7.19      args = {}
    7.20      for (k, v) in params.items():
    7.21 @@ -154,8 +156,9 @@ def packMsg(ty, params):
    7.22                  args['mac[%d]' % i] = v[i]
    7.23          else:
    7.24              args[k] = v
    7.25 -    for (k, v) in args.items():
    7.26 -        print 'packMsg>', k, v, type(v)
    7.27 +    if DEBUG:
    7.28 +        for (k, v) in args.items():
    7.29 +            print 'packMsg>', k, v, type(v)
    7.30      msgid = 0
    7.31      msg = xend.utils.message(major, minor, msgid, args)
    7.32      return msg
    7.33 @@ -175,7 +178,7 @@ def unpackMsg(ty, msg):
    7.34          args['mac'] = mac
    7.35          for k in macs:
    7.36              del args[k]
    7.37 -    print '<unpackMsg', ty, args
    7.38 +    if DEBUG: print '<unpackMsg', ty, args
    7.39      return args
    7.40  
    7.41  def msgTypeName(ty, subty):
     8.1 --- a/tools/xenmgr/lib/server/netif.py	Fri Jun 11 22:32:04 2004 +0000
     8.2 +++ b/tools/xenmgr/lib/server/netif.py	Mon Jun 14 15:51:07 2004 +0000
     8.3 @@ -6,10 +6,8 @@ from messages import *
     8.4  
     8.5  class NetifControllerFactory(controller.ControllerFactory):
     8.6      """Factory for creating network interface controllers.
     8.7 -    Also handles the 'back-end' channel to dom0.
     8.8 +    Also handles the 'back-end' channel to the device driver domain.
     8.9      """
    8.10 -    # todo: add support for setting dom controlling blkifs (don't assume 0).
    8.11 -    # todo: add support for 'recovery'.
    8.12  
    8.13      def __init__(self):
    8.14          controller.ControllerFactory.__init__(self)
    8.15 @@ -25,6 +23,8 @@ class NetifControllerFactory(controller.
    8.16          self.registerChannel()
    8.17  
    8.18      def createInstance(self, dom):
    8.19 +        """Create or find the network interface controller for a domain.
    8.20 +        """
    8.21          #print 'netif>createInstance> dom=', dom
    8.22          netif = self.getInstanceByDom(dom)
    8.23          if netif is None:
    8.24 @@ -33,6 +33,8 @@ class NetifControllerFactory(controller.
    8.25          return netif
    8.26          
    8.27      def setControlDomain(self, dom):
    8.28 +        """Set the 'back-end' device driver domain.
    8.29 +        """
    8.30          self.deregisterChannel()
    8.31          self.attached = 0
    8.32          self.dom = dom
    8.33 @@ -129,6 +131,12 @@ class NetifController(controller.Control
    8.34          return mac
    8.35  
    8.36      def attach_device(self, vif, vmac):
    8.37 +        """Attach a network device.
    8.38 +        If vmac is None a random mac address is assigned.
    8.39 +
    8.40 +        @param vif interface index
    8.41 +        @param vmac mac address (string)
    8.42 +        """
    8.43          if vmac is None:
    8.44              mac = self.randomMAC()
    8.45          else: