From 3d1fa15d716635c75897bcc49536feae60460a6a Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Tue, 10 Jul 2012 15:22:39 +0100 Subject: 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 --- nova/virt/disk/guestfs.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 -- cgit