-
Notifications
You must be signed in to change notification settings - Fork 183
pvpanic: Fix race condition when checking QMP events #4416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
When guest triggers panic and QEMU exits quickly (especially on RHEL10), the test may fail with MonitorSocketError due to socket connection being reset while checking QMP events. Signed-off-by: Wenkang Ji <wji@redhat.com>
WalkthroughThis change modifies an event detection function in Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this 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/pvpanic.py (1)
54-67: MoveMonitorSocketErrorhandling outside_do_check()to avoid timeout waste and log spamWhen
MonitorSocketErroris caught inside_do_check()and returnsNone(falsy),wait_for()continues polling until the full timeout expires, logging "QMP connection closed" on every iteration. Sincewait_for()propagates exceptions from its callback and stops only on a truthy return, this turns a terminal condition into a slow, noisy timeout.Instead:
- Simplify
_do_check()to a clean "event present?" predicate returning onlyTrue/False- Wrap the
wait_for()call intry/except MonitorSocketErrorto log once and returnNoneimmediatelyThis preserves the external behavior (returns
Trueon success,Noneotherwise) without wasting the full timeout when QMP closes:def _do_check(vm, event_names): - try: - events = vm.monitor.get_events() - for event in events: - if event.get("event") in event_names: - LOG_JOB.info( - "Receive qmp %s event notification", event.get("event") - ) - vm.monitor.clear_event(event.get("event")) - return True - except MonitorSocketError: - LOG_JOB.warning("QMP connection closed") - return None + events = vm.monitor.get_events() + for event in events: + if event.get("event") in event_names: + LOG_JOB.info( + "Receive qmp %s event notification", event.get("event") + ) + vm.monitor.clear_event(event.get("event")) + return True return False - LOG_JOB.info("Try to get qmp events %s in %s seconds!", event_names, timeout) - return wait_for(lambda: _do_check(vm, event_names), timeout, 5, 5) + LOG_JOB.info("Try to get qmp events %s in %s seconds!", event_names, timeout) + try: + return wait_for(lambda: _do_check(vm, event_names), timeout, 5, 5) + except MonitorSocketError: + LOG_JOB.warning("QMP connection closed while waiting for events %s", event_names) + return None
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
qemu/tests/pvpanic.py(2 hunks)
🔇 Additional comments (1)
qemu/tests/pvpanic.py (1)
7-7: Import ofMonitorSocketErrorlooks correctThe new import cleanly scopes the QMP error handling to this module and matches its later usage in
check_qmp_events(). No issues here.
|
Test Result: PASS |
|
@leidwang Hi Leidong, could you please help review this patch? |
When guest triggers panic and QEMU exits quickly (especially on RHEL10), the test may fail with MonitorSocketError due to socket connection being reset while checking QMP events.
ID: 1863
Signed-off-by: Wenkang Ji wji@redhat.com
Summary by CodeRabbit
Bug Fixes
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.