libvirt: allows attach and detach from all domains

Previously attaching/detaching from a shutoff domain would fail.

Fixes bug 1057730

Change-Id: I876872700da125cb078746401b1b80da265880ff
This commit is contained in:
Vishvananda Ishaya
2012-09-27 20:33:17 +00:00
parent 0c96c34eff
commit ddabe05cce

View File

@@ -69,8 +69,11 @@ VIR_DOMAIN_SHUTOFF = 5
VIR_DOMAIN_CRASHED = 6
VIR_DOMAIN_XML_SECURE = 1
VIR_DOMAIN_UNDEFINE_MANAGED_SAVE = 1
VIR_DOMAIN_AFFECT_CURRENT = 0
VIR_CPU_COMPARE_ERROR = -1
VIR_CPU_COMPARE_INCOMPATIBLE = 0
VIR_CPU_COMPARE_IDENTICAL = 1
@@ -334,11 +337,17 @@ class Domain(object):
self._def['devices']['disks'] += [disk_info]
return True
def attachDeviceFlags(self, xml, _flags):
self.attachDevice(xml)
def detachDevice(self, xml):
disk_info = _parse_disk_info(etree.fromstring(xml))
disk_info['_attached'] = True
return disk_info in self._def['devices']['disks']
def detachDeviceFlags(self, xml, _flags):
self.detachDevice(xml)
def XMLDesc(self, flags):
disks = ''
for disk in self._def['devices']['disks']: