-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
env_process: Refactor huge pages setup/cleanup steps #4054
Open
bgartzi
wants to merge
1
commit into
avocado-framework:master
Choose a base branch
from
bgartzi:env_process_refactoring-huge_pages
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from virttest import env_process, test_setup, utils_libvirtd | ||
from virttest.test_setup.core import Setuper | ||
|
||
|
||
class HugePagesSetup(Setuper): | ||
def setup(self): | ||
# If guest is configured to be backed by hugepages, setup hugepages in host | ||
if self.params.get("hugepage") == "yes": | ||
self.params["setup_hugepages"] = "yes" | ||
if self.params.get("setup_hugepages") == "yes": | ||
h = test_setup.HugePageConfig(self.params) | ||
env_process._pre_hugepages_surp = h.ext_hugepages_surp | ||
suggest_mem = h.setup() | ||
if suggest_mem is not None: | ||
self.params["mem"] = suggest_mem | ||
if not self.params.get("hugepage_path"): | ||
self.params["hugepage_path"] = h.hugepage_path | ||
if self.params.get("vm_type") == "libvirt": | ||
utils_libvirtd.Libvirtd().restart() | ||
|
||
def cleanup(self): | ||
if self.params.get("setup_hugepages") == "yes": | ||
h = test_setup.HugePageConfig(self.params) | ||
h.cleanup() | ||
if self.params.get("vm_type") == "libvirt": | ||
utils_libvirtd.Libvirtd().restart() | ||
env_process._post_hugepages_surp = h.ext_hugepages_surp |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_pre_hugepages_surp
and_post_hugepages_surp
are for hugepage leak check, with this Setuper, I would suggest dropping them. by returning a variable afterdo_cleanup
. soleak_num = _post_hugepages_surp - _pre_hugepages_surp
can short toleak_num = <new_var>
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understood correctly, you are proposing to make the
cleanup
method of thisSetuper
return theleak_num
value?That would also involve updating the
SetupManager
behavior to meet the demands ofHugePagesSetup
. If that's the case, we would permit everySetuper
return a value, which goes against the current implementation. We would then have to update theSetupManager
do_cleanup
logic to handle that.In my opinion, if we were to do that, we would have to think of a protocol of some sort to make this implementable by each
Setuper
instead of adding specificSetuper
logic into the rather generalSetupManager
. Could something like adding apost_cleanup_check
function into the coreSetuper
and calling it after thecleanup
method has been called fromSetupManager.do_cleanup
be the answer to that issue?I also thought on other approaches, as implementing a core
Singleton
abstraction, so we would be able to reachSetuper
instances instead of classes from withinenv_process
so we could call extra functions on demand after the cleanup would have terminated. However, this approach sounds too complex for a workaround, and it could introduce further issues, asSetuper
instances "surviving" from one test case run to the next one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The complex solution you mentioned is that Setuper can return something. I agree we can do this, but not now, the implementation can closely combine env_process and Setuper.