qubes: Fix "unify event names"
This commit is contained in:
parent
6c62559e86
commit
d766b8e110
@ -473,6 +473,7 @@ class VMCollection(object):
|
||||
|
||||
def __delitem__(self, key):
|
||||
vm = self[key]
|
||||
self.app.fire_event_pre('domain-pre-delete', vm)
|
||||
del self._dict[vm.qid]
|
||||
self.app.fire_event('domain-delete', vm)
|
||||
|
||||
@ -1449,7 +1450,7 @@ class Qubes(PropertyHolder):
|
||||
raise KeyError(label)
|
||||
|
||||
|
||||
@qubes.events.handler('domain-pre-deleted')
|
||||
@qubes.events.handler('domain-pre-delete')
|
||||
def on_domain_pre_deleted(self, event, vm):
|
||||
# pylint: disable=unused-argument
|
||||
if isinstance(vm, qubes.vm.templatevm.TemplateVM):
|
||||
@ -1461,7 +1462,7 @@ class Qubes(PropertyHolder):
|
||||
vm.name for name in sorted(appvms))))
|
||||
|
||||
|
||||
@qubes.events.handler('domain-deleted')
|
||||
@qubes.events.handler('domain-delete')
|
||||
def on_domain_deleted(self, event, vm):
|
||||
# pylint: disable=unused-argument
|
||||
for propname in (
|
||||
|
@ -31,8 +31,8 @@ import qubes.config
|
||||
import qubes.ext
|
||||
|
||||
class GUI(qubes.ext.Extension):
|
||||
@qubes.ext.handler('domain-start', 'domain-cmd-pre-start')
|
||||
def start_guid(self, vm, start_guid, preparing_dvm=False,
|
||||
@qubes.ext.handler('domain-start', 'domain-cmd-pre-run')
|
||||
def start_guid(self, vm, event, preparing_dvm=False, start_guid=True,
|
||||
extra_guid_args=None, **kwargs):
|
||||
'''Launch gui daemon.
|
||||
|
||||
@ -78,7 +78,7 @@ class GUI(qubes.ext.Extension):
|
||||
|
||||
|
||||
@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
|
||||
if vm.features.check_with_template('no-monitor-layout', False) \
|
||||
or not vm.is_running():
|
||||
|
@ -46,8 +46,8 @@ class R3Compatibility(qubes.ext.Extension):
|
||||
}
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
@qubes.ext.handler('qdb-created')
|
||||
def on_qdb_created(self, vm, event):
|
||||
@qubes.ext.handler('domain-qdb-create')
|
||||
def on_domain_qdb_create(self, vm, event):
|
||||
"""
|
||||
:param vm: VM on which QubesDB entries were just created
|
||||
:type vm: qubes.vm.qubesvm.QubesVM
|
||||
@ -118,7 +118,7 @@ class R3Compatibility(qubes.ext.Extension):
|
||||
self.write_services(vm)
|
||||
|
||||
# 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):
|
||||
if vm.netvm:
|
||||
self.write_iptables_qubesdb_entry(vm.netvm)
|
||||
|
@ -15,7 +15,7 @@ class AppVM(qubes.vm.qubesvm.QubesVM):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AppVM, self).__init__(*args, **kwargs)
|
||||
|
||||
@qubes.events.handler('domain-loaded')
|
||||
@qubes.events.handler('domain-load')
|
||||
def on_domain_loaded(self, event):
|
||||
# pylint: disable=unused-argument
|
||||
# Some additional checks for template based VM
|
||||
|
@ -138,13 +138,17 @@ class NetVMMixin(object):
|
||||
super(NetVMMixin, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
@qubes.events.handler('domain-started')
|
||||
def start_net(self):
|
||||
'''Connect this domain to its downstream domains.
|
||||
@qubes.events.handler('domain-start')
|
||||
def on_domain_started(self, event, **kwargs):
|
||||
'''Connect this domain to its downstream domains. Also reload firewall
|
||||
in its netvm.
|
||||
|
||||
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:
|
||||
if not vm.is_running():
|
||||
continue
|
||||
@ -165,7 +169,7 @@ class NetVMMixin(object):
|
||||
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):
|
||||
connected_vms = [vm for vm in self.connected_vms if vm.is_running()]
|
||||
if connected_vms and not force:
|
||||
@ -296,17 +300,12 @@ class NetVMMixin(object):
|
||||
# FIXME handle in the above event?
|
||||
new_netvm.reload_firewall_for_vm(self)
|
||||
|
||||
@qubes.events.handler('qdb-created')
|
||||
def on_qdb_created(self, event):
|
||||
@qubes.events.handler('domain-qdb-create')
|
||||
def on_domain_qdb_create(self, event):
|
||||
# TODO: fill firewall QubesDB entries (QubesOS/qubes-issues#1815)
|
||||
pass
|
||||
|
||||
# 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')
|
||||
def on_firewall_changed(self, event):
|
||||
if self.is_running() and self.netvm:
|
||||
|
@ -477,7 +477,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
||||
# event handlers
|
||||
#
|
||||
|
||||
@qubes.events.handler('domain-init', 'domain-loaded')
|
||||
@qubes.events.handler('domain-init', 'domain-load')
|
||||
def on_domain_init_loaded(self, event):
|
||||
# pylint: disable=unused-argument
|
||||
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')
|
||||
|
||||
|
||||
@qubes.events.handler('device-pre-attached:pci')
|
||||
@qubes.events.handler('device-pre-attach:pci')
|
||||
def on_device_pre_attached_pci(self, event, pci):
|
||||
# pylint: disable=unused-argument
|
||||
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)
|
||||
|
||||
|
||||
@qubes.events.handler('device-pre-detached:pci')
|
||||
@qubes.events.handler('device-pre-detach:pci')
|
||||
def on_device_pre_detached_pci(self, event, pci):
|
||||
# pylint: disable=unused-argument
|
||||
if not self.is_running():
|
||||
|
Loading…
Reference in New Issue
Block a user