vm/net: fix handling netvm reset to default

If there was some netvm set, unset it first (same as with ordinary set).
Otherwise it will try to attach new netvm without detaching the old one
first.
This commit is contained in:
Marek Marczykowski-Górecki 2017-10-20 02:05:49 +02:00
parent 98818b0ad9
commit 9a9452ae3a
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -317,6 +317,17 @@ class NetVMMixin(qubes.events.Emitter):
self.untrusted_qdb.rm(mapped_ip_base + '/visible-gateway')
@qubes.events.handler('property-pre-del:netvm')
def on_property_pre_del_netvm(self, event, name, oldvalue=None):
''' Sets the the NetVM to default NetVM '''
# pylint: disable=unused-argument
# we are changing to default netvm
newvalue = type(self).netvm.get_default(self)
if newvalue == oldvalue:
return
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):
''' Sets the the NetVM to default NetVM '''