From e5de8f4115d5edc76179282d1a03c7a8706f412e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 3 Jul 2017 23:08:04 +0200 Subject: [PATCH] devices: better handle exceptions in device extension Do not fail app.save() just because listing devices failed, for any reason. --- qubes/devices.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/qubes/devices.py b/qubes/devices.py index b4d166d2..a3f9783e 100644 --- a/qubes/devices.py +++ b/qubes/devices.py @@ -241,8 +241,17 @@ class DeviceCollection(object): attached persistently. ''' - devices = self._vm.fire_event('device-list-attached:' + self._bus, - persistent=persistent) + try: + devices = self._vm.fire_event('device-list-attached:' + self._bus, + persistent=persistent) + except Exception as e: # pylint: disable=broad-except + self._vm.log.exception(e, 'Failed to list {} devices'.format( + self._bus)) + if persistent is True: + # don't break app.save() + return self._set + else: + raise result = set() for dev, options in devices: if dev in self._set and not persistent: