direct-io.hg

changeset 13333:bf605c314a91

[XEND] Fix broken block-configure.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Jan 11 16:36:46 2007 +0000 (2007-01-11)
parents 2c73e6e647f3
children 66eba8d1b83a
files tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/blkif.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Jan 11 15:50:28 2007 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Jan 11 16:36:46 2007 +0000
     1.3 @@ -496,7 +496,7 @@ class XendDomainInfo:
     1.4          self._waitForDevice(dev_type, devid)
     1.5          return self.getDeviceController(dev_type).sxpr(devid)
     1.6  
     1.7 -    def device_configure(self, dev_config, devid = None):
     1.8 +    def device_configure(self, dev_sxp, devid = None):
     1.9          """Configure an existing device.
    1.10          
    1.11          @param dev_config: device configuration
    1.12 @@ -506,19 +506,24 @@ class XendDomainInfo:
    1.13          @return: Returns True if successfully updated device
    1.14          @rtype: boolean
    1.15          """
    1.16 -        deviceClass = sxp.name(dev_config)
    1.17 -        
    1.18 -        # look up uuid of the device
    1.19 -        dev_control =  self.getDeviceController(deviceClass)
    1.20 -        dev_sxpr = dev_control.sxpr(devid)
    1.21 -        dev_uuid = sxp.child_value(dev_sxpr, 'uuid')
    1.22 -        if not dev_uuid:
    1.23 -            return False
    1.24  
    1.25 -        self.info.device_update(dev_uuid, dev_config)
    1.26 -        dev_config_dict = self.info['devices'].get(dev_uuid)
    1.27 -        if dev_config_dict:
    1.28 -            dev_control.reconfigureDevice(devid, dev_config_dict[1])
    1.29 +        # convert device sxp to a dict
    1.30 +        dev_class = sxp.name(dev_sxp)
    1.31 +        dev_config = {}
    1.32 +        for opt_val in dev_sxp[1:]:
    1.33 +            try:
    1.34 +                dev_config[opt_val[0]] = opt_val[1]
    1.35 +            except IndexError:
    1.36 +                pass
    1.37 +
    1.38 +        # use DevController.reconfigureDevice to change device config
    1.39 +        dev_control = self.getDeviceController(dev_class)
    1.40 +        dev_uuid = dev_control.reconfigureDevice(devid, dev_config)
    1.41 +
    1.42 +        # update XendConfig with new device info
    1.43 +        if dev_uuid:
    1.44 +            self.info.device_update(dev_uuid, dev_sxp)
    1.45 +            
    1.46          return True
    1.47  
    1.48      def waitForDevices(self):
     2.1 --- a/tools/python/xen/xend/server/blkif.py	Thu Jan 11 15:50:28 2007 +0000
     2.2 +++ b/tools/python/xen/xend/server/blkif.py	Thu Jan 11 16:36:46 2007 +0000
     2.3 @@ -101,6 +101,7 @@ class BlkifController(DevController):
     2.4              self.writeBackend(devid,
     2.5                                'type', new_back['type'],
     2.6                                'params', new_back['params'])
     2.7 +            return new_back.get('uuid')
     2.8          else:
     2.9              raise VmError('Refusing to reconfigure device %s:%d to %s' %
    2.10                            (self.deviceClass, devid, config))