summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-07-10 23:45:53 +0000
committerGerrit Code Review <review@openstack.org>2012-07-10 23:45:53 +0000
commitdba3622f37eedaea369c13ddd618d37f7516f62a (patch)
tree5f24643a2d24ce98915d388edd5cb027fc097c56
parent6fb05fe78555ec59ed36c4a3a1cb3f60e47c7ed3 (diff)
parent3d1fa15d716635c75897bcc49536feae60460a6a (diff)
Merge "ensure libguestfs has completed before proceeding"
-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