tests: check if page scrubbing is still enabled when switching kernel

QubesOS/qubes-issues#4736
This commit is contained in:
Marek Marczykowski-Górecki 2019-01-22 03:45:37 +01:00
parent 5222650868
commit 50a89aac3f
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -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):