ia64/xen-unstable

changeset 4423:50ec7eded8a9

bitkeeper revision 1.1236.51.2 (424d4e45s3_LSUrubUDpgLTFNoQ2xw)

add support for refreshing vbds

Signed-off-by: Vincent Hanquez <vincent@xensource.com>
author vh249@arcadians.cl.cam.ac.uk
date Fri Apr 01 13:36:05 2005 +0000 (2005-04-01)
parents 6f22a415c2bc
children a6d955deec8e
files tools/python/xen/xend/XendClient.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.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	Fri Apr 01 13:20:59 2005 +0000
     1.2 +++ b/tools/python/xen/xend/XendClient.py	Fri Apr 01 13:36:05 2005 +0000
     1.3 @@ -308,6 +308,12 @@ 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 +        return self.xendPost(self.domainurl(id),
     1.9 +                             {'op'      : 'device_refresh',
    1.10 +                              'type'    : type,
    1.11 +                              'idx'     : idx })
    1.12 +
    1.13      def xend_domain_device_destroy(self, id, type, idx):
    1.14          return self.xendPost(self.domainurl(id),
    1.15                               {'op'      : 'device_destroy',
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Fri Apr 01 13:20:59 2005 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Fri Apr 01 13:36:05 2005 +0000
     2.3 @@ -687,6 +687,18 @@ class XendDomain:
     2.4          self.update_domain(dominfo.id)
     2.5          return val
     2.6      
     2.7 +    def domain_device_refresh(self, id, type, idx):
     2.8 +        """Refresh a device.
     2.9 +
    2.10 +        @param id:  domain id
    2.11 +        @param idx:  device index
    2.12 +        @param type: device type
    2.13 +        """
    2.14 +        dominfo = self.domain_lookup(id)
    2.15 +        self.refresh_schedule()
    2.16 +        val = dominfo.device_refresh(type, idx)
    2.17 +        self.update_domain(dominfo.id)
    2.18 +        return val
    2.19  
    2.20      def domain_device_destroy(self, id, type, idx):
    2.21          """Destroy a device.
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Apr 01 13:20:59 2005 +0000
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Apr 01 13:36:05 2005 +0000
     3.3 @@ -551,6 +551,16 @@ class XendDomainInfo:
     3.4          dl.append(dev)
     3.5          self.devices[type] = dl
     3.6  
     3.7 +    def refresh_device(self, type, dev):
     3.8 +        """Refresh a device to a virtual machine.
     3.9 +
    3.10 +        @param type: device type
    3.11 +        @param dev:  device
    3.12 +        """
    3.13 +        dl = self.devices.get(type, [])
    3.14 +        if dev in dl:
    3.15 +            dl.refresh(dev)
    3.16 +
    3.17      def remove_device(self, type, dev):
    3.18          """Remove a device from a virtual machine.
    3.19  
    3.20 @@ -912,6 +922,19 @@ class XendDomainInfo:
    3.21          old_index = self.config.index(old_full_config)
    3.22          self.config[old_index] = new_full_config
    3.23          return new_config
    3.24 +
    3.25 +    def device_refresh(self, type, idx):
    3.26 +        """Refresh a device.
    3.27 +
    3.28 +        @param type: device type
    3.29 +        @param idx:  device index
    3.30 +        """
    3.31 +        dev = self.get_device_by_index(type, idx)
    3.32 +        if not dev:
    3.33 +            raise VmError('invalid device: %s %s' % (type, idx))
    3.34 +        devs = self.devices.get(type)
    3.35 +        dev.refresh()
    3.36 +        #self.refresh_device(type, dev)
    3.37          
    3.38      def device_destroy(self, type, idx):
    3.39          """Destroy a device.
     4.1 --- a/tools/python/xen/xend/server/SrvDomain.py	Fri Apr 01 13:20:59 2005 +0000
     4.2 +++ b/tools/python/xen/xend/server/SrvDomain.py	Fri Apr 01 13:36:05 2005 +0000
     4.3 @@ -131,6 +131,14 @@ class SrvDomain(SrvDir):
     4.4          d = fn(req.args, {'dom': self.dom.id})
     4.5          return d
     4.6  
     4.7 +    def op_device_refresh(self, op, req):
     4.8 +        fn = FormFn(self.xd.domain_device_refresh,
     4.9 +                    [['dom', 'str'],
    4.10 +                     ['type', 'str'],
    4.11 +                     ['idx', 'str']])
    4.12 +        val = fn(req.args, {'dom': self.dom.id})
    4.13 +        return val
    4.14 +
    4.15      def op_device_destroy(self, op, req):
    4.16          fn = FormFn(self.xd.domain_device_destroy,
    4.17                      [['dom', 'str'],
     5.1 --- a/tools/python/xen/xend/server/blkif.py	Fri Apr 01 13:20:59 2005 +0000
     5.2 +++ b/tools/python/xen/xend/server/blkif.py	Fri Apr 01 13:36:05 2005 +0000
     5.3 @@ -414,6 +414,10 @@ class BlkDev(controller.SplitDev):
     5.4              val.append(['index', self.index])
     5.5          return val
     5.6  
     5.7 +    def refresh(self):
     5.8 +        log.debug("Refreshing vbd domain=%d idx=%s", self.controller.dom, self.idx)
     5.9 +        self.interfaceChanged()
    5.10 +
    5.11      def destroy(self, change=0):
    5.12          """Destroy the device. If 'change' is true notify the front-end interface.
    5.13  
     6.1 --- a/tools/python/xen/xm/main.py	Fri Apr 01 13:20:59 2005 +0000
     6.2 +++ b/tools/python/xen/xm/main.py	Fri Apr 01 13:36:05 2005 +0000
     6.3 @@ -800,6 +800,28 @@ Create a virtual block device for a doma
     6.4  
     6.5  xm.prog(ProgVbdCreate)
     6.6  
     6.7 +class ProgVbdRefresh(Prog):
     6.8 +    group = 'vbd'
     6.9 +    name  = 'vbd-refresh'
    6.10 +    info = """Refresh a virtual block device for a domain"""
    6.11 +
    6.12 +    def help(self, args):
    6.13 +        print args[0], "DOM DEV"
    6.14 +        print """
    6.15 +Refresh a virtual block device for a domain.
    6.16 +
    6.17 +  DEV     - idx field in the device information
    6.18 +"""
    6.19 +
    6.20 +    def main(self, args):
    6.21 +        if len(args) != 3: self.err("%s: Invalid argument(s)" % args[0])
    6.22 +        dom = args[1]
    6.23 +        dev = args[2]
    6.24 +        server.xend_domain_device_refresh(dom, 'vbd', dev)
    6.25 +
    6.26 +xm.prog(ProgVbdRefresh)
    6.27 +
    6.28 +
    6.29  class ProgVbdDestroy(Prog):
    6.30      group = 'vbd'
    6.31      name = 'vbd-destroy'