From 8037182dcd38dff82f59de396f6af077716364e7 Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Sat, 6 Aug 2016 17:01:31 +0200 Subject: [PATCH 1/7] qvm-start --debug don't catch exceptions --- qubes/tools/qvm_start.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qubes/tools/qvm_start.py b/qubes/tools/qvm_start.py index 4054265a..ab3106f3 100644 --- a/qubes/tools/qvm_start.py +++ b/qubes/tools/qvm_start.py @@ -133,13 +133,17 @@ def main(args=None): if args.debug: vm.debug = args.debug - try: + if args.debug: vm.start( preparing_dvm=args.preparing_dvm, start_guid=args.start_guid) - except qubes.exc.QubesException as e: - parser.error_runtime('Qubes error: {!r}'.format(e)) - + else: + try: + vm.start( + preparing_dvm=args.preparing_dvm, + start_guid=args.start_guid) + except qubes.exc.QubesException as e: + parser.error_runtime('Qubes error: {!r}'.format(e)) return 0 From b712d0f6f3d5b0b6829d12f8de4e6f5ae91c65cc Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Fri, 12 Aug 2016 21:08:00 +0200 Subject: [PATCH 2/7] Remove unexpected property --- qubes/vm/mix/net.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qubes/vm/mix/net.py b/qubes/vm/mix/net.py index 03b4b13e..a2a318df 100644 --- a/qubes/vm/mix/net.py +++ b/qubes/vm/mix/net.py @@ -164,7 +164,7 @@ class NetVMMixin(qubes.events.Emitter): pass try: - vm.attach_network(wait=False) + vm.attach_network() except qubes.exc.QubesException: vm.log.warning('Cannot attach network', exc_info=1) From c0f1a6b4e86a6c7f907a4288b5d5ae34f3a01c4e Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Tue, 16 Aug 2016 19:18:19 +0200 Subject: [PATCH 3/7] qvm-block & qvm-pool add better Exception handling --- qubes/tools/qvm_block.py | 9 +++++++-- qubes/tools/qvm_pool.py | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/qubes/tools/qvm_block.py b/qubes/tools/qvm_block.py index 855370c2..76bfe1e9 100644 --- a/qubes/tools/qvm_block.py +++ b/qubes/tools/qvm_block.py @@ -228,8 +228,13 @@ def get_parser(): def main(args=None): '''Main routine of :program:`qvm-block`.''' - args = get_parser().parse_args(args) - args.func(args) + parser = get_parser() + try: + args = parser.parse_args(args) + args.func(args) + except qubes.exc.QubesException as e: + parser.print_error(e.message) + return 1 if __name__ == '__main__': diff --git a/qubes/tools/qvm_pool.py b/qubes/tools/qvm_pool.py index 0444d56d..ca289f6d 100644 --- a/qubes/tools/qvm_pool.py +++ b/qubes/tools/qvm_pool.py @@ -187,7 +187,12 @@ def main(args=None): command line. ''' parser = get_parser() - args = parser.parse_args(args) + try: + args = parser.parse_args(args) + except qubes.exc.QubesException as e: + parser.print_error(e.message) + return 1 + if args.command is None or args.command == 'list': list_pools(args.app) elif args.command == 'add': From e0bf4bdb8e5c9f46e2640ed455df43012b5e660e Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Tue, 16 Aug 2016 19:21:10 +0200 Subject: [PATCH 4/7] Fix qvm-create lvm based AppVM --- qubes/storage/lvm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qubes/storage/lvm.py b/qubes/storage/lvm.py index 5aad339a..b4bc83a3 100644 --- a/qubes/storage/lvm.py +++ b/qubes/storage/lvm.py @@ -43,7 +43,7 @@ class ThinPool(qubes.storage.Pool): self.log = logging.getLogger('qube.storage.lvm.%s' % self._pool_id) def clone(self, source, target): - cmd = ['clone', source.vid, target.vid] + cmd = ['clone', str(source), str(target)] qubes_lvm(cmd, self.log) return target From 24bbc971b037fd99afaaa83692fd38354e855c6c Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Sun, 28 Aug 2016 23:56:06 +0200 Subject: [PATCH 5/7] qubes.storage.lvm.qubes_lvm use debug not info --- qubes/storage/lvm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qubes/storage/lvm.py b/qubes/storage/lvm.py index b4bc83a3..eae0e2cd 100644 --- a/qubes/storage/lvm.py +++ b/qubes/storage/lvm.py @@ -342,7 +342,7 @@ def qubes_lvm(cmd, log=logging.getLogger('qube.storage.lvm')): out, err = p.communicate() return_code = p.returncode if out: - log.info(out) + log.debug(out) if return_code == 0 and err: log.warning(err) elif return_code != 0: From 355ea0c2a8cc390c34b9309fe6e20232463b84cd Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Sun, 28 Aug 2016 23:52:27 +0200 Subject: [PATCH 6/7] Fix lvm AppVM startup from lvm --- qubes/storage/lvm.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qubes/storage/lvm.py b/qubes/storage/lvm.py index eae0e2cd..1ecae93b 100644 --- a/qubes/storage/lvm.py +++ b/qubes/storage/lvm.py @@ -217,8 +217,10 @@ class ThinPool(qubes.storage.Pool): def stop(self, volume): if volume.save_on_stop: self._commit(volume) - - if volume._is_volatile: + if volume._is_snapshot: + cmd = ['remove', volume._vid_snap] + qubes_lvm(cmd, self.log) + elif volume._is_volatile: cmd = ['remove', volume.vid] qubes_lvm(cmd, self.log) else: @@ -227,6 +229,12 @@ class ThinPool(qubes.storage.Pool): return volume def _snapshot(self, volume): + try: + cmd = ['remove', volume._vid_snap] + qubes_lvm(cmd, self.log) + except: + pass + if volume.source is None: cmd = ['clone', volume.vid, volume._vid_snap] else: From e4433f9a658e37041c80a9c25e66ddaf28806a0a Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Fri, 2 Sep 2016 20:16:03 +0200 Subject: [PATCH 7/7] =?UTF-8?q?Make=20pylint=20happy=20=E2=99=A5=20qubes.s?= =?UTF-8?q?torage.lvm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qubes/storage/lvm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qubes/storage/lvm.py b/qubes/storage/lvm.py index 1ecae93b..794ded7e 100644 --- a/qubes/storage/lvm.py +++ b/qubes/storage/lvm.py @@ -232,7 +232,7 @@ class ThinPool(qubes.storage.Pool): try: cmd = ['remove', volume._vid_snap] qubes_lvm(cmd, self.log) - except: + except: # pylint: disable=bare-except pass if volume.source is None: