ia64/xen-unstable

changeset 1580:e27e8d79cc6a

bitkeeper revision 1.1010.1.6 (40dbffabQ7DNCZQhMx5yK0HaV4MMWQ)

Handle domain exit virq and destroy blkif, netif.
author mjw@wray-m-3.hpl.hp.com
date Fri Jun 25 10:34:19 2004 +0000 (2004-06-25)
parents 4cf3ae77b2fe
children f804ea4d2b51 fdcfd59a93e8
files tools/xenmgr/lib/XendDomain.py tools/xenmgr/lib/server/SrvConsoleServer.py tools/xenmgr/lib/server/SrvDomain.py tools/xenmgr/lib/server/blkif.py tools/xenmgr/lib/server/controller.py tools/xenmgr/lib/server/netif.py
line diff
     1.1 --- a/tools/xenmgr/lib/XendDomain.py	Fri Jun 25 10:31:04 2004 +0000
     1.2 +++ b/tools/xenmgr/lib/XendDomain.py	Fri Jun 25 10:34:19 2004 +0000
     1.3 @@ -42,8 +42,13 @@ class XendDomain:
     1.4          if xroot.get_rebooted():
     1.5              print 'XendDomain> rebooted: removing all domain info'
     1.6              self.rm_all()
     1.7 +        eserver.subscribe('xend.virq', self.onVirq)
     1.8          self.initial_refresh()
     1.9  
    1.10 +    def onVirq(self, event, val):
    1.11 +        print 'XendDomain> virq', val
    1.12 +        self.reap()
    1.13 +
    1.14      def rm_all(self):
    1.15          """Remove all domain info. Used after reboot.
    1.16          """
    1.17 @@ -136,13 +141,33 @@ class XendDomain:
    1.18  
    1.19      def _delete_domain(self, id, notify=1):
    1.20          if id in self.domain:
    1.21 -            self.domain[id].died()
    1.22              if notify: eserver.inject('xend.domain.died', id)
    1.23              del self.domain[id]
    1.24          if id in self.domain_db:
    1.25              del self.domain_db[id]
    1.26              self.db.delete(id)
    1.27  
    1.28 +    def reap(self):
    1.29 +        print 'reap>'
    1.30 +        domlist = xc.domain_getinfo()
    1.31 +        casualties = []
    1.32 +        for d in domlist:
    1.33 +            print 'dom', d
    1.34 +            dead = 0
    1.35 +            dead = dead or (d['crashed'] or d['shutdown'])
    1.36 +            dead = dead or (d['dying'] and
    1.37 +                            not(d['running'] or d['paused'] or d['blocked']))
    1.38 +            if dead:
    1.39 +                casualties.append(d)
    1.40 +        for d in casualties:
    1.41 +            id = str(d['dom'])
    1.42 +            print 'died> id=', id, d
    1.43 +            dominfo = self.domain.get(id)
    1.44 +            if not dominfo: continue
    1.45 +            dominfo.died()
    1.46 +            self.domain_destroy(id, refresh=0)
    1.47 +        print 'reap<'
    1.48 +
    1.49      def refresh(self):
    1.50          """Refresh domain list from Xen.
    1.51          """
    1.52 @@ -169,6 +194,7 @@ class XendDomain:
    1.53                  d.update(dominfo)
    1.54              else:
    1.55                  self._delete_domain(d.id)
    1.56 +        self.reap()
    1.57  
    1.58      def refresh_domain(self, id):
    1.59          dom = int(id)
    1.60 @@ -232,7 +258,7 @@ class XendDomain:
    1.61          self.refresh()
    1.62          return val
    1.63      
    1.64 -    def domain_destroy(self, id):
    1.65 +    def domain_destroy(self, id, refresh=1):
    1.66          """Terminate domain immediately.
    1.67          """
    1.68          dom = int(id)
    1.69 @@ -240,7 +266,7 @@ class XendDomain:
    1.70              return 0
    1.71          eserver.inject('xend.domain.destroy', id)
    1.72          val = xc.domain_destroy(dom=dom)
    1.73 -        self.refresh()
    1.74 +        if refresh: self.refresh()
    1.75          return val       
    1.76  
    1.77      def domain_migrate(self, id, dst):
     2.1 --- a/tools/xenmgr/lib/server/SrvConsoleServer.py	Fri Jun 25 10:31:04 2004 +0000
     2.2 +++ b/tools/xenmgr/lib/server/SrvConsoleServer.py	Fri Jun 25 10:34:19 2004 +0000
     2.3 @@ -415,6 +415,7 @@ class VirqClient:
     2.4  
     2.5      def virqReceived(self, virq):
     2.6          print 'VirqClient.virqReceived>', virq
     2.7 +        eserver.inject('xend.virq', virq)
     2.8  
     2.9      def lostChannel(self, channel):
    2.10          print 'VirqClient.lostChannel>', channel
     3.1 --- a/tools/xenmgr/lib/server/SrvDomain.py	Fri Jun 25 10:31:04 2004 +0000
     3.2 +++ b/tools/xenmgr/lib/server/SrvDomain.py	Fri Jun 25 10:34:19 2004 +0000
     3.3 @@ -40,14 +40,14 @@ class SrvDomain(SrvDir):
     3.4      def op_save(self, op, req):
     3.5          fn = FormFn(self.xd.domain_save,
     3.6                      [['dom', 'int'],
     3.7 -                     ['dst', 'str']])
     3.8 +                     ['file', 'str']])
     3.9          val = fn(req.args, {'dom': self.dom.id})
    3.10          return val
    3.11  
    3.12      def op_restore(self, op, req):
    3.13          fn = FormFn(self.xd.domain_restore,
    3.14                      [['dom', 'int'],
    3.15 -                     ['src', 'str']])
    3.16 +                     ['file', 'str']])
    3.17          val = fn(req.args, {'dom': self.dom.id})
    3.18          return val
    3.19          
     4.1 --- a/tools/xenmgr/lib/server/blkif.py	Fri Jun 25 10:31:04 2004 +0000
     4.2 +++ b/tools/xenmgr/lib/server/blkif.py	Fri Jun 25 10:34:19 2004 +0000
     4.3 @@ -1,5 +1,8 @@
     4.4  from twisted.internet import defer
     4.5  
     4.6 +from xenmgr import sxp
     4.7 +from xenmgr import PrettyPrint
     4.8 +
     4.9  import channel
    4.10  import controller
    4.11  from messages import *
    4.12 @@ -140,11 +143,12 @@ class BlkDev(controller.Dev):
    4.13          return 'w' not in self.mode
    4.14  
    4.15      def sxpr(self):
    4.16 -        print 'BlkDev>sxpr>', vars(self)
    4.17 -        val = ['blkif', ['vdev', self.vdev], ['mode', self.mode] ]
    4.18 +        val = ['blkdev', ['vdev', self.vdev], ['mode', self.mode] ]
    4.19          return val
    4.20  
    4.21      def destroy(self):
    4.22 +        print 'BlkDev>destroy>', self.vdev
    4.23 +        PrettyPrint.prettyprint(self.sxpr())
    4.24          self.controller.send_be_vbd_destroy(self.vdev)
    4.25          
    4.26  class BlkifController(controller.Controller):
    4.27 @@ -166,9 +170,18 @@ class BlkifController(controller.Control
    4.28                  self.recv_fe_interface_connect,
    4.29              }
    4.30          self.attached = 1
    4.31 +        self.evtchn = None
    4.32          self.registerChannel()
    4.33          #print 'BlkifController<', 'dom=', self.dom, 'idx=', self.idx
    4.34  
    4.35 +    def sxpr(self):
    4.36 +        val = ['blkif', ['dom', self.dom]]
    4.37 +        if self.evtchn:
    4.38 +            val.append(['evtchn',
    4.39 +                        self.evtchn['port1'],
    4.40 +                        self.evtchn['port2']])
    4.41 +        return val
    4.42 +
    4.43      def lostChannel(self):
    4.44          print 'BlkifController>lostChannel>', 'dom=', self.dom
    4.45          #self.destroyDevices()
    4.46 @@ -201,7 +214,9 @@ class BlkifController(controller.Control
    4.47          return d
    4.48  
    4.49      def destroy(self):
    4.50 +        print 'BlkifController>destroy> dom=', self.dom
    4.51          self.destroyDevices()
    4.52 +        self.send_be_destroy()
    4.53  
    4.54      def destroyDevices(self):
    4.55          for dev in self.getDevices():
    4.56 @@ -229,7 +244,8 @@ class BlkifController(controller.Control
    4.57          return self.attached
    4.58  
    4.59      def reattached(self):
    4.60 -        """All devices have been reattached after the back-end control domain has changed.
    4.61 +        """All devices have been reattached after the back-end control
    4.62 +        domain has changed.
    4.63          """
    4.64          msg = packMsg('blkif_fe_interface_status_changed_t',
    4.65                        { 'handle' : 0,
    4.66 @@ -246,6 +262,8 @@ class BlkifController(controller.Control
    4.67      def recv_fe_interface_connect(self, msg, req):
    4.68          val = unpackMsg('blkif_fe_interface_connect_t', msg)
    4.69          self.evtchn = channel.eventChannel(0, self.dom)
    4.70 +        print 'recv_fe_interface_connect>'
    4.71 +        PrettyPrint.prettyprint(self.sxpr())
    4.72          msg = packMsg('blkif_be_connect_t',
    4.73                        { 'domid'        : self.dom,
    4.74                          'blkif_handle' : val['handle'],
    4.75 @@ -272,6 +290,13 @@ class BlkifController(controller.Control
    4.76                          'blkif_handle' : 0 })
    4.77          self.factory.writeRequest(msg)
    4.78  
    4.79 +    def send_be_destroy(self):
    4.80 +        print '>BlkifController>send_be_destroy>', 'dom=', self.dom
    4.81 +        msg = packMsg('blkif_be_destroy_t',
    4.82 +                      { 'domid'        : self.dom,
    4.83 +                        'blkif_handle' : 0 })
    4.84 +        self.factory.writeRequest(msg)
    4.85 +
    4.86      def send_be_vbd_create(self, vdev):
    4.87          dev = self.devices[vdev]
    4.88          msg = packMsg('blkif_be_vbd_create_t',
    4.89 @@ -293,6 +318,8 @@ class BlkifController(controller.Control
    4.90          self.factory.writeRequest(msg)
    4.91  
    4.92      def send_be_vbd_destroy(self, vdev):
    4.93 +        print '>BlkifController>send_be_vbd_destroy>', 'dom=', self.dom, 'vdev=', vdev
    4.94 +        PrettyPrint.prettyprint(self.sxpr())
    4.95          dev = self.devices[vdev]
    4.96          msg = packMsg('blkif_be_vbd_destroy_t',
    4.97                        { 'domid'                : self.dom,
     5.1 --- a/tools/xenmgr/lib/server/controller.py	Fri Jun 25 10:31:04 2004 +0000
     5.2 +++ b/tools/xenmgr/lib/server/controller.py	Fri Jun 25 10:34:19 2004 +0000
     5.3 @@ -132,7 +132,7 @@ class Controller(CtrlMsgRcvr):
     5.4  
     5.5      def close(self):
     5.6          self.deregisterChannel()
     5.7 -        self.lostChannel(self)
     5.8 +        self.lostChannel()
     5.9  
    5.10      def lostChannel(self):
    5.11          self.factory.instanceClosed(self)
     6.1 --- a/tools/xenmgr/lib/server/netif.py	Fri Jun 25 10:31:04 2004 +0000
     6.2 +++ b/tools/xenmgr/lib/server/netif.py	Fri Jun 25 10:34:19 2004 +0000
     6.3 @@ -2,6 +2,8 @@ import random
     6.4  
     6.5  from twisted.internet import defer
     6.6  
     6.7 +from xenmgr import sxp
     6.8 +from xenmgr import PrettyPrint
     6.9  from xenmgr import XendBridge
    6.10  
    6.11  import channel
    6.12 @@ -117,9 +119,13 @@ class NetDev(controller.Dev):
    6.13      def sxpr(self):
    6.14          vif = str(self.vif)
    6.15          mac = ':'.join(map(lambda x: "%x" % x, self.mac))
    6.16 -        val = ['netif', ['vif', vif], ['mac', mac]]
    6.17 +        val = ['netdev', ['vif', vif], ['mac', mac]]
    6.18          if self.bridge:
    6.19 -            val += ['bridge', self.bridge]
    6.20 +            val.append(['bridge', self.bridge])
    6.21 +        if self.evtchn:
    6.22 +            val.append(['evtchn',
    6.23 +                        self.evtchn['port1'],
    6.24 +                        self.evtchn['port2']])
    6.25          return val
    6.26  
    6.27      def bridge_add(self, bridge):
    6.28 @@ -131,6 +137,8 @@ class NetDev(controller.Dev):
    6.29          self.bridge = None
    6.30  
    6.31      def destroy(self):
    6.32 +        print 'NetDev>destroy>', 'vif=', self.vif
    6.33 +        PrettyPrint.prettyprint(self.sxpr())
    6.34          self.bridge_rem()
    6.35          self.controller.send_be_destroy(self.vif)
    6.36          
    6.37 @@ -155,7 +163,10 @@ class NetifController(controller.Control
    6.38          self.registerChannel()
    6.39          #print 'NetifController<', 'dom=', self.dom, 'idx=', self.idx
    6.40  
    6.41 -
    6.42 +    def sxpr(self):
    6.43 +        val = ['netif', ['dom', self.dom]]
    6.44 +        return val
    6.45 +    
    6.46      def randomMAC(self):
    6.47          # VIFs get a random MAC address with a "special" vendor id.
    6.48          # 
    6.49 @@ -194,6 +205,7 @@ class NetifController(controller.Control
    6.50          return dev
    6.51  
    6.52      def destroy(self):
    6.53 +        print 'NetifController>destroy>', 'dom=', self.dom
    6.54          self.destroyDevices()
    6.55          
    6.56      def destroyDevices(self):
    6.57 @@ -270,7 +282,8 @@ class NetifController(controller.Control
    6.58          self.factory.writeRequest(msg)
    6.59  
    6.60      def send_be_destroy(self, vif):
    6.61 -        print 'send_be_destroy>', 'dom=', self.dom, 'vif=', vif
    6.62 +        print 'NetifController>send_be_destroy>', 'dom=', self.dom, 'vif=', vif
    6.63 +        PrettyPrint.prettyprint(self.sxpr())
    6.64          dev = self.devices[vif]
    6.65          del self.devices[vif]
    6.66          msg = packMsg('netif_be_destroy_t',