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?).
This commit is contained in:
Marek Marczykowski-Górecki 2013-07-22 04:40:24 +02:00
parent bc58ca5edb
commit a8bee8d978

View File

@ -42,7 +42,10 @@ dry_run = False
if not dry_run: if not dry_run:
import libvirt import libvirt
try:
import xen.lowlevel.xs import xen.lowlevel.xs
except ImportError:
pass
qubes_base_dir = "/var/lib/qubes" qubes_base_dir = "/var/lib/qubes"
@ -138,6 +141,7 @@ class QubesVMMConnection(object):
# Do not initialize in offline mode # Do not initialize in offline mode
return return
if 'xen.lowlevel.xs' in sys.modules:
self._xs = xen.lowlevel.xs.xs() self._xs = xen.lowlevel.xs.xs()
self._libvirt_conn = libvirt.open(defaults['libvirt_uri']) self._libvirt_conn = libvirt.open(defaults['libvirt_uri'])
if self._libvirt_conn == None: if self._libvirt_conn == None:
@ -160,7 +164,10 @@ class QubesVMMConnection(object):
@property @property
def xs(self): def xs(self):
if 'xen.lowlevel.xs' in sys.modules:
return self._common_getter('_xs') return self._common_getter('_xs')
else:
return None
##### VMM global variable definition ##### ##### VMM global variable definition #####