Additional check for qemu-nbd hang

/sys/block/*device*/pid check is not enough. I see that the unix
socket used by the device my be stuck as well, so let's add another
check for the path to the unix socket for the device as well to
figure out if the device is free. Complain loud and clear that the
qemu-nbd is leaking resources.

Change-Id: I28cedffba7a9915ef6f7888989e40e4d0de475c6
Closes-Bug: #973413
Partial-Bug: #1254890
This commit is contained in:
Davanum Srinivas 2014-01-14 19:29:46 -05:00 committed by Gerrit Code Review
parent f579affb50
commit a0891ad0af
1 changed files with 5 additions and 1 deletions

View File

@ -52,7 +52,11 @@ class NbdMount(api.Mount):
def _find_unused(self, devices):
for device in devices:
if not os.path.exists(os.path.join('/sys/block/', device, 'pid')):
return device
if not os.path.exists('/var/lock/qemu-nbd-%s' % device):
return device
else:
LOG.error(_('NBD error - previous umount did not cleanup '
'/var/lock/qemu-nbd-%s.'), device)
LOG.warn(_('No free nbd devices'))
return None