|
|
|
|
|
|
|
|
|
|
xen-changelog
[Xen-changelog] [xen-unstable] xend: Check no VBDs attached on VDI.destr
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1255678521 -3600
# Node ID 4872dc215d62d5d5f57869619d36d854342860c5
# Parent 7396c20cb26c767e587df5da414ae0ff0da89141
xend: Check no VBDs attached on VDI.destroy
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 <kanno.masaki@xxxxxxxxxxxxxx>
---
tools/python/xen/xend/XendAPI.py | 6 ++++++
tools/python/xen/xend/XendError.py | 12 ++++++++++++
2 files changed, 18 insertions(+)
diff -r 7396c20cb26c -r 4872dc215d62 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py Fri Oct 16 08:34:49 2009 +0100
+++ b/tools/python/xen/xend/XendAPI.py Fri Oct 16 08:35:21 2009 +0100
@@ -2370,6 +2370,12 @@ class XendAPI(object):
# 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()
diff -r 7396c20cb26c -r 4872dc215d62 tools/python/xen/xend/XendError.py
--- a/tools/python/xen/xend/XendError.py Fri Oct 16 08:34:49 2009 +0100
+++ b/tools/python/xen/xend/XendError.py Fri Oct 16 08:35:21 2009 +0100
@@ -185,6 +185,18 @@ class DirectPCIError(XendAPIError):
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
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
<Prev in Thread] |
Current Thread |
[Next in Thread> |
- [Xen-changelog] [xen-unstable] xend: Check no VBDs attached on VDI.destroy,
Xen patchbot-unstable <=
|
|
|
|
|