ia64/xen-unstable

changeset 1771:524a61d40438

bitkeeper revision 1.1077 (40f3fb66AxVdcgokLJ3FBqGopebf3A)

Add some device create/destroy changes that got missed.
author mjw@wray-m-3.hpl.hp.com
date Tue Jul 13 15:10:30 2004 +0000 (2004-07-13)
parents 1331621fe269
children 384558e64811
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Tue Jul 13 14:54:44 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Tue Jul 13 15:10:30 2004 +0000
     1.3 @@ -566,18 +566,31 @@ class XendDomain:
     1.4          return xc.atropos_domain_get(dom)
     1.5  
     1.6      def domain_device_create(self, dom, devconfig):
     1.7 +        """Create a new device for a domain.
     1.8 +
     1.9 +        @param dom:       domain id
    1.10 +        @param devconfig: device configuration
    1.11 +        @return: deferred
    1.12 +        """
    1.13          dom = int(dom)
    1.14          dominfo = self.domain_get(dom)
    1.15          if not dominfo:
    1.16              raise ValueError("invalid domain:" + str(dom))
    1.17 +        self.refresh_schedule()
    1.18          return dominfo.device_create(devconfig)
    1.19 -    
    1.20  
    1.21      def domain_device_destroy(self, dom, type, idx):
    1.22 +        """Destroy a device.
    1.23 +
    1.24 +        @param dom:  domain id
    1.25 +        @param type: device type
    1.26 +        @param idx:  device index
    1.27 +        """
    1.28          dom = int(dom)
    1.29          dominfo = self.domain_get(dom)
    1.30          if not dominfo:
    1.31              raise ValueError("invalid domain:" + str(dom))
    1.32 +        self.refresh_schedule()
    1.33          return dominfo.device_destroy(type, idx)
    1.34  
    1.35      def domain_devtype_ls(self, dom, type):
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Jul 13 14:54:44 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Jul 13 15:10:30 2004 +0000
     2.3 @@ -445,6 +445,13 @@ class XendDomainInfo:
     2.4                  devices.append(dev)
     2.5          return devices
     2.6  
     2.7 +    def config_device(self, type, idx):
     2.8 +        devs = self.config_devices(type)
     2.9 +        if 0 <= idx < len(devs):
    2.10 +            return devs[idx]
    2.11 +        else:
    2.12 +            return None
    2.13 +
    2.14      def add_device(self, type, dev):
    2.15          """Add a device to a virtual machine.
    2.16  
    2.17 @@ -650,6 +657,39 @@ class XendDomainInfo:
    2.18          print '<create_devices'
    2.19          return deferred
    2.20  
    2.21 +    def device_create(self, dev_config):
    2.22 +        """Create a new device.
    2.23 +
    2.24 +        @param dev_config: device configuration
    2.25 +        @return: deferred
    2.26 +        """
    2.27 +        dev_name = sxp.name(dev_config)
    2.28 +        dev_handler = get_device_handler(dev_name)
    2.29 +        if dev_handler is None:
    2.30 +            raise VmError('unknown device type: ' + dev_name)
    2.31 +        devs = self.get_devices(dev_name)
    2.32 +        dev_index = len(devs)
    2.33 +        self.config.append(['device', dev_config])
    2.34 +        d = dev_handler(self, dev_config, dev_index)
    2.35 +        return d
    2.36 +
    2.37 +    def device_destroy(self, type, idx):
    2.38 +        """Destroy a device.
    2.39 +
    2.40 +        @param type: device type
    2.41 +        @param idx:  device index
    2.42 +        """
    2.43 +        dev = self.get_device_by_index(type, idx)
    2.44 +        if not dev:
    2.45 +            raise VmError('invalid device: %s %d' % (type, idx))
    2.46 +        devs = self.devices.get(type)
    2.47 +        if 0 <= idx < len(devs):
    2.48 +            del devs[idx]
    2.49 +        dev_config = self.config_device(type, idx)
    2.50 +        if dev_config:
    2.51 +            self.config.remove(['device', dev_config])
    2.52 +        dev.destroy()
    2.53 +
    2.54      def configure_backends(self):
    2.55          """Set configuration flags if the vm is a backend for netif of blkif.
    2.56          """