Skip to content

Commit

Permalink
hugepage_setup: Cleanup hugepage when setup process fails
Browse files Browse the repository at this point in the history
If the setup process fails, func will raise an error and return. Meanwhile, if the system has
created some other hugepages, they will remain on the host to consume memory.

Therefore, do the cleanup process after failing.

Signed-off-by: Hu Shuai <[email protected]>
  • Loading branch information
hs0210 committed Jul 6, 2023
1 parent 5254729 commit d5dd42a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions virttest/test_setup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ def set_hugepages(self):
msg = "Can't read/write from kernel hugepage file"
raise exceptions.TestSetupFail(msg)
if loop_hp == hp:
if loop_hp > 0:
self.cleanup()
raise ValueError("Cannot set the kernel hugepage setting "
"to the target value of %d hugepages." %
self.target_hugepages)
Expand Down

0 comments on commit d5dd42a

Please sign in to comment.