Skip to contentSkip to conversation

xend: Unlink VDI instances and VBD instances

PATCH Superseded Masaki Kanno 2 participants 4 messages Sep 17, 2009 – Sep 24, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xend: Unlink VDI instances and VBD instances

Hi,

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

Best regards,
Kan

tools/python/xen/xend/XendDomain.py +2 -0
diff -r 72d130772f36 tools/python/xen/xend/XendDomain.py
@@ -347,6 +347,7 @@
             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 @@
             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.")
tools/python/xen/xend/XendDomainInfo.py +12 -0
diff -r 72d130772f36 tools/python/xen/xend/XendDomainInfo.py
@@ -4043,6 +4043,18 @@
             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.
         """

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Applied as c/s 20221, but it produces the following backtrace, so I reverted it:
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/xen/xend/XendCheckpoint.py", line
165, in save
dominfo.destroy()
File "/usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line
2855, in destroy
XendDomain.instance().remove_domain(self)
File "/usr/lib/python2.4/site-packages/xen/xend/XendDomain.py", line 468,
in remove_domain
self._remove_domain(info, domid)
File "/usr/lib/python2.4/site-packages/xen/xend/XendDomain.py", line 489,
in _remove_domain
info.unlink_xapi_instances()
File "/usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line
4054, in unlink_xapi_instances

    vdi = XendNode.instance().get_vdi_by_uuid(dev_info['VDI'])

KeyError: 'VDI'

-- Keir

Quoted 11 lines · Masaki Kanno

Hi,

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

Best regards,
Kan

#2 lore raw

Hi Keir,

Sorry. I didn't test the patch on a server to which XenAPI mode was invalid. I will send a new patch.

Best regards,
Kan

Quoted 43 lines · Keir Fraser

Applied as c/s 20221, but it produces the following backtrace, so I reverted it:
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/xen/xend/XendCheckpoint.py", line
165, in save
dominfo.destroy()
File "/usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line
2855, in destroy
XendDomain.instance().remove_domain(self)
File "/usr/lib/python2.4/site-packages/xen/xend/XendDomain.py", line 468,
in remove_domain
self._remove_domain(info, domid)
File "/usr/lib/python2.4/site-packages/xen/xend/XendDomain.py", line 489,
in _remove_domain
info.unlink_xapi_instances()
File "/usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line
4054, in unlink_xapi_instances
vdi = XendNode.instance().get_vdi_by_uuid(dev_info['VDI'])
KeyError: 'VDI'

-- Keir

Quoted 11 lines · Masaki Kanno

Hi,

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

Best regards,
Kan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw

PATCH v2 1/1 xend: Unlink VDI instances and VBD instances

Hi Keir,

VBD information in xend does not have a VDI value if XenAPI mode is invalid.
A new patch confirms the VDI value is valid. So, the new patch cuts off VDI->VBD links if the VDI value is valid.

Best regards,
Kan

Quoted 55 lines · Masaki Kanno

Hi Keir,

Sorry. I didn't test the patch on a server to which XenAPI mode was invalid. I will send a new patch.

Best regards,
Kan

Quoted 39 lines · Keir Fraser

Applied as c/s 20221, but it produces the following backtrace, so I reverted it:
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/xen/xend/XendCheckpoint.py", line
165, in save
dominfo.destroy()
File "/usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line
2855, in destroy
XendDomain.instance().remove_domain(self)
File "/usr/lib/python2.4/site-packages/xen/xend/XendDomain.py", line 468,
in remove_domain
self._remove_domain(info, domid)
File "/usr/lib/python2.4/site-packages/xen/xend/XendDomain.py", line 489,
in _remove_domain
info.unlink_xapi_instances()
File "/usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line
4054, in unlink_xapi_instances
vdi = XendNode.instance().get_vdi_by_uuid(dev_info['VDI'])
KeyError: 'VDI'

-- Keir

Quoted 11 lines · Masaki Kanno

Hi,

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

Best regards,
Kan

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

tools/python/xen/xend/XendDomain.py +2 -0
diff -r 0f8376078dc1 tools/python/xen/xend/XendDomain.py
@@ -347,6 +347,7 @@
             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 @@
             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.")
tools/python/xen/xend/XendDomainInfo.py +14 -0
diff -r 0f8376078dc1 tools/python/xen/xend/XendDomainInfo.py
@@ -4043,6 +4043,20 @@
             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_uuid = dev_info.get('VDI', None)
+            if vdi_uuid and XendNode.instance().is_valid_vdi(vdi_uuid):
+                vdi = XendNode.instance().get_vdi_by_uuid(vdi_uuid)
+                if vdi.getVBDs().count(vbd_ref):
+                    vdi.removeVBD(vbd_ref)
+
     def destroy_xapi_instances(self):
         """Destroy Xen-API instances stored in XendAPIStore.
         """

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel