storage/lvm: make sure that volumes have /dev entries when export() is called

In some cases (even manual manipulation) those files may not be present
- especially because thin snapshots do not have nodes in /dev by default.
This commit is contained in:
Marek Marczykowski-Górecki 2017-07-29 04:42:19 +02:00
parent 27ce27b6e9
commit 46bfa14d08
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -121,7 +121,7 @@ class ThinPool(qubes.storage.Pool):
return volumes
def init_cache(log=logging.getLogger('qube.storage.lvm')):
def init_cache(log=logging.getLogger('qubes.storage.lvm')):
cmd = ['lvs', '--noheadings', '-o',
'vg_name,pool_lv,name,lv_size,data_percent,lv_attr,origin',
'--units', 'b', '--separator', ',']
@ -291,6 +291,8 @@ class ThinVolume(qubes.storage.Volume):
def export(self):
''' Returns an object that can be `open()`. '''
# make sure the device node is available
qubes_lvm(['activate', self.vid], self.log)
devpath = '/dev/' + self.vid
return devpath
@ -464,6 +466,8 @@ def qubes_lvm(cmd, log=logging.getLogger('qubes.storage.lvm')):
elif action == 'extend':
size = int(cmd[2]) / (1000 * 1000)
lvm_cmd = ["lvextend", "-L%s" % size, cmd[1]]
elif action == 'activate':
lvm_cmd = ['lvchange', '-ay', cmd[1]]
else:
raise NotImplementedError('unsupported action: ' + action)
if lvm_is_very_old: