diff --git a/qubes/__init__.py b/qubes/__init__.py index 70476c99..40f37594 100644 --- a/qubes/__init__.py +++ b/qubes/__init__.py @@ -1193,6 +1193,7 @@ class Qubes(PropertyHolder): cls = qubes.vm.BaseVM.register[node.get('class')] vm = cls(self, node) vm.load_properties(load_stage=2) + vm.init_log() self.domains.add(vm) if not 0 in self.domains: diff --git a/qubes/log.py b/qubes/log.py index 82d9cc96..6494afb5 100644 --- a/qubes/log.py +++ b/qubes/log.py @@ -86,7 +86,8 @@ def get_vm_logger(vmname): ''' logger = logging.getLogger('vm.' + vmname) - handler = logging.FileHandler(os.path.join(LOGPATH, 'vm', vmname + '.log')) + handler = logging.FileHandler( + os.path.join(LOGPATH, 'vm-{}.log'.format(vmname))) handler.setFormatter(formatter_log) logger.addHandler(handler) diff --git a/qubes/tests/__init__.py b/qubes/tests/__init__.py index bb493f5f..a1a93852 100644 --- a/qubes/tests/__init__.py +++ b/qubes/tests/__init__.py @@ -51,6 +51,8 @@ except libvirt.libvirtError: try: in_git = subprocess.check_output( ['git', 'rev-parse', '--show-toplevel']).strip() + qubes.log.LOGPATH = '/tmp' + qubes.log.LOGFILE = '/tmp/qubes.log' except subprocess.CalledProcessError: # git returned nonzero, we are outside git repo pass diff --git a/qubes/vm/__init__.py b/qubes/vm/__init__.py index acf1cb49..41f83a10 100644 --- a/qubes/vm/__init__.py +++ b/qubes/vm/__init__.py @@ -197,6 +197,9 @@ class BaseVM(qubes.PropertyHolder): #: logger instance for logging messages related to this VM self.log = None + if hasattr(self, 'name'): + self.init_log() + def init_log(self): '''Initialise logger for this domain.''' diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index de4c96da..90c72ca0 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -628,6 +628,8 @@ class QubesVM(qubes.vm.BaseVM): @qubes.events.handler('property-set:name') def on_property_set_name(self, event, name, new_name, old_name=None): # pylint: disable=unused-argument + self.init_log() + if self._libvirt_domain is not None: self.libvirt_domain.undefine() self._libvirt_domain = None