qubes: Fix "unify event names"

This commit is contained in:
Wojtek Porczyk 2016-03-14 22:16:52 +01:00
parent 6c62559e86
commit d766b8e110
6 changed files with 23 additions and 23 deletions

View File

@ -473,6 +473,7 @@ class VMCollection(object):
def __delitem__(self, key): def __delitem__(self, key):
vm = self[key] vm = self[key]
self.app.fire_event_pre('domain-pre-delete', vm)
del self._dict[vm.qid] del self._dict[vm.qid]
self.app.fire_event('domain-delete', vm) self.app.fire_event('domain-delete', vm)
@ -1449,7 +1450,7 @@ class Qubes(PropertyHolder):
raise KeyError(label) raise KeyError(label)
@qubes.events.handler('domain-pre-deleted') @qubes.events.handler('domain-pre-delete')
def on_domain_pre_deleted(self, event, vm): def on_domain_pre_deleted(self, event, vm):
# pylint: disable=unused-argument # pylint: disable=unused-argument
if isinstance(vm, qubes.vm.templatevm.TemplateVM): if isinstance(vm, qubes.vm.templatevm.TemplateVM):
@ -1461,7 +1462,7 @@ class Qubes(PropertyHolder):
vm.name for name in sorted(appvms)))) vm.name for name in sorted(appvms))))
@qubes.events.handler('domain-deleted') @qubes.events.handler('domain-delete')
def on_domain_deleted(self, event, vm): def on_domain_deleted(self, event, vm):
# pylint: disable=unused-argument # pylint: disable=unused-argument
for propname in ( for propname in (

View File

@ -31,8 +31,8 @@ import qubes.config
import qubes.ext import qubes.ext
class GUI(qubes.ext.Extension): class GUI(qubes.ext.Extension):
@qubes.ext.handler('domain-start', 'domain-cmd-pre-start') @qubes.ext.handler('domain-start', 'domain-cmd-pre-run')
def start_guid(self, vm, start_guid, preparing_dvm=False, def start_guid(self, vm, event, preparing_dvm=False, start_guid=True,
extra_guid_args=None, **kwargs): extra_guid_args=None, **kwargs):
'''Launch gui daemon. '''Launch gui daemon.
@ -78,7 +78,7 @@ class GUI(qubes.ext.Extension):
@qubes.ext.handler('monitor-layout-change') @qubes.ext.handler('monitor-layout-change')
def on_monitor_layout_change(self, vm, monitor_layout): def on_monitor_layout_change(self, vm, event, monitor_layout):
# pylint: disable=no-self-use # pylint: disable=no-self-use
if vm.features.check_with_template('no-monitor-layout', False) \ if vm.features.check_with_template('no-monitor-layout', False) \
or not vm.is_running(): or not vm.is_running():

View File

@ -46,8 +46,8 @@ class R3Compatibility(qubes.ext.Extension):
} }
# noinspection PyUnusedLocal # noinspection PyUnusedLocal
@qubes.ext.handler('qdb-created') @qubes.ext.handler('domain-qdb-create')
def on_qdb_created(self, vm, event): def on_domain_qdb_create(self, vm, event):
""" """
:param vm: VM on which QubesDB entries were just created :param vm: VM on which QubesDB entries were just created
:type vm: qubes.vm.qubesvm.QubesVM :type vm: qubes.vm.qubesvm.QubesVM
@ -118,7 +118,7 @@ class R3Compatibility(qubes.ext.Extension):
self.write_services(vm) self.write_services(vm)
# FIXME use event after creating Xen domain object, but before "resume" # FIXME use event after creating Xen domain object, but before "resume"
@qubes.ext.handler('domain-started') @qubes.ext.handler('domain-start')
def on_domain_started(self, vm, event, **kwargs): def on_domain_started(self, vm, event, **kwargs):
if vm.netvm: if vm.netvm:
self.write_iptables_qubesdb_entry(vm.netvm) self.write_iptables_qubesdb_entry(vm.netvm)

View File

