mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
bitkeeper revision 1.1077 (40f3fb66AxVdcgokLJ3FBqGopebf3A)
Add some device create/destroy changes that got missed.
This commit is contained in:
1 parent
9a1fac5ff3
commit
0fa06134bb
2 files changed
+54
-1
No files matched your search
@@ -566,18 +566,31 @@ class XendDomain:
|
||||
return xc.atropos_domain_get(dom)
|
||||
|
||||
def domain_device_create(self, dom, devconfig):
|
||||
"""Create a new device for a domain.
|
||||
|
||||
@param dom: domain id
|
||||
@param devconfig: device configuration
|
||||
@return: deferred
|
||||
"""
|
||||
dom = int(dom)
|
||||
dominfo = self.domain_get(dom)
|
||||
if not dominfo:
|
||||
raise ValueError("invalid domain:" + str(dom))
|
||||
self.refresh_schedule()
|
||||
return dominfo.device_create(devconfig)
|
||||
|
||||
|
||||
def domain_device_destroy(self, dom, type, idx):
|
||||
"""Destroy a device.
|
||||
|
||||
@param dom: domain id
|
||||
@param type: device type
|
||||
@param idx: device index
|
||||
"""
|
||||
dom = int(dom)
|
||||
dominfo = self.domain_get(dom)
|
||||
if not dominfo:
|
||||
raise ValueError("invalid domain:" + str(dom))
|
||||
self.refresh_schedule()
|
||||
return dominfo.device_destroy(type, idx)
|
||||
|
||||
def domain_devtype_ls(self, dom, type):
|
||||
|
||||
@@ -445,6 +445,13 @@ class XendDomainInfo:
|
||||
devices.append(dev)
|
||||
return devices
|
||||
|
||||
def config_device(self, type, idx):
|
||||
devs = self.config_devices(type)
|
||||
if 0 <= idx < len(devs):
|
||||
return devs[idx]
|
||||
else:
|
||||
return None
|
||||
|
||||
def add_device(self, type, dev):
|
||||
"""Add a device to a virtual machine.
|
||||
|
||||
@@ -650,6 +657,39 @@ class XendDomainInfo:
|
||||
print '<create_devices'
|
||||
return deferred
|
||||
|
||||
def device_create(self, dev_config):
|
||||
"""Create a new device.
|
||||
|
||||
@param dev_config: device configuration
|
||||
@return: deferred
|
||||
"""
|
||||
dev_name = sxp.name(dev_config)
|
||||
dev_handler = get_device_handler(dev_name)
|
||||
if dev_handler is None:
|
||||
raise VmError('unknown device type: ' + dev_name)
|
||||
devs = self.get_devices(dev_name)
|
||||
dev_index = len(devs)
|
||||
self.config.append(['device', dev_config])
|
||||
d = dev_handler(self, dev_config, dev_index)
|
||||
return d
|
||||
|
||||
def device_destroy(self, type, idx):
|
||||
"""Destroy a device.
|
||||
|
||||
@param type: device type
|
||||
@param idx: device index
|
||||
"""
|
||||
dev = self.get_device_by_index(type, idx)
|
||||
if not dev:
|
||||
raise VmError('invalid device: %s %d' % (type, idx))
|
||||
devs = self.devices.get(type)
|
||||
if 0 <= idx < len(devs):
|
||||
del devs[idx]
|
||||
dev_config = self.config_device(type, idx)
|
||||
if dev_config:
|
||||
self.config.remove(['device', dev_config])
|
||||
dev.destroy()
|
||||
|
||||
def configure_backends(self):
|
||||
"""Set configuration flags if the vm is a backend for netif of blkif.
|
||||
"""
|
||||
|
||||