From 6ccae83956fcfc76e87a8486df01bfe5f98940a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 16 Jul 2016 21:50:24 +0200 Subject: [PATCH] tests/backup: verify restored VM properties QubesOS/qubes-issues#2106 --- tests/__init__.py | 3 +++ tests/backup.py | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/tests/__init__.py b/tests/__init__.py index e01e2502..0e6891d0 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -639,6 +639,7 @@ class BackupTestsMixin(SystemTestsMixin): testnet = self.qc.add_new_vm('QubesNetVm', name=vmname, template=template) testnet.create_on_disk(verbose=self.verbose) + testnet.services['ntpd'] = True vms.append(testnet) self.fill_image(testnet.private_img, 20*1024*1024) @@ -657,6 +658,8 @@ class BackupTestsMixin(SystemTestsMixin): if self.verbose: print >>sys.stderr, "-> Creating %s" % vmname testvm2 = self.qc.add_new_vm('QubesHVm', name=vmname) + # fixup - uses_default_netvm=True anyway + testvm2.netvm = self.qc.get_default_netvm() testvm2.create_on_disk(verbose=self.verbose) self.fill_image(testvm2.root_img, 1024*1024*1024, True) vms.append(testvm2) diff --git a/tests/backup.py b/tests/backup.py index 69b5c597..554f8dc8 100644 --- a/tests/backup.py +++ b/tests/backup.py @@ -37,6 +37,32 @@ class TC_00_Backup(qubes.tests.BackupTestsMixin, qubes.tests.QubesTestCase): self.make_backup(vms) self.remove_vms(vms) self.restore_backup() + for vm in vms: + restored_vm = self.qc.get_vm_by_name(vm.name) + for prop in ('name', 'kernel', 'uses_default_kernel', + 'uses_default_netvm', 'memory', 'maxmem', 'kernelopts', + 'uses_default_kernelopts', 'services', 'vcpus', 'pcidevs', + 'include_in_backups', 'default_user', 'qrexec_timeout', + 'autostart', 'pci_strictreset', 'pci_e820_host', 'debug', + 'internal'): + if prop not in vm.get_attrs_config(): + continue + self.assertEquals( + getattr(vm, prop), getattr(restored_vm, prop), + "VM {} - property {} not properly restored".format( + vm.name, prop)) + for prop in ('netvm', 'template', 'label'): + orig_value = getattr(vm, prop) + restored_value = getattr(restored_vm, prop) + if orig_value and restored_value: + self.assertEquals(orig_value.name, restored_value.name, + "VM {} - property {} not properly restored".format( + vm.name, prop)) + else: + self.assertEquals(orig_value, restored_value, + "VM {} - property {} not properly restored".format( + vm.name, prop)) + self.remove_vms(vms) def test_001_compressed_backup(self):