WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xend: Check no VBDs attached on VDI.destr

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xend: Check no VBDs attached on VDI.destroy
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 16 Oct 2009 01:10:19 -0700
Delivery-date: Fri, 16 Oct 2009 01:15:20 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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 <=