app: fix setting default_*netvm

1. Fire both property-pre-del:netvm and property-del:netvm - those
events should be fired in pairs - especially one may assume the other
will be called too. This is the case here - one disconnect old netvm,
the other connect the new one.

2. Remove spurious 'newvalue' argument for property-del:netvm event.

3. Fix logic for default_fw_netvm/default_netvm usage. The former is
used if vm.provides_network=True.
This commit is contained in:
Marek Marczykowski-Górecki 2017-10-21 03:06:30 +02:00
parent 4500c4dcab
commit 0b1a0b028b
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -1250,11 +1250,14 @@ class Qubes(qubes.PropertyHolder):
oldvalue=None):
# pylint: disable=unused-argument,invalid-name
for vm in self.domains:
if not vm.provides_network and vm.property_is_default('netvm'):
if hasattr(vm, 'provides_network') and vm.provides_network and \
hasattr(vm, 'netvm') and vm.property_is_default('netvm'):
# fire property-del: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',
name='netvm', newvalue=newvalue, oldvalue=oldvalue)
name='netvm', oldvalue=oldvalue)
@qubes.events.handler('property-set:default_netvm')
@ -1262,8 +1265,11 @@ class Qubes(qubes.PropertyHolder):
oldvalue=None):
# pylint: disable=unused-argument
for vm in self.domains:
if hasattr(vm, 'netvm') and vm.property_is_default('netvm'):
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
# 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',
name='netvm', oldvalue=oldvalue)