Skip to content

Conversation

@elizashurov
Copy link

@elizashurov elizashurov commented Dec 9, 2025

Check for WMI-Activity Event ID 5858 since blnsvr.exe start.

id: 1315

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced Windows balloon service validation by adding a post-operation check for WMI Event 5858 to detect related errors.
    • Introduced a configurable Windows check command used during install/uninstall and after run operations.
    • Checks handle absent service, command failures, and unexpected results with clear pass/fail outcomes.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Walkthrough

Adds Windows-specific verification for WMI Event ID 5858 during balloon service tests. A new method assert_no_wmi_error_5858(self, session) was added to BallooningTestWin to run a configurable PowerShell command (wmi_5858_check_cmd) that inspects the Microsoft-Windows-WMI-Activity/Operational log for Event ID 5858 related to the blnsvr process and interprets multiple exit statuses. balloon_service.py was updated to call this check after balloon operations when running on Windows and the config cfg/balloon_service.cfg includes the new PowerShell command under the install_uninstall variant.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review assert_no_wmi_error_5858 for correct exit-code handling and error messages.
  • Validate integration in qemu/tests/balloon_service.py that the check runs only for the "run" operation on Windows and at the correct point in the flow.
  • Inspect cfg/balloon_service.cfg wmi_5858_check_cmd PowerShell expression for correctness, edge cases (process start time capture, missing process), and robustness against unexpected output.
  • Confirm configuration lookup and propagation to the new method are correct.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a WMI-Activity check after balloon service restart on Windows systems.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
qemu/tests/balloon_check.py (1)

504-557: assert_no_wmi_error_5858 behavior and exit-code mapping look solid

The helper cleanly maps the PowerShell command’s exit codes (0/1/2/other) into “pass/fail/skip/warn” semantics, and degrades gracefully when wmi_5858_check_cmd is missing or returns an unexpected status. This matches the cfg command and avoids breaking non-Windows or misconfigured runs.

If, in the future, you want the “run after restart” scenario to also assert that blnsvr is actually running, you could treat status == 2 as a failure (or add a separate strict mode) in that specific call site, but that’s optional and not required for this PR’s goal.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1339503 and 3d6fadb.

📒 Files selected for processing (3)
  • qemu/tests/balloon_check.py (1 hunks)
  • qemu/tests/balloon_service.py (1 hunks)
  • qemu/tests/cfg/balloon_service.cfg (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
qemu/tests/balloon_service.py (1)
qemu/tests/balloon_check.py (2)
  • operate_balloon_service (560-583)
  • assert_no_wmi_error_5858 (504-557)
🔇 Additional comments (2)
qemu/tests/cfg/balloon_service.cfg (1)

72-72: WMI 5858 PowerShell probe matches helper expectations

The PowerShell command’s exit codes (0: NONE, 1: HIT, 2: NO_PID) and log selection/filtering align cleanly with assert_no_wmi_error_5858, and scoping it under the Windows disable_enable (stop/run) variant fits the “restart” use case. Looks good as-is.

qemu/tests/balloon_service.py (1)

92-104: Windows-only WMI 5858 check is correctly scoped and placed

Gating the WMI 5858 check behind windows_run ensures it’s only invoked for Windows runs of the balloon service, and placing it after balloon_memory keeps the existing flow intact while adding the new validation. No issues spotted.

Check for WMI-Activity Event ID 5858 since blnsvr.exe start.
Filter by ClientProcessId.
Use PS exit codes: 0=NONE, 1=HIT, 2=NO_PID.
Command configured in cfg.

id: 1315
Signed-off-by: Elizabeth Ashurov <eashurov@redhat.com>
@elizashurov
Copy link
Author

Hi @xiagao , I've implemented the suggested changes.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
qemu/tests/balloon_check.py (1)

510-511: Optional: Remove redundant OS check.

This method is in the BallooningTestWin class, which is already Windows-specific. The OS type check here is defensive but unnecessary.

Consider removing these lines:

-        if self.params.get("os_type") != "windows":
-            return
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d6fadb and 3c9cc08.

📒 Files selected for processing (3)
  • qemu/tests/balloon_check.py (1 hunks)
  • qemu/tests/balloon_service.py (1 hunks)
  • qemu/tests/cfg/balloon_service.cfg (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • qemu/tests/cfg/balloon_service.cfg
🧰 Additional context used
🧬 Code graph analysis (1)
qemu/tests/balloon_service.py (1)
qemu/tests/balloon_check.py (3)
  • operate_balloon_service (545-568)
  • balloon_memory (195-233)
  • assert_no_wmi_error_5858 (504-542)
🔇 Additional comments (5)
qemu/tests/balloon_service.py (1)

92-104: LGTM! Well-structured Windows-specific WMI event validation.

The implementation correctly:

  • Computes the windows_run condition once for reuse
  • Adds the WMI 5858 check only after "run" operations on Windows guests
  • Provides clear error context for logging
  • Integrates cleanly with the new assert_no_wmi_error_5858 method
qemu/tests/balloon_check.py (4)

534-537: Verify status 2 handling after "run" operation.

Status 2 indicates the balloon service is not running, which triggers an info log and skips the check. However, this method is called immediately after a "run" operation in balloon_service.py. If the service is not running after being started, this might indicate a failure to start or a crash.

Current behavior treats this as a benign skip scenario. Consider whether this should be:

  • A test failure (service should be running after "run" operation)
  • A warning rather than info (unexpected but not critical)
  • The current behavior (acceptable timing/race condition)

Review the test flow to determine if there are legitimate scenarios where the service might not be running immediately after the "run" operation (e.g., slow startup, timing window), or if this always indicates a problem that should fail the test.


517-519: Good defensive check for missing configuration.

Explicitly failing when wmi_5858_check_cmd is missing prevents silent test passes and ensures the check is actually performed. This addresses previous reviewer feedback about ensuring the test doesn't pass without running the validation.


526-542: Well-structured status code handling.

The if/elif/else structure cleanly handles all expected status codes with appropriate actions:

  • Status 0: Success (no events found)
  • Status 1: Test failure (events detected)
  • Status 2: Skip scenario (service not running)
  • Other: Test failure (unexpected status)

This implementation addresses previous reviewer feedback to use if/elif/else and handle all cases explicitly.


520-520: Add timeout parameter to cmd_status_output call to prevent indefinite blocking.

The PowerShell command execution at line 520 lacks an explicit timeout. The cmd_status_output() method supports a timeout parameter (as shown in similar calls throughout the codebase with timeout=360, timeout=240, etc.), but this call omits it. If the PowerShell command hangs, test execution could block indefinitely. Consider specifying a reasonable timeout like other operations in the file:

status, output = session.cmd_status_output(ps_cmd, timeout=60)

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.

2 participants