core: fix handling uses_default_netvm property

- for netvm it doesn't make sense, but instead of removing it (which
        surely will break some code), make it always False
- when settings VM connections, uses_default_netvm is already loaded
- handle it properly during backup restore (really use default netvm,
        istead of assuming it's the same as during backup)
This commit is contained in:
Marek Marczykowski-Górecki 2016-07-17 03:52:40 +02:00
parent 6ccae83956
commit 6068c7bc50
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
3 changed files with 7 additions and 7 deletions

View File

@ -42,6 +42,7 @@ class QubesNetVm(QubesVm):
attrs_config['dir_path']['func'] = \
lambda value: value if value is not None else \
os.path.join(system_path["qubes_servicevms_dir"], self.name)
attrs_config['uses_default_netvm']['func'] = lambda x: False
attrs_config['label']['default'] = defaults["servicevm_label"]
attrs_config['memory']['default'] = 300

View File

@ -1706,7 +1706,11 @@ def restore_info_verify(restore_info, host_collection):
# check netvm
vm_info.pop('missing-netvm', None)
if vm_info['netvm']:
if vm_info['vm'].uses_default_netvm:
default_netvm = host_collection.get_default_netvm()
vm_info['netvm'] = default_netvm.name if \
default_netvm else None
elif vm_info['netvm']:
netvm_name = vm_info['netvm']
netvm_on_host = host_collection.get_vm_by_name(netvm_name)

View File

@ -713,18 +713,13 @@ class QubesVmCollection(dict):
def set_netvm_dependency(self, element):
kwargs = {}
attr_list = ("qid", "uses_default_netvm", "netvm_qid")
attr_list = ("qid", "netvm_qid")
for attribute in attr_list:
kwargs[attribute] = element.get(attribute)
vm = self[int(kwargs["qid"])]
if "uses_default_netvm" not in kwargs:
vm.uses_default_netvm = True
else:
vm.uses_default_netvm = (
True if kwargs["uses_default_netvm"] == "True" else False)
if vm.uses_default_netvm is True:
if vm.is_proxyvm():
netvm = self.get_default_fw_netvm()