-
Notifications
You must be signed in to change notification settings - Fork 179
Virtual_disk: fix virtio_scsi driver issue in image mode #6538
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
Conversation
Dracut command is used in guest to add the scsi driver. But in image mode it can't write to /boot/efi. Because actually this is not a necessary checkpoint in test scenario, so I think we can directly skip this step in case. Signed-off-by: meinaLi <[email protected]>
|
This PR depends on avocado-framework/avocado-vt#4215. |
|
WalkthroughAdds a guard around invoking dracut in virtual_disks_multidisks.py by checking image mode via utils_sys.is_image_mode(session=...). dracut runs only when not in image mode. Introduces new import for utils_sys. No other logic or interfaces changed. Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Test Case
participant Session as Guest Session
participant Utils as utils_sys
participant System as System (dracut)
Test->>Utils: is_image_mode(session)
Utils-->>Test: image_mode (True/False)
alt add_disk_driver and not image_mode
Test->>System: run dracut to rebuild initramfs
System-->>Test: dracut result
else add_disk_driver and image_mode
Note over Test: Skip dracut in image mode
end
Note over Test: Continue with existing verification logic
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks (3 passed)✅ Passed checks (3 passed)
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 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 (2)
libvirt/tests/src/virtual_disks/virtual_disks_multidisks.py (2)
24-24: New dependency on utils_sys.is_image_mode: add a graceful fallback or enforce via explicit dependency checkIf CI/dev envs pick an older avocado-vt without utils_sys.is_image_mode, this import/call will break the test at runtime. Either add a defensive fallback (recommended for robustness) or fail fast with a clear message when add_disk_driver is used.
Proposed defensive import:
-from virttest import utils_sys +try: + from virttest import utils_sys # requires avocado-vt PR 4215+ +except Exception: + utils_sys = None # fallback for older environmentsAnd guard the usage (paired with the block below):
- image_mode = utils_sys.is_image_mode(session=session) + image_mode = False + if utils_sys and hasattr(utils_sys, "is_image_mode"): + image_mode = utils_sys.is_image_mode(session=session) + else: + logging.debug("utils_sys.is_image_mode unavailable; assuming non-image mode.")
1098-1107: Gate zipl together with dracut in image mode, and truly ignore dracut failures
- If image mode skips dracut, zipl on s390x likely isn’t needed and may also fail.
- The comment says “Ignore errors here”, but session.cmd will raise on non-zero exit. Catch and log instead.
if add_disk_driver: # Ignore errors here - image_mode = utils_sys.is_image_mode(session=session) - if not image_mode: - session.cmd("dracut --force --add-drivers '%s'" - % add_disk_driver, timeout=360) - # In terms of s390x, additional step is needed for normal guest - # boot, see https://bugzilla.redhat.com/show_bug.cgi?id=2214147 - if arch == 's390x': - session.cmd("zipl") + # image mode cannot write to /boot/efi; skip initramfs/bootloader work there + # (fallback guard if utils_sys/is_image_mode is unavailable is added above) + if image_mode: + logging.debug("Image mode detected; skipping dracut and zipl.") + else: + try: + session.cmd("dracut --force --add-drivers '%s'" % add_disk_driver, timeout=360) + except aexpect.ShellCmdError as e: + logging.debug("dracut failed (ignored): %s", e) + # On s390x, zipl is required only when we actually rebuilt initramfs. + # https://bugzilla.redhat.com/show_bug.cgi?id=2214147 + if arch == 's390x': + session.cmd("zipl")
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.
lgtm
Dracut command is used in guest to add the scsi driver. But in image mode it can't write to /boot/efi. Because actually this is not a necessary checkpoint in test scenario, so I think we can directly skip this step in case.
Summary by CodeRabbit
Bug Fixes
Tests