xend: Unlink VDI instances and VBD instances

When VBD instances are destroyed by xm delete command, VDI
instances keep linking to the VBD instances unilaterally.

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
This commit is contained in:
Keir Fraser committed 2009-09-18 08:27:38 +01:00
1 parent d7a4a39acb
commit 75112bdbe1
2 files changed
+14

No files matched your search

+2
View File
@@ -347,6 +347,7 @@ class XendDomain:
if self.is_domain_managed(dom):
self._managed_config_remove(dom.get_uuid())
del self.managed_domains[dom.get_uuid()]
dom.unlink_xapi_instances()
dom.destroy_xapi_instances()
except ValueError:
log.warn("Domain is not registered: %s" % dom.get_uuid())
@@ -485,6 +486,7 @@ class XendDomain:
if domid in self.domains:
del self.domains[domid]
info.unlink_xapi_instances()
info.destroy_xapi_instances()
else:
log.warning("Attempted to remove non-existent domain.")
+12
View File
@@ -4043,6 +4043,18 @@ class XendDomainInfo:
except Exception, exn:
raise XendError('Failed to destroy device')
def unlink_xapi_instances(self):
from xen.xend import XendDomain
if XendDomain.instance().is_valid_vm(self.info.get('uuid')):
# domain still exists.
return
for vbd_ref in self.info.get('vbd_refs'):
dev_info = self.info['devices'].get(vbd_ref)[1]
vdi = XendNode.instance().get_vdi_by_uuid(dev_info['VDI'])
if vdi.getVBDs().count(vbd_ref):
vdi.removeVBD(vbd_ref)
def destroy_xapi_instances(self):
"""Destroy Xen-API instances stored in XendAPIStore.
"""
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.