From 33fecd90c1c532e09b8eb9f19f0f89a0b85ee232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 5 Oct 2016 01:58:11 +0200 Subject: [PATCH] qubes/backup: misc fixes Fix restoring ProxyVM and NetVM from core2. Use correct VM class. --- qubes/backup.py | 8 ++++---- qubes/core2migration.py | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/qubes/backup.py b/qubes/backup.py index 1109aa41..aeda2dde 100644 --- a/qubes/backup.py +++ b/qubes/backup.py @@ -2100,11 +2100,10 @@ class BackupRestore(object): "updbl": {"func": "'Yes' if vm.updateable else ''"}, - "template": {"func": "'n/a' if not hasattr(vm, 'template') is None " + "template": {"func": "'n/a' if not hasattr(vm, 'template') " "else vm_info.template"}, - "netvm": {"func": "'n/a' if vm.provides_network else\ - ('*' if vm.property_is_default('netvm') else '') +\ + "netvm": {"func": "('*' if vm.property_is_default('netvm') else '') +\ vm_info.netvm if vm_info.netvm is not None " "else '-'"}, @@ -2409,8 +2408,9 @@ class BackupRestore(object): try: # first only minimal set, later clone_properties # will be called + cls = self.app.get_vm_class(vm.__class__.__name__) new_vm = self.app.add_new_vm( - vm.__class__, + cls, name=vm_name, label=vm.label, installed_by_rpm=False, diff --git a/qubes/core2migration.py b/qubes/core2migration.py index bea22ac7..8ddd943d 100644 --- a/qubes/core2migration.py +++ b/qubes/core2migration.py @@ -180,6 +180,10 @@ class Core2Qubes(qubes.Qubes): "true": kwargs[attr] = value kwargs['hvm'] = "HVm" in vm_class_name + kwargs['provides_network'] = \ + vm_class_name in ('QubesNetVm', 'QubesProxyVm') + if vm_class_name == 'QubesNetVm': + kwargs['netvm'] = None vm = self.add_new_vm(vm_class, qid=int(element.get('qid')), **kwargs) services = element.get('services')