From 50a89aac3fb8ebefca2cbded8b608da797dad4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 22 Jan 2019 03:45:37 +0100 Subject: [PATCH] tests: check if page scrubbing is still enabled when switching kernel QubesOS/qubes-issues#4736 --- qubes/tests/integ/grub.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qubes/tests/integ/grub.py b/qubes/tests/integ/grub.py index e4a9457d..0ddd0166 100644 --- a/qubes/tests/integ/grub.py +++ b/qubes/tests/integ/grub.py @@ -84,6 +84,14 @@ class GrubBase(object): cmd_get_kernel_version, user="root")) return kver.strip() + def assertXenScrubPagesEnabled(self, vm): + enabled, _ = self.loop.run_until_complete(vm.run_for_stdio( + 'cat /sys/devices/system/xen_memory/xen_memory0/scrub_pages || ' + 'echo 1')) + enabled = enabled.decode().strip() + self.assertEqual(enabled, '1', + 'Xen scrub pages not enabled in {}'.format(vm.name)) + def test_000_standalone_vm(self): self.testvm1 = self.app.add_new_vm('StandaloneVM', name=self.make_vm_name('vm1'), @@ -103,6 +111,8 @@ class GrubBase(object): self.testvm1.run_for_stdio('uname -r')) self.assertEquals(actual_kver.strip(), kver) + self.assertXenScrubPagesEnabled(self.testvm1) + def test_010_template_based_vm(self): self.test_template = self.app.add_new_vm('TemplateVM', name=self.make_vm_name('template'), label='red') @@ -132,12 +142,16 @@ class GrubBase(object): self.testvm1.run_for_stdio('uname -r')) self.assertEquals(actual_kver.strip(), kver) + self.assertXenScrubPagesEnabled(self.testvm1) + # And the same for the TemplateVM itself self.loop.run_until_complete(self.test_template.start()) (actual_kver, _) = self.loop.run_until_complete( self.test_template.run_for_stdio('uname -r')) self.assertEquals(actual_kver.strip(), kver) + self.assertXenScrubPagesEnabled(self.test_template) + @unittest.skipUnless(os.path.exists('/var/lib/qubes/vm-kernels/pvgrub2'), 'grub-xen package not installed') class TC_40_PVGrub(GrubBase):