-
Notifications
You must be signed in to change notification settings - Fork 179
LIBVIRTAT-22036: Add VM shutdown test to iommu_device_lifecycle for better vIOMMU device coverage #6578
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
LIBVIRTAT-22036: Add VM shutdown test to iommu_device_lifecycle for better vIOMMU device coverage #6578
Conversation
…etter vIOMMU device coverage This change adds new test to verify virsh shutdown command is working as expected for VM with vIOMMU devices. Also added the optional possibility to start the VM again after the shutdown. improving test coverage for RHEL-109504.
WalkthroughAdds a new "shutdown" test scenario and corresponding test logic: the VM is shut down, waited on (default 60s), and optionally restarted if Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Runner as Test Runner
participant Test as Test Case
participant Libvirt as libvirt
participant VM as Guest
Runner->>Test: invoke "shutdown" scenario
Test->>Libvirt: virDomainShutdown(domain)
Note over Test,Libvirt #D3E4CD: initiate graceful shutdown
Test->>Libvirt: poll state until "shut off" (≤ shutdown_timeout)
alt shutdown completed
Libvirt-->>Test: state = shut off
alt start_after_shutdown == yes
Test->>Libvirt: virDomainStart(domain)
Libvirt-->>Test: domain started
Test->>VM: open serial login, wait (login_timeout)
VM-->>Test: login successful
Note right of Test #FCE7C6: reset serial & close session
end
else timeout
Libvirt-->>Test: still running
Note right of Test #F8D7DA: log failure and abort branch
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
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. 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 (4)
libvirt/tests/cfg/sriov/vIOMMU/iommu_device_lifecycle.cfg (1)
44-46: Add a configurable shutdown timeout knob.Hard-coding 60s in code makes tuning harder across environments. Add a
shutdown_timeoutparam here to align with code usage.- shutdown: start_after_shutdown = yes + shutdown_timeout = 60libvirt/tests/src/sriov/vIOMMU/iommu_device_lifecycle.py (3)
91-97: Make shutdown wait duration configurable.Use a
shutdown_timeoutparam (default 60) instead of a magic number for better portability.- if not utils_misc.wait_for(lambda: vm.is_dead(), 60): + shutdown_timeout = int(params.get("shutdown_timeout", "60")) + if not utils_misc.wait_for(lambda: vm.is_dead(), shutdown_timeout): test.fail("VM failed to shutdown")
101-104: Close the login session to avoid leaks.
vm.wait_for_login()returns a session; not closing it can leak resources.- vm.start() - vm.wait_for_login(timeout=int(params.get('login_timeout', 240))) - test.log.info("VM successfully started after shutdown") + vm.start() + session = vm.wait_for_login(timeout=int(params.get('login_timeout', 240))) + session.close() + test.log.info("VM successfully started after shutdown")
101-104: Prefer serial login after restart to reduce network flakiness.Aligns with the other lifecycle branches and avoids dependency on guest networking being up.
- test.log.info("TEST_STEP: Starting VM after shutdown") - vm.start() - vm.wait_for_login(timeout=int(params.get('login_timeout', 240))) - test.log.info("VM successfully started after shutdown") + test.log.info("TEST_STEP: Starting VM after shutdown") + vm.cleanup_serial_console() + vm.create_serial_console() + vm.start() + session = vm.wait_for_serial_login(timeout=int(params.get('login_timeout'))) + session.close() + test.log.info("VM successfully started after shutdown")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
libvirt/tests/cfg/sriov/vIOMMU/iommu_device_lifecycle.cfg(1 hunks)libvirt/tests/src/sriov/vIOMMU/iommu_device_lifecycle.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
libvirt/tests/src/sriov/vIOMMU/iommu_device_lifecycle.py (1)
libvirt/tests/src/serial/serial_functional.py (1)
wait_for_login(235-258)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Python 3.12
- GitHub Check: Python 3.9
- GitHub Check: Python 3.11
- GitHub Check: Python 3.8
|
Closed - and recreated a new one #6579 |
This change adds new test to verify virsh shutdown command is working as expected for VM with vIOMMU devices.
Also added the optional possibility to start the VM again after the shutdown.
Improving test coverage for RHEL-109504.
Summary by CodeRabbit