Convert handler to use property-reset instead of property-del
There was also one case of triggering property-{del => reset} synthetically on default value change. Adjust it too and drop -pre- event call in that case. QubesOS/qubes-issues#5834
This commit is contained in:
parent
4e473dd190
commit
dc2cf1db5d
@ -1530,9 +1530,7 @@ class Qubes(qubes.PropertyHolder):
|
||||
for vm in self.domains:
|
||||
if hasattr(vm, 'provides_network') and not vm.provides_network and \
|
||||
hasattr(vm, 'netvm') and vm.property_is_default('netvm'):
|
||||
# fire property-del:netvm as it is responsible for resetting
|
||||
# fire property-reset:netvm as it is responsible for resetting
|
||||
# netvm to it's default value
|
||||
vm.fire_event('property-pre-del:netvm', pre_event=True,
|
||||
name='netvm', oldvalue=oldvalue)
|
||||
vm.fire_event('property-del:netvm',
|
||||
vm.fire_event('property-reset:netvm',
|
||||
name='netvm', oldvalue=oldvalue)
|
||||
|
@ -48,9 +48,8 @@ class AUDIO(qubes.ext.Extension):
|
||||
self.on_property_set(vm, event, name='audiovm',
|
||||
newvalue=vm.audiovm)
|
||||
|
||||
# property-del <=> property-reset-to-default
|
||||
@qubes.ext.handler('property-del:audiovm')
|
||||
def on_property_del(self, subject, event, name, oldvalue=None):
|
||||
@qubes.ext.handler('property-reset:audiovm')
|
||||
def on_property_reset(self, subject, event, name, oldvalue=None):
|
||||
newvalue = getattr(subject, 'audiovm', None)
|
||||
self.on_property_set(subject, event, name, newvalue, oldvalue)
|
||||
|
||||
|
@ -75,8 +75,8 @@ class CoreFeatures(qubes.ext.Extension):
|
||||
# pylint: disable=unused-argument
|
||||
self.set_servicevm_feature(subject)
|
||||
|
||||
@qubes.ext.handler('property-del:provides_network')
|
||||
def on_property_del(self, subject, event, name):
|
||||
@qubes.ext.handler('property-reset:provides_network')
|
||||
def on_property_reset(self, subject, event, name):
|
||||
# pylint: disable=unused-argument
|
||||
self.set_servicevm_feature(subject)
|
||||
|
||||
|
@ -58,9 +58,8 @@ class GUI(qubes.ext.Extension):
|
||||
if 'guivm-' + vm.guivm.name not in vm.tags:
|
||||
self.on_property_set(vm, event, name='guivm', newvalue=vm.guivm)
|
||||
|
||||
# property-del <=> property-reset-to-default
|
||||
@qubes.ext.handler('property-del:guivm')
|
||||
def on_property_del(self, subject, event, name, oldvalue=None):
|
||||
@qubes.ext.handler('property-reset:guivm')
|
||||
def on_property_reset(self, subject, event, name, oldvalue=None):
|
||||
newvalue = getattr(subject, 'guivm', None)
|
||||
self.on_property_set(subject, event, name, newvalue, oldvalue)
|
||||
|
||||
|
@ -329,8 +329,8 @@ class Rule(qubes.PropertyHolder):
|
||||
if newvalue not in ('icmp',):
|
||||
self.icmptype = qubes.property.DEFAULT
|
||||
|
||||
@qubes.events.handler('property-del:proto')
|
||||
def on_del_proto(self, event, name, oldvalue):
|
||||
@qubes.events.handler('property-reset:proto')
|
||||
def on_reset_proto(self, event, name, oldvalue):
|
||||
# pylint: disable=unused-argument
|
||||
self.dstports = qubes.property.DEFAULT
|
||||
self.icmptype = qubes.property.DEFAULT
|
||||
|
@ -112,8 +112,8 @@ class AppVM(qubes.vm.qubesvm.QubesVM):
|
||||
''' # pylint: disable=unused-argument
|
||||
assert self.template
|
||||
|
||||
@qubes.events.handler('property-pre-del:template')
|
||||
def on_property_pre_del_template(self, event, name, oldvalue=None):
|
||||
@qubes.events.handler('property-pre-reset:template')
|
||||
def on_property_pre_reset_template(self, event, name, oldvalue=None):
|
||||
'''Forbid deleting template of running VM
|
||||
''' # pylint: disable=unused-argument,no-self-use
|
||||
raise qubes.exc.QubesValueError('Cannot unset template')
|
||||
|
@ -134,7 +134,7 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
|
||||
assert self.template
|
||||
|
||||
@qubes.events.handler('property-pre-set:template',
|
||||
'property-pre-del:template')
|
||||
'property-pre-reset:template')
|
||||
def on_property_pre_set_template(self, event, name, newvalue=None,
|
||||
oldvalue=None):
|
||||
''' Disposable VM cannot have template changed '''
|
||||
|
@ -406,8 +406,8 @@ class NetVMMixin(qubes.events.Emitter):
|
||||
'/connected-ips6',
|
||||
' '.join(connected_ips6))
|
||||
|
||||
@qubes.events.handler('property-pre-del:netvm')
|
||||
def on_property_pre_del_netvm(self, event, name, oldvalue=None):
|
||||
@qubes.events.handler('property-pre-reset:netvm')
|
||||
def on_property_pre_reset_netvm(self, event, name, oldvalue=None):
|
||||
''' Sets the the NetVM to default NetVM '''
|
||||
# pylint: disable=unused-argument
|
||||
# we are changing to default netvm
|
||||
@ -419,8 +419,8 @@ class NetVMMixin(qubes.events.Emitter):
|
||||
self.fire_event('property-pre-set:netvm', pre_event=True,
|
||||
name='netvm', newvalue=newvalue, oldvalue=oldvalue)
|
||||
|
||||
@qubes.events.handler('property-del:netvm')
|
||||
def on_property_del_netvm(self, event, name, oldvalue=None):
|
||||
@qubes.events.handler('property-reset:netvm')
|
||||
def on_property_reset_netvm(self, event, name, oldvalue=None):
|
||||
''' Sets the the NetVM to default NetVM '''
|
||||
# pylint: disable=unused-argument
|
||||
# we are changing to default netvm
|
||||
|
@ -1006,8 +1006,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
||||
raise qubes.exc.QubesException(
|
||||
'Failed to set autostart for VM in systemd')
|
||||
|
||||
@qubes.events.handler('property-pre-del:autostart')
|
||||
def on_property_pre_del_autostart(self, event, name, oldvalue=None):
|
||||
@qubes.events.handler('property-pre-reset:autostart')
|
||||
def on_property_pre_reset_autostart(self, event, name, oldvalue=None):
|
||||
# pylint: disable=unused-argument
|
||||
if oldvalue:
|
||||
retcode = subprocess.call(
|
||||
|
Loading…
Reference in New Issue
Block a user