summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPádraig Brady <pbrady@redhat.com>2012-07-10 15:22:39 +0100
committerPádraig Brady <pbrady@redhat.com>2012-07-10 17:02:11 +0100
commit3d1fa15d716635c75897bcc49536feae60460a6a (patch)
tree15acb14e1253eb9ace3b173f5e6966127b14483c
parentbda7c3e0b6863473a0202905cb5b41a7d33d2143 (diff)
ensure libguestfs has completed before proceeding
This is a more correct fix than the previous sync(1) which probably only changed timings, masking the real issue. The FUSE issue is referenced here: http://code.google.com/p/s3ql/issues/detail?id=159 which in turn references this thread on the subject from 2006: http://thread.gmane.org/gmane.comp.file-systems.fuse.devel/3903 And another case from 2008: http://permalink.gmane.org/gmane.comp.file-systems.fuse.devel/6502 Fixes bug: 1013689 Change-Id: I36fd11d5f01562f65a6b6f07e759ea066490b067
-rw-r--r--nova/virt/disk/guestfs.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/nova/virt/disk/guestfs.py b/nova/virt/disk/guestfs.py
index bf7a286e0..f2ff3c371 100644
--- a/nova/virt/disk/guestfs.py
+++ b/nova/virt/disk/guestfs.py
@@ -88,8 +88,19 @@ class Mount(mount.Mount):
def unmnt_dev(self):
if not self.mounted:
return
- utils.execute('sync')
# root users don't need a specific unmnt_dev()
# but ordinary users do
utils.execute('fusermount', '-u', self.mount_dir, run_as_root=True)
+
+ # Unfortunately FUSE has an issue where it doesn't wait
+ # for processes associated with the mount to terminate.
+ # Therefore we do this manually here. Note later versions
+ # of guestmount have the --pid-file option to help with this.
+ # Here we check every .2 seconds whether guestmount is finished
+ # but do this for at most 10 seconds.
+ wait_cmd = 'until ! ps -C guestmount -o args= | grep -qF "%s"; '
+ wait_cmd += 'do sleep .2; done'
+ wait_cmd %= self.mount_dir
+ utils.execute('timeout', '10s', 'sh', '-c', wait_cmd)
+
self.mounted = False