From a8bee8d9782980a3eddc81bfb54424dca2c92608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 22 Jul 2013 04:40:24 +0200 Subject: [PATCH] Ignore error when 'xen.lowlevel.xs' doesn't exists There are still few uses of direct xenstore access, most of them are xen-specific (so doesn't need to be portable). For now simply don't connect to xenstore when no 'xen.lowlevel.xs' module present. It will break such xen-specific accesses - it must be somehow reworked - either by adding appropriate conditionals, or moving such code somewhere else (custom methods of libvirt driver?). --- core/qubes.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core/qubes.py b/core/qubes.py index ae562a4a..50fba25f 100755 --- a/core/qubes.py +++ b/core/qubes.py @@ -42,7 +42,10 @@ dry_run = False if not dry_run: import libvirt - import xen.lowlevel.xs + try: + import xen.lowlevel.xs + except ImportError: + pass qubes_base_dir = "/var/lib/qubes" @@ -138,7 +141,8 @@ class QubesVMMConnection(object): # Do not initialize in offline mode return - self._xs = xen.lowlevel.xs.xs() + if 'xen.lowlevel.xs' in sys.modules: + self._xs = xen.lowlevel.xs.xs() self._libvirt_conn = libvirt.open(defaults['libvirt_uri']) if self._libvirt_conn == None: raise QubesException("Failed connect to libvirt driver") @@ -160,7 +164,10 @@ class QubesVMMConnection(object): @property def xs(self): - return self._common_getter('_xs') + if 'xen.lowlevel.xs' in sys.modules: + return self._common_getter('_xs') + else: + return None ##### VMM global variable definition #####