Skip to content

Add Xen guest check to reset command #217

Description

@stisiTT

Summary

A customer has requested that the reset command check whether the host is a Xen guest before proceeding.

Request

Add a check_xen_hvm() helper to tt_smi/tt_smi_utils.py that detects if the system is running as a Xen guest by reading /sys/hypervisor/type. The check should only verify hypervisor_type == "xen" (the HVM guest type condition is not needed). The function should then be called in the reset command flow in tt_smi/tt_smi.py to block the reset when running on Xen.

Proposed implementation

def check_xen_hvm() -> bool:
    """Check if the system is a Xen guest"""
    is_xen = False
    try:
        with open("/sys/hypervisor/type", "r") as f:
            hypervisor_type = f.read().strip()
        if hypervisor_type == "xen":
            is_xen = True
    except FileNotFoundError:
        pass
    except OSError:
        pass
    # All other types of errors should throw an exception
    return is_xen

Files to change

  • tt_smi/tt_smi_utils.py — add check_xen_hvm()
  • tt_smi/tt_smi.py — import and call it in the reset command path (around line 769)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions