Skip to content

Commit

Permalink
Merge pull request avocado-framework#3439 from dzhengfy/add_func_rese…
Browse files Browse the repository at this point in the history
…t_cpuset

libvirt_cgroup: add functions for cpusset.cpus
  • Loading branch information
chloerh authored Jun 29, 2022
2 parents 8d98e23 + 58a542a commit f010886
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions virttest/libvirt_cgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,27 @@ def get_standardized_virsh_output_by_name(self, vm_name=None, virsh_cmd=None):
"""
virsh_output_dict = self.get_virsh_output_dict(vm_name, virsh_cmd)
return self.get_standardized_virsh_info(virsh_cmd, virsh_output_dict)

def reset_cpuset_cpus(self, value):
"""
Reset the cpuset.cpus file to the specified content
:param value: to be set
"""
if self.is_cgroup_v2_enabled():
return
LOG.debug("Reset /sys/fs/cgroup/cpuset/machine.slice/cpuset.cpus to %s", value)
cmd = "echo %s > /sys/fs/cgroup/cpuset/machine.slice/cpuset.cpus" % value
process.run(cmd, ignore_status=False, shell=True)

def get_cpuset_cpus(self):
"""
Get the cpuset.cpus file content
:return: str, the value of cpuset.cpus content
"""
if self.is_cgroup_v2_enabled():
return
LOG.debug("Get /sys/fs/cgroup/cpuset/machine.slice/cpuset.cpus value")
cmd = "cat /sys/fs/cgroup/cpuset/machine.slice/cpuset.cpus"
return process.run(cmd, ignore_status=False, shell=True).stdout_text.strip()

0 comments on commit f010886

Please sign in to comment.