Explicitly lock an LV before trying to delete it sipb-xen-remctl-auto/1.1
authorEvan Broder <broder@mit.edu>
Sun, 5 Oct 2008 22:01:54 +0000 (18:01 -0400)
committerEvan Broder <broder@mit.edu>
Sun, 5 Oct 2008 22:01:54 +0000 (18:01 -0400)
svn path=/trunk/packages/sipb-xen-remctl-auto/; revision=1066

debian/changelog
files/usr/sbin/sipb-xen-lvm

index 27c6166..ffe56b6 100644 (file)
@@ -1,3 +1,9 @@
+sipb-xen-remctl-auto (1.1) unstable; urgency=low
+
+  * Explicitly lock a volume before deleting it
+
+ -- Evan Broder <broder@mit.edu>  Sun, 05 Oct 2008 18:01:34 -0400
+
 sipb-xen-remctl-auto (1.0.21) unstable; urgency=low
 
   * start inetd too in init script
index f42804e..00766f6 100755 (executable)
@@ -41,11 +41,19 @@ else:
     lvname = prefix + machine + "_" + disk
     lvpath = "/dev/" + vg + "/" + lvname
 if subcommand == "lvremove":
+    def error():
+        print >>sys.stderr, "Error removing LV %s\n" % lvname
+        sys.exit(1)
+    rv = call(["/sbin/lvchange", "-a", "n", lvpath])
+    if rv != 0:
+        error()
+    rv = call(["/sbin/lvchange", "-a", "ey", lvpath])
+    if rv != 0:
+        error()
     rv = call(["/sbin/lvremove", "--force", lvpath])
-    ensureoff(machine)
     if rv != 0:
-        print >>sys.stderr, "Error removing LV %s\n" %(lvname,)
-        sys.exit(1)
+        error()
+    ensureoff(machine)
 elif subcommand == "lvresize":
     size = sys.argv[4]
     ensureoff(machine)