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-devel

[Xen-devel] [PATCH] Fix block-detach of non-existent device

To: Xen Developers <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Fix block-detach of non-existent device
From: Dan Smith <danms@xxxxxxxxxx>
Date: Tue, 04 Oct 2005 15:07:54 -0700
Delivery-date: Tue, 04 Oct 2005 22:06:12 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux)
The attached patch prevents Xend from blowing up when a user tries to
detach a non-existent block device.

I also added a check in xm to make sure that a numeric id is supplied,
instead of a device name.

This will cause xm-test 04_block-destroy_nonattached_neg to pass.

Signed-off-by: Dan Smith <danms@xxxxxxxxxx>
diff -r ec84b119e4ed tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py     Tue Oct  4 14:02:51 2005
+++ b/tools/python/xen/xend/server/DevController.py     Tue Oct  4 13:12:38 2005
@@ -78,8 +78,12 @@
         backpath = xstransact.Read(frontpath, "backend")
 
         xstransact.Remove(frontpath)
-        xstransact.Remove(backpath)
-
+
+        if backpath:
+            xstransact.Remove(backpath)
+        else:
+            raise VmError("Device not connected")
+           
 
     def configurations(self):
         return map(lambda x: self.configuration(int(x)),
diff -r ec84b119e4ed tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Tue Oct  4 14:02:51 2005
+++ b/tools/python/xen/xm/main.py       Tue Oct  4 13:12:38 2005
@@ -165,6 +165,9 @@
     error = str(ex)
     if error == "Not found" and dom != None:
         err("Domain '%s' not found when running 'xm %s'" % (dom, cmd))
+        sys.exit(1)
+    elif error == "Exception: Device not connected":
+        err("Device not connected")
         sys.exit(1)
     else:
         raise ex
@@ -532,7 +535,12 @@
     arg_check(args,2,"block-detach")
 
     dom = args[0]
-    dev = args[1]
+
+    try:
+        dev = int(args[1])
+    except ValueError, e:
+        err("Invalid device id: %s" % args[1])
+        sys.exit(1)
 
     from xen.xend.XendClient import server
     server.xend_domain_device_destroy(dom, 'vbd', dev)
-- 
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms@xxxxxxxxxx
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>