xend: Check no VBDs attached
PATCH 1/1 xend: Check no VBDs attached
Hi,
We can destroy a VDI by VDI.destroy even if the VDI is being used to VBDs.
This patch checks that the VDI is not used to VBDs.
Signed-off-by Masaki Kanno <[email protected]>
Best regards,
Kan
tools/python/xen/xend/XendAPI.py +6 -0
@@ -2369,6 +2369,12 @@ # Object Methods def VDI_destroy(self, session, vdi_ref): + # check no VBDs attached + image = XendNode.instance().get_vdi_by_uuid(vdi_ref) + if image.getVBDs(): + raise VDIError("Cannot destroy VDI with VBDs attached", + image.name_label) + sr = XendNode.instance().get_sr_containing_vdi(vdi_ref) sr.destroy_vdi(vdi_ref) return xen_api_success_void()
tools/python/xen/xend/XendError.py +12 -0
@@ -186,6 +186,18 @@ def __str__(self): return 'DIRECT_PCI_ERROR: %s' % self.error +class VDIError(XendAPIError): + def __init__(self, error, vdi): + XendAPIError.__init__(self) + self.vdi = vdi + self.error = error + + def get_api_error(self): + return ['VDI_ERROR', self.error, self.vdi] + + def __str__(self): + return 'VDI_ERROR: %s %s' % (self.error, self.vdi) + from xen.util.xsconstants import xserr2string class SecurityError(XendAPIError):
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel