Skip to content

Conversation

@adityagesh
Copy link
Collaborator

  1. Hibernation requires free disk space proportional to RAM of the machine. LISA currently does not support os disk size as a requirement.
  2. Azure does not support Hibernation for VM with memory larger than 256 GB

@adityagesh adityagesh requested a review from LiliDeng as a code owner November 21, 2025 06:37
@adityagesh adityagesh force-pushed the aditya/hibernation_precheck branch 3 times, most recently from 1709020 to ba9870a Compare November 21, 2025 10:31
@kanchansenlaskar
Copy link
Collaborator

LGTM

@adityagesh adityagesh force-pushed the aditya/hibernation_precheck branch 3 times, most recently from 6619dfd to da8f248 Compare November 24, 2025 04:21
df_tool = node.tools[Df]

# Get total memory in KB
total_memory_kb = free_tool._get_field_bytes_kib("Mem", "total")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does get_total_memory meet your requirement?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated

@LiliDeng LiliDeng requested a review from Copilot November 24, 2025 07:41
Copilot finished reviewing on behalf of LiliDeng November 24, 2025 07:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds disk space validation for VM hibernation to prevent setup failures. The changes implement pre-flight checks for disk space requirements and improve error handling for space-related hibernation failures.

  • Adds a new function check_hibernation_disk_requirements() that validates available disk space based on VM RAM size
  • Adds error pattern detection for defragmentation space errors in the hibernation setup tool
  • Integrates the disk space check into the Power test suite's before_case hook to fail fast before attempting hibernation

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
lisa/tools/hibernation_setup.py Adds regex pattern and error handling for defragmentation space errors during hibernation setup
lisa/microsoft/testsuites/power/common.py Implements new disk space validation function that checks RAM size and available disk space against hibernation requirements
lisa/microsoft/testsuites/power/power.py Integrates disk space check into test suite setup by calling it in the before_case hook

Comment on lines 65 to 67
# Get total memory in KB
total_memory_kb = free_tool._get_field_bytes_kib("Mem", "total")
total_memory_gb = total_memory_kb / (1024 * 1024) # Convert KB to GB
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code accesses the private method _get_field_bytes_kib directly. Consider using the existing public method get_total_memory_gb() instead, which internally calls _get_field_bytes_kib("Mem", "total") >> 20. This would be more maintainable and follow the principle of using public APIs. If more precision is needed than the integer value returned by get_total_memory_gb(), consider adding a new public method to the Free class.

Suggested change
# Get total memory in KB
total_memory_kb = free_tool._get_field_bytes_kib("Mem", "total")
total_memory_gb = total_memory_kb / (1024 * 1024) # Convert KB to GB
# Get total memory in GB using public API
total_memory_gb = float(free_tool.get_total_memory_gb())

Copilot uses AI. Check for mistakes.
f"Current RAM: {total_memory_gb:.2f} GB"
)

# Calculate required swap space based on RAM size
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states 'Calculate required swap space' but the code actually calculates required disk space for hibernation, not swap space. The comment should be updated to accurately reflect what's being calculated: 'Calculate required disk space based on RAM size'.

Suggested change
# Calculate required swap space based on RAM size
# Calculate required disk space for hibernation based on RAM size

Copilot uses AI. Check for mistakes.

# Get total memory in KB
total_memory_kb = free_tool._get_field_bytes_kib("Mem", "total")
total_memory_gb = total_memory_kb / (1024 * 1024) # Convert KB to GB
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conversion from KB to GB should use 1024 ** 2 or explicitly comment that this converts KiB to GiB (using binary units). The current comment 'Convert KB to GB' is technically imprecise since the values are in kibibytes (KiB) not kilobytes (KB), as indicated by the method name _get_field_bytes_kib.

Suggested change
total_memory_gb = total_memory_kb / (1024 * 1024) # Convert KB to GB
total_memory_gb = total_memory_kb / (1024 * 1024) # Convert KiB to GiB (binary units)

Copilot uses AI. Check for mistakes.
required_space_with_buffer = required_space_gb * 1.2

root_partition = df_tool.get_partition_by_mountpoint("/", force_run=True)
assert root_partition is not None, "Unable to determine root partition disk space"
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using assert statements for error handling is not recommended in production code, as assertions can be disabled with Python's -O flag. Consider using an explicit if-check followed by raising a LisaException instead: if root_partition is None: raise LisaException(\"Unable to determine root partition disk space\").

Suggested change
assert root_partition is not None, "Unable to determine root partition disk space"
if root_partition is None:
raise LisaException("Unable to determine root partition disk space")

Copilot uses AI. Check for mistakes.
@adityagesh adityagesh force-pushed the aditya/hibernation_precheck branch from da8f248 to 7868802 Compare November 24, 2025 12:48
1. Hibernation requires free disk space proportional to
RAM of the machine. LISA currently does not support
os disk size as a requirement.
2. Azure does not support Hibernation for VM with
memory larger than 256 GB
@adityagesh adityagesh force-pushed the aditya/hibernation_precheck branch from 7868802 to 99d6976 Compare November 24, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants