Handle return code 2 from blkid calls

blkid returns code 2 if the requested TYPE key is not found
for the specified device.

Ensure that this situation is handled correctly; blkid will
not return any data, so the return value will be empty.

Change-Id: I38cd7b53cdfd694c0eba1b6054d8e4c33759b0b8
Closes-Bug: #1426324
(cherry picked from commit 051fced477)
This commit is contained in:
James Page 2015-02-27 11:27:30 +00:00
parent 08d0b08ce8
commit 1b941f1d61
2 changed files with 4 additions and 2 deletions

View File

@ -416,7 +416,8 @@ class VirtDiskVFSLocalFSTest(test.NoDBTestCase):
execute.assert_called_once_with('blkid', '-o',
'value', '-s',
'TYPE', '/dev/xyz',
run_as_root=True)
run_as_root=True,
check_exit_code=[0, 2])
@mock.patch.object(tempfile, 'mkdtemp')
@mock.patch.object(nova.virt.disk.mount.nbd, 'NbdMount')

View File

@ -164,6 +164,7 @@ class VFSLocalFS(vfs.VFS):
out, err = utils.execute('blkid', '-o',
'value', '-s',
'TYPE', self.mount.device,
run_as_root=True)
run_as_root=True,
check_exit_code=[0, 2])
return out.strip()
return ""