ia64/xen-unstable

changeset 15853:0c14d0bf369e

Fix error message and wait time for xm block-detach command.

- Wait time
When xm requests a block device detach to xend, xm makes two
requests. At first, xm requests the block device detach by device
class 'vbd'. Next, xm requests the block device detaching by
device class 'tap'.
As a result, the wait time is 200 seconds because each of
the block device detaching requests causes time-out.
- Misleading error message
Because the last request is by device class 'tap' to xend,
the keyword "(tap)" is included in the error message.

This patch fixes the number of times of the block device detaching
request to one time. At first, xm makes inquiries about device
class of a detaching target device to xend. Then xm requires the
block device detaching by xend returned device class. The wait
time becomes 100 seconds because the block device detaching request
is one time. And the error message is also fixed.

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author kfraser@localhost.localdomain
date Fri Sep 07 11:30:18 2007 +0100 (2007-09-07)
parents 7dba4441bf92
children 9071521d4864
files tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/XMLRPCServer.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Sep 07 11:24:28 2007 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Sep 07 11:30:18 2007 +0100
     1.3 @@ -602,16 +602,16 @@ class XendDomainInfo:
     1.4                                      mac = x[1]
     1.5                                      break
     1.6                              break
     1.7 -                    dev_info = self.getDeviceInfo_vif(mac)
     1.8 +                    dev_info = self._getDeviceInfo_vif(mac)
     1.9                  else:
    1.10                      _, dev_info = sxprs[dev]
    1.11              else:  # 'vbd' or 'tap'
    1.12 -                dev_info = self.getDeviceInfo_vbd(dev)
    1.13 +                dev_info = self._getDeviceInfo_vbd(dev)
    1.14                  # To remove the UUID of the device from refs,
    1.15                  # deviceClass must be always 'vbd'.
    1.16                  deviceClass = 'vbd'
    1.17              if dev_info is None:
    1.18 -                return rc
    1.19 +                raise XendError("Device %s is not defined" % devid)
    1.20  
    1.21              dev_uuid = sxp.child_value(dev_info, 'uuid')
    1.22              del self.info['devices'][dev_uuid]
    1.23 @@ -632,14 +632,22 @@ class XendDomainInfo:
    1.24                      dev_num += 1
    1.25              return sxprs
    1.26  
    1.27 -    def getDeviceInfo_vif(self, mac):
    1.28 +    def getBlockDeviceClass(self, devid):
    1.29 +        # To get a device number from the devid,
    1.30 +        # we temporarily use the device controller of VBD.
    1.31 +        dev = self.getDeviceController('vbd').convertToDeviceNumber(devid)
    1.32 +        dev_info = self._getDeviceInfo_vbd(dev)
    1.33 +        if dev_info:
    1.34 +            return dev_info[0]
    1.35 +
    1.36 +    def _getDeviceInfo_vif(self, mac):
    1.37          for dev_type, dev_info in self.info.all_devices_sxpr():
    1.38              if dev_type != 'vif':
    1.39                  continue
    1.40              if mac == sxp.child_value(dev_info, 'mac'):
    1.41                  return dev_info
    1.42  
    1.43 -    def getDeviceInfo_vbd(self, devid):
    1.44 +    def _getDeviceInfo_vbd(self, devid):
    1.45          for dev_type, dev_info in self.info.all_devices_sxpr():
    1.46              if dev_type != 'vbd' and dev_type != 'tap':
    1.47                  continue
     2.1 --- a/tools/python/xen/xend/server/XMLRPCServer.py	Fri Sep 07 11:24:28 2007 +0100
     2.2 +++ b/tools/python/xen/xend/server/XMLRPCServer.py	Fri Sep 07 11:30:18 2007 +0100
     2.3 @@ -87,7 +87,7 @@ methods = ['device_create', 'device_conf
     2.4             'destroyDevice','getDeviceSxprs',
     2.5             'setMemoryTarget', 'setName', 'setVCpuCount', 'shutdown',
     2.6             'send_sysrq', 'getVCPUInfo', 'waitForDevices',
     2.7 -           'getRestartCount']
     2.8 +           'getRestartCount', 'getBlockDeviceClass']
     2.9  
    2.10  exclude = ['domain_create', 'domain_restore']
    2.11  
     3.1 --- a/tools/python/xen/xm/main.py	Fri Sep 07 11:24:28 2007 +0100
     3.2 +++ b/tools/python/xen/xm/main.py	Fri Sep 07 11:30:18 2007 +0100
     3.3 @@ -2217,12 +2217,13 @@ def xm_block_detach(args):
     3.4                                % (dev,dom))
     3.5      else:
     3.6          arg_check(args, 'block-detach', 2, 3)
     3.7 -        try:
     3.8 +        dom = args[0]
     3.9 +        dev = args[1]
    3.10 +        dc = server.xend.domain.getBlockDeviceClass(dom, dev)
    3.11 +        if dc == "tap":
    3.12 +            detach(args, 'tap')
    3.13 +        else:
    3.14              detach(args, 'vbd')
    3.15 -            return
    3.16 -        except:
    3.17 -            pass
    3.18 -        detach(args, 'tap')
    3.19  
    3.20  def xm_network_detach(args):
    3.21      if serverType == SERVER_XEN_API: