From bb4dc91ee87bef3e84e301614dfe03caca7d9ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 25 Nov 2016 02:04:09 +0100 Subject: [PATCH] storage/lvm: add workaround for ancient lvm2 in Travis-CI environment --- qubes/storage/lvm.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qubes/storage/lvm.py b/qubes/storage/lvm.py index 4f3a4b56..77d9995d 100644 --- a/qubes/storage/lvm.py +++ b/qubes/storage/lvm.py @@ -27,6 +27,17 @@ import subprocess import qubes +def check_lvm_version(): + #Check if lvm is very very old, like in Travis-CI + try: + lvm_help = subprocess.check_output(['lvm', 'lvcreate', '--help'], + stderr=subprocess.DEVNULL).decode() + return '--setactivationskip' not in lvm_help + except subprocess.CalledProcessError: + pass + +lvm_is_very_old = check_lvm_version() + class ThinPool(qubes.storage.Pool): ''' LVM Thin based pool implementation ''' # pylint: disable=protected-access @@ -437,6 +448,9 @@ def qubes_lvm(cmd, log=logging.getLogger('qube.storage.lvm')): lvm_cmd = ["lvextend", "-L%s" % size, cmd[1]] else: raise NotImplementedError('unsupported action: ' + action) + if lvm_is_very_old: + # old lvm in trusty image used there does not support -k option + lvm_cmd = [x for x in lvm_cmd if x != '-kn'] if os.getuid() != 0: cmd = ['sudo', 'lvm'] + lvm_cmd else: