ia64/xen-unstable

changeset 2185:6c272033a2ed

bitkeeper revision 1.1159.1.36 (4119f27eonzahatd09ja80xf3ifOFw)

Documentation and some debug changes.
author mjw@wray-m-3.hpl.hp.com
date Wed Aug 11 10:18:38 2004 +0000 (2004-08-11)
parents c6a98003938a
children 0c7d6ab95324
files tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/blkif.py tools/python/xen/xend/server/controller.py tools/python/xen/xend/server/messages.py tools/python/xen/xend/server/netif.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Aug 10 15:53:15 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Aug 11 10:18:38 2004 +0000
     1.3 @@ -472,7 +472,10 @@ class XendDomainInfo:
     1.4          # When creating or rebooting, a domain with my name should not exist.
     1.5          # When restoring, a domain with my name will exist, but it should have
     1.6          # my domain id.
     1.7 -        if dominfo and (not self.dom or dominfo.dom != self.dom):
     1.8 +        if not dominfo:
     1.9 +            return
    1.10 +        print 'check_name>', 'dom=', dominfo.name, dominfo.dom, 'self=', name, self.dom
    1.11 +        if not self.dom or (dominfo.dom != self.dom):
    1.12              raise VmError('vm name clash: ' + name)
    1.13          
    1.14      def construct(self, config):
     2.1 --- a/tools/python/xen/xend/server/blkif.py	Tue Aug 10 15:53:15 2004 +0000
     2.2 +++ b/tools/python/xen/xend/server/blkif.py	Wed Aug 11 10:18:38 2004 +0000
     2.3 @@ -1,4 +1,6 @@
     2.4  # Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
     2.5 +"""Support for virtual block devices.
     2.6 +"""
     2.7  
     2.8  from twisted.internet import defer
     2.9  #defer.Deferred.debug = 1
     3.1 --- a/tools/python/xen/xend/server/controller.py	Tue Aug 10 15:53:15 2004 +0000
     3.2 +++ b/tools/python/xen/xend/server/controller.py	Wed Aug 11 10:18:38 2004 +0000
     3.3 @@ -247,7 +247,7 @@ class ControllerFactory(CtrlMsgRcvr):
     3.4      Maintains a table of instances.
     3.5  
     3.6      @ivar instances: mapping of index to controller instance
     3.7 -    @type instances: {int: Controller}
     3.8 +    @type instances: {String: Controller}
     3.9      @ivar dom: domain
    3.10      @type dom: int
    3.11      """
    3.12 @@ -274,6 +274,10 @@ class ControllerFactory(CtrlMsgRcvr):
    3.13  
    3.14      def getInstanceByDom(self, dom):
    3.15          """Get the controller instance for the given domain.
    3.16 +
    3.17 +        @param dom: domain id
    3.18 +        @type  dom: int
    3.19 +        @return: controller or None
    3.20          """
    3.21          for inst in self.instances.values():
    3.22              if inst.dom == dom:
    3.23 @@ -281,7 +285,9 @@ class ControllerFactory(CtrlMsgRcvr):
    3.24          return None
    3.25  
    3.26      def delInstance(self, instance):
    3.27 -        """Delete an instance from the table.
    3.28 +        """Delete a controller instance from the table.
    3.29 +
    3.30 +        @param instance: controller instance
    3.31          """
    3.32          if instance.idx in self.instances:
    3.33              del self.instances[instance.idx]
    3.34 @@ -293,16 +299,29 @@ class ControllerFactory(CtrlMsgRcvr):
    3.35          @type  dom: int
    3.36          @param recreate: true if the instance is being recreated (after xend restart)
    3.37          @type  recreate: int
    3.38 +        @return: controller instance
    3.39 +        @rtype:  Controller (or subclass)
    3.40          """
    3.41          raise NotImplementedError()
    3.42  
    3.43      def instanceClosed(self, instance):
    3.44          """Callback called when an instance is closed (usually by the instance).
    3.45 +        
    3.46 +        @param instance: controller instance
    3.47          """
    3.48          self.delInstance(instance)
    3.49  
    3.50  class Controller(CtrlMsgRcvr):
    3.51      """Abstract class for a device controller attached to a domain.
    3.52 +
    3.53 +    @ivar factory: controller factory
    3.54 +    @type factory: ControllerFactory
    3.55 +    @ivar dom:     domain
    3.56 +    @type dom:     int
    3.57 +    @ivar channel: channel to the domain
    3.58 +    @type channel: Channel
    3.59 +    @ivar idx:     channel index
    3.60 +    @type idx:     String
    3.61      """
    3.62  
    3.63      def __init__(self, factory, dom):
    3.64 @@ -325,6 +344,13 @@ class Controller(CtrlMsgRcvr):
    3.65  
    3.66  class Dev:
    3.67      """Abstract class for a device attached to a device controller.
    3.68 +
    3.69 +    @ivar idx:        identifier
    3.70 +    @type idx:        String
    3.71 +    @ivar controller: device controller
    3.72 +    @type controller: DeviceController
    3.73 +    @ivar props:      property table
    3.74 +    @type props:      { String: value }
    3.75      """
    3.76      
    3.77      def __init__(self, idx, controller):
    3.78 @@ -349,6 +375,11 @@ class Dev:
    3.79              del self.props[k]
    3.80  
    3.81      def sxpr(self):
    3.82 +        """Get the s-expression for the deivice.
    3.83 +        Implement in a subclass.
    3.84 +
    3.85 +        @return: sxpr
    3.86 +        """
    3.87          raise NotImplementedError()
    3.88  
    3.89      
     4.1 --- a/tools/python/xen/xend/server/messages.py	Tue Aug 10 15:53:15 2004 +0000
     4.2 +++ b/tools/python/xen/xend/server/messages.py	Wed Aug 11 10:18:38 2004 +0000
     4.3 @@ -213,9 +213,6 @@ def packMsg(ty, params):
     4.4                  args['mac[%d]' % i] = v[i]
     4.5          else:
     4.6              args[k] = v
     4.7 -    if DEBUG:
     4.8 -        for (k, v) in args.items():
     4.9 -            print 'packMsg>', k, v, type(v)
    4.10      msg = xu.message(major, minor, msgid, args)
    4.11      if DEBUG: print '<packMsg', msg.get_header()['id'], ty, params
    4.12      return msg
     5.1 --- a/tools/python/xen/xend/server/netif.py	Tue Aug 10 15:53:15 2004 +0000
     5.2 +++ b/tools/python/xen/xend/server/netif.py	Wed Aug 11 10:18:38 2004 +0000
     5.3 @@ -1,4 +1,6 @@
     5.4  # Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
     5.5 +"""Support for virtual network interfaces.
     5.6 +"""
     5.7  
     5.8  import random
     5.9  
    5.10 @@ -27,8 +29,6 @@ class NetifControllerFactory(controller.
    5.11          self.majorTypes = [ CMSG_NETIF_BE ]
    5.12  
    5.13          self.subTypes = {
    5.14 -            #CMSG_NETIF_BE_CREATE : self.recv_be_create,
    5.15 -            #CMSG_NETIF_BE_CONNECT: self.recv_be_connect,
    5.16              CMSG_NETIF_BE_DRIVER_STATUS_CHANGED: self.recv_be_driver_status_changed,
    5.17              }
    5.18          self.attached = 1
    5.19 @@ -37,10 +37,9 @@ class NetifControllerFactory(controller.
    5.20      def createInstance(self, dom, recreate=0):
    5.21          """Create or find the network interface controller for a domain.
    5.22  
    5.23 -        dom      domain
    5.24 -        recreate if true this is a recreate (xend restarted)
    5.25 -
    5.26 -        returns netif controller
    5.27 +        @param dom:      domain
    5.28 +        @param recreate: if true this is a recreate (xend restarted)
    5.29 +        @return: netif controller
    5.30          """
    5.31          netif = self.getInstanceByDom(dom)
    5.32          if netif is None:
    5.33 @@ -51,9 +50,8 @@ class NetifControllerFactory(controller.
    5.34      def getDomainDevices(self, dom):
    5.35          """Get the network device controllers for a domain.
    5.36  
    5.37 -        dom  domain
    5.38 -        
    5.39 -        returns netif controller
    5.40 +        @param dom:  domain
    5.41 +        @return: netif controller list
    5.42          """
    5.43          netif = self.getInstanceByDom(dom)
    5.44          return (netif and netif.getDevices()) or []
    5.45 @@ -61,10 +59,9 @@ class NetifControllerFactory(controller.
    5.46      def getDomainDevice(self, dom, vif):
    5.47          """Get a virtual network interface device for a domain.
    5.48  
    5.49 -        dom domain
    5.50 -        vif virtual interface index
    5.51 -
    5.52 -        returns NetDev
    5.53 +        @param dom: domain
    5.54 +        @param vif: virtual interface index
    5.55 +        @return: NetDev
    5.56          """
    5.57          netif = self.getInstanceByDom(dom)
    5.58          return (netif and netif.getDevice(vif)) or None
    5.59 @@ -72,8 +69,8 @@ class NetifControllerFactory(controller.
    5.60      def setControlDomain(self, dom, recreate=0):
    5.61          """Set the 'back-end' device driver domain.
    5.62  
    5.63 -        dom      domain
    5.64 -        recreate if true this is a recreate (xend restarted)
    5.65 +        @param dom:     domain
    5.66 +        @param recreate: if true this is a recreate (xend restarted)
    5.67          """
    5.68          if self.dom == dom: return
    5.69          self.deregisterChannel()
    5.70 @@ -84,6 +81,8 @@ class NetifControllerFactory(controller.
    5.71  
    5.72      def getControlDomain(self):
    5.73          """Get the domain id of the back-end control domain.
    5.74 +
    5.75 +        @return domain id
    5.76          """
    5.77          return self.dom
    5.78  
    5.79 @@ -95,7 +94,7 @@ class NetifControllerFactory(controller.
    5.80          if netif:
    5.81              netif.send_interface_connected(vif)
    5.82          else:
    5.83 -            log.warning("respond_be_connect> unknown dom=%d vif=%d", dom, vif)
    5.84 +            log.warning("respond_be_connect> unknown vif dom=%d vif=%d", dom, vif)
    5.85              pass
    5.86  
    5.87      def recv_be_driver_status_changed(self, msg, req):
    5.88 @@ -168,6 +167,8 @@ class NetDev(controller.Dev):
    5.89          return ':'.join(map(lambda x: "%02x" % x, self.mac))
    5.90  
    5.91      def vifctl_params(self, vmname=None):
    5.92 +        """Get the parameters to pass to vifctl.
    5.93 +        """
    5.94          dom = self.controller.dom
    5.95          if vmname is None:
    5.96              xd = get_component('xen.xend.XendDomain')
    5.97 @@ -185,6 +186,11 @@ class NetDev(controller.Dev):
    5.98  
    5.99      def vifctl(self, op, vmname=None):
   5.100          """Bring the device up or down.
   5.101 +        The vmname is needed when bringing a device up for a new domain because
   5.102 +        the domain is not yet in the table so we can't look its name up.
   5.103 +
   5.104 +        @param op: operation name (up, down)
   5.105 +        @param vmname: vmname
   5.106          """
   5.107          Vifctl.vifctl(op, **self.vifctl_params(vmname=vmname))
   5.108          vnet = XendVnet.instance().vnet_of_bridge(self.bridge)
   5.109 @@ -239,19 +245,17 @@ class NetifController(controller.Control
   5.110      def getDevice(self, vif):
   5.111          """Get a device.
   5.112  
   5.113 -        vif device index
   5.114 -
   5.115 -        returns device (or None)
   5.116 +        @param vif: device index
   5.117 +        @return: device (or None)
   5.118          """
   5.119          return self.devices.get(vif)
   5.120  
   5.121      def addDevice(self, vif, config):
   5.122          """Add a network interface.
   5.123  
   5.124 -        vif device index
   5.125 -        config device configuration 
   5.126 -
   5.127 -        returns device
   5.128 +        @param vif: device index
   5.129 +        @param config: device configuration 
   5.130 +        @return: device
   5.131          """
   5.132          dev = NetDev(self, vif, config)
   5.133          self.devices[vif] = dev
   5.134 @@ -263,15 +267,18 @@ class NetifController(controller.Control
   5.135          self.destroyDevices()
   5.136          
   5.137      def destroyDevices(self):
   5.138 +        """Destroy all devices.
   5.139 +        """
   5.140          for dev in self.getDevices():
   5.141              dev.destroy()
   5.142  
   5.143      def attachDevice(self, vif, config, recreate=0):
   5.144          """Attach a network device.
   5.145 -        If vmac is None a random mac address is assigned.
   5.146  
   5.147 -        @param vif interface index
   5.148 -        @param vmac mac address (string)
   5.149 +        @param vif: interface index
   5.150 +        @param config: device configuration
   5.151 +        @param recreate: recreate flag (true after xend restart)
   5.152 +        @return: deferred
   5.153          """
   5.154          self.addDevice(vif, config)
   5.155          d = defer.Deferred()