diff --git a/qubes/__init__.py b/qubes/__init__.py index 4f148d44..bad38c68 100644 --- a/qubes/__init__.py +++ b/qubes/__init__.py @@ -547,7 +547,6 @@ class property(object): def __get__(self, instance, owner): -# sys.stderr.write('{!r}.__get__({}, {!r})\n'.format(self.__name__, hex(id(instance)), owner)) if instance is None: return self @@ -556,12 +555,10 @@ class property(object): raise AttributeError( 'qubes.property should be used on qubes.PropertyHolder instances only') -# sys.stderr.write(' __get__ try\n') try: return getattr(instance, self._attr_name) except AttributeError: -# sys.stderr.write(' __get__ except\n') if self._default is self._NO_DEFAULT: raise AttributeError('property {!r} not set'.format(self.__name__)) elif isinstance(self._default, collections.Callable): @@ -761,7 +758,6 @@ class PropertyHolder(qubes.events.Emitter): :type load_stage: :py:func:`int` or :py:obj:`None` ''' -# sys.stderr.write('{!r}.get_props_list(load_stage={})\n'.format('self', load_stage)) props = set() for class_ in cls.__mro__: props.update(prop for prop in class_.__dict__.values() @@ -769,7 +765,6 @@ class PropertyHolder(qubes.events.Emitter): if load_stage is not None: props = set(prop for prop in props if prop.load_stage == load_stage) -# sys.stderr.write(' props={!r}\n'.format(props)) return sorted(props, key=lambda prop: (prop.load_stage, prop.order, prop.__name__)) @@ -829,16 +824,12 @@ class PropertyHolder(qubes.events.Emitter): :param lxml.etree._Element xml: XML node reference ''' -# sys.stderr.write('<{}>.load_properties(load_stage={}) xml={!r}\n'.format(hex(id(self)), load_stage, self.xml)) - self.events_enabled = False all_names = set(prop.__name__ for prop in self.get_props_list(load_stage)) -# sys.stderr.write(' all_names={!r}\n'.format(all_names)) for node in self.xml.xpath('./properties/property'): name = node.get('name') value = node.get('ref') or node.text -# sys.stderr.write(' load_properties name={!r} value={!r}\n'.format(name, value)) if not name in all_names: raise AttributeError( 'No property {!r} found in {!r}'.format( @@ -848,7 +839,6 @@ class PropertyHolder(qubes.events.Emitter): self.events_enabled = True self.fire_event('property-loaded') -# sys.stderr.write(' load_properties return\n') def save_properties(self, with_defaults=False): @@ -857,7 +847,6 @@ class PropertyHolder(qubes.events.Emitter): :param bool with_defaults: If :py:obj:`True`, then it also includes properties which were not set explicite, but have default values filled. ''' -# sys.stderr.write('{!r}.save_properties(with_defaults={})\n'.format(self, with_defaults)) properties = lxml.etree.Element('properties') @@ -865,7 +854,6 @@ class PropertyHolder(qubes.events.Emitter): try: value = getattr(self, (prop.__name__ if with_defaults else prop._attr_name)) except AttributeError, e: -# sys.stderr.write('AttributeError: {!s}\n'.format(e)) continue try: diff --git a/qubes/config.py b/qubes/config.py index 7cbaa382..f35801f0 100644 --- a/qubes/config.py +++ b/qubes/config.py @@ -4,7 +4,7 @@ # The Qubes OS Project, http://www.qubes-os.org # # Copyright (C) 2010 Joanna Rutkowska -# Copyright (C) 2014 Wojtek Porczyk +# Copyright (C) 2014 Wojtek Porczyk # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License diff --git a/qubes/utils.py b/qubes/utils.py index 5792d588..ba0a20ed 100644 --- a/qubes/utils.py +++ b/qubes/utils.py @@ -23,8 +23,7 @@ # -# FIXME: should be outside of QubesVM? -def get_timezone(self): +def get_timezone(): # fc18 if os.path.islink('/etc/localtime'): return '/'.join(os.readlink('/etc/localtime').split('/')[-2:]) diff --git a/qubes/vm/__init__.py b/qubes/vm/__init__.py index a98d296b..ab31e78a 100644 --- a/qubes/vm/__init__.py +++ b/qubes/vm/__init__.py @@ -586,9 +586,13 @@ class BaseVM(qubes.PropertyHolder): conf["rules"].append(rule) except EnvironmentError as err: + # problem accessing file, like ENOTFOUND, EPERM or sth + # return default config return conf + except (xml.parsers.expat.ExpatError, ValueError, LookupError) as err: + # config is invalid print("{0}: load error: {1}".format( os.path.basename(sys.argv[0]), err)) return None diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index d9b46dad..25d50cea 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -416,7 +416,7 @@ class QubesVM(qubes.vm.BaseVM): self.maxmem = total_mem_mb/2 # Linux specific cap: max memory can't scale beyond 10.79*init_mem - # XXX what?! -woju + # see https://groups.google.com/forum/#!topic/qubes-devel/VRqkFj1IOtA if self.maxmem > self.memory * 10: self.maxmem = self.memory * 10 @@ -447,7 +447,6 @@ class QubesVM(qubes.vm.BaseVM): # event handlers # - @qubes.events.handler('property-set:label') def on_property_set_label(self, event, name, new_label, old_label=None): if self.icon_path: @@ -557,6 +556,7 @@ class QubesVM(qubes.vm.BaseVM): return try: + # TODO: libvirt-ise subprocess.check_call(['sudo', system_path["qubes_pciback_cmd"], pci]) subprocess.check_call(['sudo', 'xl', 'pci-attach', str(self.xid), pci]) except Exception as e: @@ -569,6 +569,7 @@ class QubesVM(qubes.vm.BaseVM): if not self.is_running(): return + # TODO: libvirt-ise p = subprocess.Popen(['xl', 'pci-list', str(self.xid)], stdout=subprocess.PIPE) result = p.communicate() @@ -802,6 +803,8 @@ class QubesVM(qubes.vm.BaseVM): args += ["-t"] if os.isatty(sys.stderr.fileno()): args += ["-T"] + + # TODO: QSB#13 if passio: if os.name == 'nt': # wait for qrexec-client to exit, otherwise client is not properly attached to console @@ -854,6 +857,7 @@ class QubesVM(qubes.vm.BaseVM): source = 'dom0' if source is None else self.app.domains[source].name + # XXX TODO FIXME this looks bad... if input: return self.run("QUBESRPC %s %s" % (service, source), localcmd="echo %s" % input, user=user, wait=True)