qubes/vm/qubesvm: fix log initialisation

This commit is contained in:
Wojtek Porczyk 2015-09-23 16:25:53 +02:00
parent 9da5ae8169
commit 12329e7b35
5 changed files with 10 additions and 1 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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

View File

@ -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.'''

View File

@ -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