Skip to content

Commit

Permalink
Merge "ensure libguestfs mounts are cleaned up" into stable/essex
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jul 31, 2012
2 parents 2d053e9 + 3b4ac31 commit 6c05f43
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions nova/virt/disk/guestfs.py
Expand Up @@ -17,6 +17,7 @@

import os

from nova import exception
from nova import utils
from nova.virt.disk import mount

Expand Down Expand Up @@ -88,9 +89,18 @@ def mnt_dev(self):
def unmnt_dev(self):
if not self.mounted:
return
# root users don't need a specific unmnt_dev()
# but ordinary users do
utils.execute('fusermount', '-u', self.mount_dir, run_as_root=True)
umount_cmd = ['fusermount', '-u', self.mount_dir]
try:
# We make a few attempts to work around other
# processes temporarily scanning the mount_dir etc.
utils.execute(*umount_cmd, attempts=5, run_as_root=True)
except exception.ProcessExecutionError:
# If we still can't umount, then do a lazy umount
# (in the background), so that mounts might eventually
# be cleaned up. Note we'll wait 10s below for the umount to
# complete, after which we'll raise an exception.
umount_cmd.insert(1, '-z')
utils.execute(*umount_cmd, run_as_root=True)

# Unfortunately FUSE has an issue where it doesn't wait
# for processes associated with the mount to terminate.
Expand Down

0 comments on commit 6c05f43

Please sign in to comment.