Skip to content

Commit

Permalink
Add virtutil module, check platform type and cpu hp state, Review V2
Browse files Browse the repository at this point in the history
  • Loading branch information
pssatapathy-oracle authored and brenns10 committed Mar 29, 2024
1 parent f56ea5e commit f886684
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
4 changes: 2 additions & 2 deletions drgn_tools/sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from drgn_tools.mm import totalram_pages
from drgn_tools.table import print_dictionary
from drgn_tools.util import human_bytes
from drgn_tools.virtutil import show_platform
from drgn_tools.virtutil import get_platform


def loadavg_str(prog: Program) -> str:
Expand Down Expand Up @@ -92,7 +92,7 @@ def get_sysinfo(prog: Program) -> Dict[str, Any]:
load_avg = loadavg_str(prog)
memory = get_mem(prog)
tasks = task_info(prog)
platform = show_platform(prog)
platform = get_platform(prog)

return {
"MODE": mode,
Expand Down
31 changes: 25 additions & 6 deletions drgn_tools/virtutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,54 @@ def get_platform_hypervisor(prog: Program) -> str:
try:
return prog["x86_hyper_type"].format_(type_name=False)
except KeyError:
print("Platform not supported.")
return ""
return "Platform not supported."


def get_cpuhp_state(prog: Program, cpu: int) -> str:
"""
Return CPU state for a given CPU
"""
cpuhp_state = per_cpu(prog["cpuhp_state"], cpu).state
return cpuhp_state.format_(type_name=False)


def show_cpuhp_state(prog: Program) -> None:
"""
Display cpu state for all possible CPUs
"""
for cpu in for_each_possible_cpu(prog):
state = get_cpuhp_state(prog, cpu)
print(f"CPU [{cpu:3d}]: {state}")


def show_platform(prog: Program) -> str:
def get_platform(prog: Program) -> str:
"""
Prints the kernel command line
Return platform type
"""
str_platform = (
get_platform_arch(prog) + " " + get_platform_hypervisor(prog)
)
return str_platform


def show_platform(prog: Program) -> None:
"""
Prints platfrom type
"""
platform = get_platform(prog)
print(platform)


class VirtUtil(CorelensModule):
""""""
"""
This module contains helper regarding virtualization.
Current functionality are :
cpu hotplug state
platform type, which includes architecture and hypervisor type
"""

name = "virtutil"
name = "virt"

def run(self, prog: Program, args: argparse.Namespace) -> None:
show_platform(prog)
return

0 comments on commit f886684

Please sign in to comment.