qubes/vm/qubesvm: fix log initialisation
This commit is contained in:
parent
9da5ae8169
commit
12329e7b35
@ -1193,6 +1193,7 @@ class Qubes(PropertyHolder):
|
|||||||
cls = qubes.vm.BaseVM.register[node.get('class')]
|
cls = qubes.vm.BaseVM.register[node.get('class')]
|
||||||
vm = cls(self, node)
|
vm = cls(self, node)
|
||||||
vm.load_properties(load_stage=2)
|
vm.load_properties(load_stage=2)
|
||||||
|
vm.init_log()
|
||||||
self.domains.add(vm)
|
self.domains.add(vm)
|
||||||
|
|
||||||
if not 0 in self.domains:
|
if not 0 in self.domains:
|
||||||
|
@ -86,7 +86,8 @@ def get_vm_logger(vmname):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
logger = logging.getLogger('vm.' + 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)
|
handler.setFormatter(formatter_log)
|
||||||
logger.addHandler(handler)
|
logger.addHandler(handler)
|
||||||
|
|
||||||
|
@ -51,6 +51,8 @@ except libvirt.libvirtError:
|
|||||||
try:
|
try:
|
||||||
in_git = subprocess.check_output(
|
in_git = subprocess.check_output(
|
||||||
['git', 'rev-parse', '--show-toplevel']).strip()
|
['git', 'rev-parse', '--show-toplevel']).strip()
|
||||||
|
qubes.log.LOGPATH = '/tmp'
|
||||||
|
qubes.log.LOGFILE = '/tmp/qubes.log'
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
# git returned nonzero, we are outside git repo
|
# git returned nonzero, we are outside git repo
|
||||||
pass
|
pass
|
||||||
|
@ -197,6 +197,9 @@ class BaseVM(qubes.PropertyHolder):
|
|||||||
#: logger instance for logging messages related to this VM
|
#: logger instance for logging messages related to this VM
|
||||||
self.log = None
|
self.log = None
|
||||||
|
|
||||||
|
if hasattr(self, 'name'):
|
||||||
|
self.init_log()
|
||||||
|
|
||||||
|
|
||||||
def init_log(self):
|
def init_log(self):
|
||||||
'''Initialise logger for this domain.'''
|
'''Initialise logger for this domain.'''
|
||||||
|
@ -628,6 +628,8 @@ class QubesVM(qubes.vm.BaseVM):
|
|||||||
@qubes.events.handler('property-set:name')
|
@qubes.events.handler('property-set:name')
|
||||||
def on_property_set_name(self, event, name, new_name, old_name=None):
|
def on_property_set_name(self, event, name, new_name, old_name=None):
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
|
self.init_log()
|
||||||
|
|
||||||
if self._libvirt_domain is not None:
|
if self._libvirt_domain is not None:
|
||||||
self.libvirt_domain.undefine()
|
self.libvirt_domain.undefine()
|
||||||
self._libvirt_domain = None
|
self._libvirt_domain = None
|
||||||
|
Loading…
Reference in New Issue
Block a user