ia64/xen-unstable

changeset 6279:a86fb4df3bdd

Add very rough xend support for xenbus block device setup.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Fri Aug 19 12:21:29 2005 +0000 (2005-08-19)
parents 73b23942d6f5
children bf1746842c46
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Aug 19 12:14:41 2005 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Aug 19 12:21:29 2005 +0000
     1.3 @@ -36,8 +36,10 @@ from xen.xend.server import controller
     1.4  from xen.xend.server import SrvDaemon; xend = SrvDaemon.instance()
     1.5  from xen.xend.server import messages
     1.6  from xen.xend.server.channel import EventChannel, channelFactory
     1.7 +from xen.util.blkif import blkdev_name_to_number, expand_dev_name
     1.8  
     1.9  from xen.xend import sxp
    1.10 +from xen.xend import Blkctl
    1.11  from xen.xend.PrettyPrint import prettyprintstring
    1.12  from xen.xend.XendBootloader import bootloader
    1.13  from xen.xend.XendLogging import log
    1.14 @@ -380,6 +382,39 @@ class XendDomainInfo:
    1.15          return ctrl
    1.16  
    1.17      def createDevice(self, type, devconfig, change=False):
    1.18 +        if type == 'vbd':
    1.19 +
    1.20 +            backdom = domain_exists(sxp.child_value(devconfig, 'backend', '0'))
    1.21 +
    1.22 +            devnum = blkdev_name_to_number(sxp.child_value(devconfig, 'dev'))
    1.23 +
    1.24 +            # create backend db
    1.25 +            backdb = backdom.db.addChild("/backend/%s/%s/%d" %
    1.26 +                                         (type, self.uuid, devnum))
    1.27 +
    1.28 +            # create frontend db
    1.29 +            db = self.db.addChild("/device/%s/%d" % (type, devnum))
    1.30 +            
    1.31 +            db['virtual-device'] = "%i" % devnum
    1.32 +            #db['backend'] = sxp.child_value(devconfig, 'backend', '0')
    1.33 +            db['backend'] = backdb.getPath()
    1.34 +            db['backend-id'] = "%i" % int(sxp.child_value(devconfig,
    1.35 +                                                          'backend', '0'))
    1.36 +
    1.37 +            backdb['frontend'] = db.getPath()
    1.38 +            (type, params) = string.split(sxp.child_value(devconfig, 'uname'), ':', 1)
    1.39 +            node = Blkctl.block('bind', type, params)
    1.40 +            backdb['frontend-id'] = "%i" % self.id
    1.41 +            backdb['physical-device'] = "%li" % blkdev_name_to_number(node)
    1.42 +            backdb.saveDB(save=True)
    1.43 +
    1.44 +            # Ok, super gross, this really doesn't belong in the frontend db...
    1.45 +            db['type'] = type
    1.46 +            db['node'] = node
    1.47 +            db['params'] = params
    1.48 +            db.saveDB(save=True)
    1.49 +            
    1.50 +            return
    1.51          ctrl = self.findDeviceController(type)
    1.52          return ctrl.createDevice(devconfig, recreate=self.recreate,
    1.53                                   change=change)
    1.54 @@ -671,6 +706,16 @@ class XendDomainInfo:
    1.55          for ctrl in self.getDeviceControllers():
    1.56              if ctrl.isDestroyed(): continue
    1.57              ctrl.destroyController(reboot=reboot)
    1.58 +        ddb = self.db.addChild("/device")
    1.59 +        for type in ddb.keys():
    1.60 +            if type == 'vbd':
    1.61 +                typedb = ddb.addChild(type)
    1.62 +                for dev in typedb.keys():
    1.63 +                    devdb = typedb.addChild(str(dev))
    1.64 +                    Blkctl.block('unbind', devdb['type'].getData(),
    1.65 +                                 devdb['node'].getData())
    1.66 +                    typedb[dev].delete()
    1.67 +                typedb.saveDB(save=True)
    1.68  
    1.69      def show(self):
    1.70          """Print virtual machine info.
    1.71 @@ -926,6 +971,7 @@ class XendDomainInfo:
    1.72          at creation time, for example when it uses NFS root.
    1.73  
    1.74          """
    1.75 +        return
    1.76          blkif = self.getDeviceController("vbd", error=False)
    1.77          if not blkif:
    1.78              blkif = self.createDeviceController("vbd")