Skip to content

Commit

Permalink
tests: check if page scrubbing is still enabled when switching kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
marmarek committed Feb 25, 2019
1 parent 5b43fc0 commit 6e3fda3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions qubes/tests/integ/grub.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ def get_kernel_version(self, vm):
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'),
Expand All @@ -103,6 +111,8 @@ def test_000_standalone_vm(self):
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')
Expand Down Expand Up @@ -132,12 +142,16 @@ def test_010_template_based_vm(self):
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):
Expand Down

0 comments on commit 6e3fda3

Please sign in to comment.