@ -15,7 +15,7 @@ class AppVM(qubes.vm.qubesvm.QubesVM):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(AppVM, self).__init__(*args, **kwargs) super(AppVM, self).__init__(*args, **kwargs)
@qubes.events.handler('domain-loaded') @qubes.events.handler('domain-load')
def on_domain_loaded(self, event): def on_domain_loaded(self, event):
# pylint: disable=unused-argument # pylint: disable=unused-argument
# Some additional checks for template based VM # Some additional checks for template based VM

View File

@ -138,13 +138,17 @@ class NetVMMixin(object):
super(NetVMMixin, self).__init__(*args, **kwargs) super(NetVMMixin, self).__init__(*args, **kwargs)
@qubes.events.handler('domain-started') @qubes.events.handler('domain-start')
def start_net(self): def on_domain_started(self, event, **kwargs):
'''Connect this domain to its downstream domains. '''Connect this domain to its downstream domains. Also reload firewall
in its netvm.
This is needed when starting netvm *after* its connected domains. This is needed when starting netvm *after* its connected domains.
''' '''
if self.netvm:
self.netvm.reload_firewall_for_vm(self)
for vm in self.connected_vms: for vm in self.connected_vms:
if not vm.is_running(): if not vm.is_running():
continue continue
@ -165,7 +169,7 @@ class NetVMMixin(object):
vm.log.warning('Cannot attach network', exc_info=1) vm.log.warning('Cannot attach network', exc_info=1)
@qubes.events.handler('pre-domain-shutdown') @qubes.events.handler('domain-pre-shutdown')
def shutdown_net(self, force=False): def shutdown_net(self, force=False):
connected_vms = [vm for vm in self.connected_vms if vm.is_running()] connected_vms = [vm for vm in self.connected_vms if vm.is_running()]
if connected_vms and not force: if connected_vms and not force:
@ -296,17 +300,12 @@ class NetVMMixin(object):
# FIXME handle in the above event? # FIXME handle in the above event?
new_netvm.reload_firewall_for_vm(self) new_netvm.reload_firewall_for_vm(self)
@qubes.events.handler('qdb-created') @qubes.events.handler('domain-qdb-create')
def on_qdb_created(self, event): def on_domain_qdb_create(self, event):
# TODO: fill firewall QubesDB entries (QubesOS/qubes-issues#1815) # TODO: fill firewall QubesDB entries (QubesOS/qubes-issues#1815)
pass pass
# FIXME use event after creating Xen domain object, but before "resume" # FIXME use event after creating Xen domain object, but before "resume"
@qubes.events.handler('domain-started')
def on_domain_started(self, event, **kwargs):
if self.netvm:
self.netvm.reload_firewall_for_vm(self)
@qubes.events.handler('firewall-changed') @qubes.events.handler('firewall-changed')
def on_firewall_changed(self, event): def on_firewall_changed(self, event):
if self.is_running() and self.netvm: if self.is_running() and self.netvm:

View File

@ -477,7 +477,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
# event handlers # event handlers
# #
@qubes.events.handler('domain-init', 'domain-loaded') @qubes.events.handler('domain-init', 'domain-load')
def on_domain_init_loaded(self, event): def on_domain_init_loaded(self, event):
# pylint: disable=unused-argument # pylint: disable=unused-argument
if not hasattr(self, 'uuid'): if not hasattr(self, 'uuid'):
@ -557,7 +557,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
'Failed to set autostart for VM via systemctl') 'Failed to set autostart for VM via systemctl')
@qubes.events.handler('device-pre-attached:pci') @qubes.events.handler('device-pre-attach:pci')
def on_device_pre_attached_pci(self, event, pci): def on_device_pre_attached_pci(self, event, pci):
# pylint: disable=unused-argument # pylint: disable=unused-argument
if not os.path.exists('/sys/bus/pci/devices/0000:{}'.format(pci)): if not os.path.exists('/sys/bus/pci/devices/0000:{}'.format(pci)):
@ -577,7 +577,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
' changes will be seen after VM restart.'.format(pci), e) ' changes will be seen after VM restart.'.format(pci), e)
@qubes.events.handler('device-pre-detached:pci') @qubes.events.handler('device-pre-detach:pci')
def on_device_pre_detached_pci(self, event, pci): def on_device_pre_detached_pci(self, event, pci):
# pylint: disable=unused-argument # pylint: disable=unused-argument
if not self.is_running(): if not self.is_running():