direct-io.hg

changeset 7238:f5320ac7ed31

Remove xm commands block-refresh and vbd-refresh, as these are unsupported.

Allow xm block-detach to take a device name as well as a device ID. This
closes bug #285 and fixes xm-test's 01_block-destroy_btblock_pos.py and
02_block-destroy_rtblock_pos.py.

Rename and reconnect XendDomainInfo.configureDevice to reconfigureDevice.
There is nothing using this at the moment, mind you.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Thu Oct 06 19:41:29 2005 +0100 (2005-10-06)
parents cd228621e1fd
children 62190db89326
files tools/python/xen/xend/XendClient.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/DevController.py tools/python/xen/xend/server/SrvDomain.py tools/python/xen/xend/server/blkif.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xend/XendClient.py	Thu Oct 06 15:12:31 2005 +0100
     1.2 +++ b/tools/python/xen/xend/XendClient.py	Thu Oct 06 19:41:29 2005 +0100
     1.3 @@ -306,22 +306,22 @@ class Xend:
     1.4                               {'op'      : 'device_create',
     1.5                                'config'  : fileof(config) })
     1.6  
     1.7 -    def xend_domain_device_refresh(self, id, type, idx):
     1.8 +    def xend_domain_device_refresh(self, id, type, dev):
     1.9          return self.xendPost(self.domainurl(id),
    1.10                               {'op'      : 'device_refresh',
    1.11                                'type'    : type,
    1.12 -                              'idx'     : idx })
    1.13 +                              'dev'     : dev })
    1.14  
    1.15 -    def xend_domain_device_destroy(self, id, type, idx):
    1.16 +    def xend_domain_device_destroy(self, id, type, dev):
    1.17          return self.xendPost(self.domainurl(id),
    1.18                               {'op'      : 'device_destroy',
    1.19                                'type'    : type,
    1.20 -                              'idx'     : idx })
    1.21 +                              'dev'     : dev })
    1.22  
    1.23 -    def xend_domain_device_configure(self, id, config, idx):
    1.24 +    def xend_domain_device_configure(self, id, config, dev):
    1.25          return self.xendPost(self.domainurl(id),
    1.26                               {'op'      : 'device_configure',
    1.27 -                              'idx'     : idx,
    1.28 +                              'dev'     : dev,
    1.29                                'config'  : fileof(config) })
    1.30  
    1.31      def xend_vnets(self):
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Thu Oct 06 15:12:31 2005 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Thu Oct 06 19:41:29 2005 +0100
     2.3 @@ -492,13 +492,6 @@ class XendDomain:
     2.4                               devconfig, devid)
     2.5  
     2.6      
     2.7 -    def domain_device_refresh(self, domid, devtype, devid):
     2.8 -        """Refresh a device."""
     2.9 -        return self.callInfo(domid,
    2.10 -                             XendDomainInfo.XendDomainInfo.device_refresh,
    2.11 -                             devtype, devid)
    2.12 -
    2.13 -
    2.14      def domain_device_destroy(self, domid, devtype, devid):
    2.15          """Destroy a device."""
    2.16          return self.callInfo(domid,
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Oct 06 15:12:31 2005 +0100
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Oct 06 19:41:29 2005 +0100
     3.3 @@ -876,25 +876,29 @@ class XendDomainInfo:
     3.4      __repr__ = __str__
     3.5  
     3.6  
     3.7 +    ## private:
     3.8 +
     3.9      def createDevice(self, deviceClass, devconfig):
    3.10          return self.getDeviceController(deviceClass).createDevice(devconfig)
    3.11  
    3.12  
    3.13 -    def configureDevice(self, deviceClass, devid, devconfig):
    3.14 -        return self.getDeviceController(deviceClass).configureDevice(
    3.15 +    def reconfigureDevice(self, deviceClass, devid, devconfig):
    3.16 +        return self.getDeviceController(deviceClass).reconfigureDevice(
    3.17              devid, devconfig)
    3.18  
    3.19  
    3.20 +    ## public:
    3.21 +
    3.22      def destroyDevice(self, deviceClass, devid):
    3.23          return self.getDeviceController(deviceClass).destroyDevice(devid)
    3.24  
    3.25  
    3.26 +    ## private:
    3.27 +
    3.28      def getDeviceSxprs(self, deviceClass):
    3.29          return self.getDeviceController(deviceClass).sxprs()
    3.30  
    3.31  
    3.32 -    ## private:
    3.33 -
    3.34      def getDeviceConfigurations(self, deviceClass):
    3.35          return self.getDeviceController(deviceClass).configurations()
    3.36  
    3.37 @@ -1234,7 +1238,7 @@ class XendDomainInfo:
    3.38          @param devid:      device id
    3.39          """
    3.40          deviceClass = sxp.name(dev_config)
    3.41 -        self.configureDevice(deviceClass, devid, dev_config)
    3.42 +        self.reconfigureDevice(deviceClass, devid, dev_config)
    3.43  
    3.44  
    3.45      ## private:
     4.1 --- a/tools/python/xen/xend/server/DevController.py	Thu Oct 06 15:12:31 2005 +0100
     4.2 +++ b/tools/python/xen/xend/server/DevController.py	Thu Oct 06 19:41:29 2005 +0100
     4.3 @@ -86,8 +86,7 @@ class DevController:
     4.4             
     4.5  
     4.6      def configurations(self):
     4.7 -        return map(lambda x: self.configuration(int(x)),
     4.8 -                   xstransact.List(self.frontendRoot()))
     4.9 +        return map(self.configuration, self.deviceIDs())
    4.10  
    4.11  
    4.12      def configuration(self, devid):
    4.13 @@ -176,7 +175,14 @@ class DevController:
    4.14          return xstransact.Read(backpath, *args)
    4.15  
    4.16  
    4.17 -    ## private:
    4.18 +    def deviceIDs(self):
    4.19 +        """@return The IDs of each of the devices currently configured for
    4.20 +        this instance's deviceClass.
    4.21 +        """
    4.22 +        return map(int, xstransact.List(self.frontendRoot()))
    4.23 +
    4.24 +
    4.25 +## private:
    4.26  
    4.27      def writeDetails(self, config, devid, backDetails, frontDetails):
    4.28          """Write the details in the store to trigger creation of a device.
     5.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Thu Oct 06 15:12:31 2005 +0100
     5.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Thu Oct 06 19:41:29 2005 +0100
     5.3 @@ -156,19 +156,11 @@ class SrvDomain(SrvDir):
     5.4          val = fn(req.args, {'dom': self.dom.domid})
     5.5          return val
     5.6  
     5.7 -    def op_device_refresh(self, op, req):
     5.8 -        fn = FormFn(self.xd.domain_device_refresh,
     5.9 -                    [['dom',  'int'],
    5.10 -                     ['type', 'str'],
    5.11 -                     ['idx',  'int']])
    5.12 -        val = fn(req.args, {'dom': self.dom.domid})
    5.13 -        return val
    5.14 -
    5.15      def op_device_destroy(self, op, req):
    5.16          fn = FormFn(self.xd.domain_device_destroy,
    5.17                      [['dom',  'int'],
    5.18                       ['type', 'str'],
    5.19 -                     ['idx',  'int']])
    5.20 +                     ['dev',  'str']])
    5.21          val = fn(req.args, {'dom': self.dom.domid})
    5.22          return val
    5.23                  
    5.24 @@ -176,7 +168,7 @@ class SrvDomain(SrvDir):
    5.25          fn = FormFn(self.xd.domain_device_configure,
    5.26                      [['dom',    'int'],
    5.27                       ['config', 'sxpr'],
    5.28 -                     ['idx',    'int']])
    5.29 +                     ['dev',    'str']])
    5.30          val = fn(req.args, {'dom': self.dom.domid})
    5.31          return val
    5.32  
     6.1 --- a/tools/python/xen/xend/server/blkif.py	Thu Oct 06 15:12:31 2005 +0100
     6.2 +++ b/tools/python/xen/xend/server/blkif.py	Thu Oct 06 19:41:29 2005 +0100
     6.3 @@ -23,7 +23,7 @@ import string
     6.4  from xen.util import blkif
     6.5  from xen.xend import sxp
     6.6  
     6.7 -from xen.xend.server.DevController import DevController
     6.8 +from DevController import DevController
     6.9  
    6.10  
    6.11  class BlkifController(DevController):
    6.12 @@ -79,3 +79,23 @@ class BlkifController(DevController):
    6.13              result.append(['mode', 'w'])
    6.14  
    6.15          return result
    6.16 +
    6.17 +
    6.18 +    def destroyDevice(self, devid):
    6.19 +        """@see DevController.destroyDevice"""
    6.20 +
    6.21 +        # If we are given a device name, then look up the device ID from it,
    6.22 +        # and destroy that ID instead.  If what we are given is an integer,
    6.23 +        # then assume it's a device ID and pass it straight through to our
    6.24 +        # superclass's method.
    6.25 +
    6.26 +        try:
    6.27 +            DevController.destroyDevice(self, int(devid))
    6.28 +        except ValueError:
    6.29 +            for i in self.deviceIDs():
    6.30 +                if self.readBackend(i, 'dev') == devid:
    6.31 +                    DevController.destroyDevice(self, i)
    6.32 +                    return
    6.33 +            # Try this, but it's almost certainly going to throw VmError,
    6.34 +            # since we can't find the device.
    6.35 +            DevController.destroyDevice(self, int(devid))
     7.1 --- a/tools/python/xen/xm/main.py	Thu Oct 06 15:12:31 2005 +0100
     7.2 +++ b/tools/python/xen/xm/main.py	Thu Oct 06 19:41:29 2005 +0100
     7.3 @@ -106,9 +106,10 @@ xm full list of subcommands:
     7.4    Virtual Device Commands:
     7.5      block-attach  <DomId> <BackDev> <FrontDev> <Mode> [BackDomId]
     7.6          Create a new virtual block device 
     7.7 -    block-detach  <DomId> <DevId>  Destroy a domain's virtual block device
     7.8 +    block-detach  <DomId> <DevId>  Destroy a domain's virtual block device,
     7.9 +                                   where <DevId> may either be the device ID
    7.10 +                                   or the device name as mounted in the guest.
    7.11      block-list    <DomId>          List virtual block devices for a domain
    7.12 -    block-refresh <DomId> <DevId>  Refresh a virtual block device for a domain
    7.13      network-limit   <DomId> <Vif> <Credit> <Period>
    7.14          Limit the transmission rate of a virtual network interface
    7.15      network-list    <DomId>        List virtual network interfaces for a domain
    7.16 @@ -522,25 +523,11 @@ def xm_block_attach(args):
    7.17      from xen.xend.XendClient import server
    7.18      server.xend_domain_device_create(dom, vbd)
    7.19  
    7.20 -def xm_block_refresh(args):
    7.21 -    arg_check(args,2,"block-refresh")
    7.22 -
    7.23 -    dom = args[0]
    7.24 -    dev = args[1]
    7.25 -
    7.26 -    from xen.xend.XendClient import server
    7.27 -    server.xend_domain_device_refresh(dom, 'vbd', dev)
    7.28 -
    7.29  def xm_block_detach(args):
    7.30      arg_check(args,2,"block-detach")
    7.31  
    7.32      dom = args[0]
    7.33 -
    7.34 -    try:
    7.35 -        dev = int(args[1])
    7.36 -    except ValueError, e:
    7.37 -        err("Invalid device id: %s" % args[1])
    7.38 -        sys.exit(1)
    7.39 +    dev = args[1]
    7.40  
    7.41      from xen.xend.XendClient import server
    7.42      server.xend_domain_device_destroy(dom, 'vbd', dev)
    7.43 @@ -622,7 +609,6 @@ commands = {
    7.44      "block-attach": xm_block_attach,
    7.45      "block-detach": xm_block_detach,
    7.46      "block-list": xm_block_list,
    7.47 -    "block-refresh": xm_block_refresh,
    7.48      # network
    7.49      "network-limit": xm_network_limit,
    7.50      "network-list": xm_network_list,
    7.51 @@ -651,7 +637,6 @@ aliases = {
    7.52      "vbd-create": "block-create",
    7.53      "vbd-destroy": "block-destroy",
    7.54      "vbd-list": "block-list",
    7.55 -    "vbd-refresh": "block-refresh",
    7.56      }
    7.57  
    7.58  help = {