openstack team mailing list archive
-
openstack team
-
Mailing list archive
-
Message #04512
Re: [PATCH] don't disconnect a mounted device
Quoting Serge E. Hallyn (serge.hallyn@xxxxxxxxxxxxx):
> I'm sure the patch should be tweaked (helpers moved elsewhere, whatever)
> but running euca-terminate-instances twice on an lxc container can cause
> oopses on the host without this.
Sorry, I guess when I re-typed it I erred on caps - s/true/True/ and
s/false/False/ to come up with the following, which is working rock-solid
for me.
diff -Nru nova-2011.3/debian/changelog nova-2011.3/debian/changelog
--- nova-2011.3/debian/changelog 2011-09-30 14:22:23.000000000 -0500
+++ nova-2011.3/debian/changelog 2011-10-03 20:14:58.000000000 -0500
@@ -1,3 +1,10 @@
+nova (2011.3-0ubuntu5) oneiric; urgency=low
+
+ * debian/patches/dont-detach-mounted-qemu-nbd.patch: work harder to prevent
+ host kernel oopses when a container is slow to shut down. (LP: #861656)
+
+ -- Serge Hallyn <serge.hallyn@xxxxxxxxxxxxx> Mon, 03 Oct 2011 20:14:05 -0500
+
nova (2011.3-0ubuntu4) oneiric; urgency=low
[James Page]
diff -Nru nova-2011.3/debian/patches/dont-detach-mounted-qemu-nbd.patch nova-2011.3/debian/patches/dont-detach-mounted-qemu-nbd.patch
--- nova-2011.3/debian/patches/dont-detach-mounted-qemu-nbd.patch 1969-12-31 18:00:00.000000000 -0600
+++ nova-2011.3/debian/patches/dont-detach-mounted-qemu-nbd.patch 2011-10-03 20:13:59.000000000 -0500
@@ -0,0 +1,40 @@
+Description: virt/disk.py: don't detach a mounted qemu-nbd drive
+ If a mounted qemu-nbd drive is detached, it can easily oops the kernel
+ and prevent the host from syncing or being cleanly shut down.
+Author: Serge Hallyn <serge.hallyn@xxxxxxxxxxxxx>
+Forwarded: yes
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/861656
+
+Index: nova-2011.3/nova/virt/disk.py
+===================================================================
+--- nova-2011.3.orig/nova/virt/disk.py 2011-10-03 20:11:42.104067746 -0500
++++ nova-2011.3/nova/virt/disk.py 2011-10-03 20:11:51.920116412 -0500
+@@ -224,9 +224,28 @@
+ return out.strip()
+
+
++def is_mounted(device):
++ f=open("/proc/mounts", "r")
++ for l in f.readlines():
++ fields = l.split()
++ if fields[0] == device:
++ f.close()
++ return True
++ f.close()
++ return False
++
++def is_stuck_mounted(device):
++ if is_mounted(device):
++ utils.execute('umount', device, run_as_root=True)
++ if is_mounted(device):
++ return True
++ return False
++
+ def _unlink_device(device, nbd):
+ """Unlink image from device using loopback or nbd"""
+ if nbd:
++ if is_stuck_mounted(device):
++ raise exception.Error(_('Could not unmount device %s') % device)
+ utils.execute('qemu-nbd', '-d', device, run_as_root=True)
+ _free_device(device)
+ else:
diff -Nru nova-2011.3/debian/patches/series nova-2011.3/debian/patches/series
--- nova-2011.3/debian/patches/series 2011-09-30 14:22:23.000000000 -0500
+++ nova-2011.3/debian/patches/series 2011-10-03 20:11:37.000000000 -0500
@@ -10,3 +10,4 @@
backport-lxc-container-console-fix.patch
backport-snapshot-cleanup.patch
fix-lp863305-images-permission.patch
+dont-detach-mounted-qemu-nbd.patch
References