Skip to content

Conversation

@Anushree-Mathur
Copy link
Contributor

@Anushree-Mathur Anushree-Mathur commented Nov 24, 2025

Add a check to skip unsupported architectures when running virsh cpu-models. Logs the message and continues with the next architecture to avoid unnecessary failures as it is expected..

Signed-off-by: Anushree-Mathur [email protected]

Summary by CodeRabbit

  • Tests
    • Enhanced virsh cpu-models tests to gracefully skip unsupported CPU architectures instead of failing, improving test reliability across different environments.

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

Add a check to skip unsupported architectures when running
virsh cpu-models. Logs the message and continues with the
next architecture to avoid unnecessary failures as it is expected..
Signed-off-by: Anushree-Mathur <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Nov 24, 2025

Walkthrough

The change modifies the virsh cpu-models test to handle unsupported CPU architectures at runtime. When executing the cpu-models command, if the stderr contains "architecture is not supported by CPU driver", the test logs an info message and skips processing that architecture. For supported architectures, the existing exit status checks and comparison logic remain unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single file modification with focused error handling logic
  • Additional consideration: verify that the error message string matches the exact output from the virsh command to avoid false negatives or false positives in architecture skipping

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 'Handle unsupported architectures in virsh CPU models check!' accurately and concisely describes the main change: adding runtime handling for unsupported CPU architectures in virsh cpu-models tests.
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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a302a6f and 0e3a4a4.

📒 Files selected for processing (1)
  • libvirt/tests/src/virsh_cmd/host/virsh_cpu_models.py (1 hunks)
⏰ 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.9
  • GitHub Check: Python 3.12
  • GitHub Check: Python 3.8
  • GitHub Check: Python 3.11

Comment on lines +84 to +87
# Check if the architecture is not supported; log it and skip to the next architecture.
if "architecture is not supported by CPU driver" in result.stderr:
logging.info("%s architecture is not supported by CPU driver as expected" % arch)
continue
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Consider checking exit status in addition to stderr.

The condition only checks stderr content without verifying that the command actually failed. If the command succeeds (exit status 0) but includes this text in stderr as a warning, the architecture would be incorrectly skipped.

Apply this diff for more defensive error handling:

 # Check if the architecture is not supported; log it and skip to the next architecture.
-if "architecture is not supported by CPU driver" in result.stderr:
+if result.exit_status != 0 and "architecture is not supported by CPU driver" in result.stderr:
     logging.info("%s architecture is not supported by CPU driver as expected" % arch)
     continue

Additionally, the hardcoded error message string may be fragile if libvirt changes its error format.

Please verify the error message format is stable across libvirt versions:


🌐 Web query:

What error message does libvirt virsh cpu-models command return for unsupported architectures?

💡 Result:

It doesn't return an error — for architectures where libvirt has no built-in models it prints "all CPU models are accepted". [1][2]

Sources:
[1] libvirt virsh manpage (cpu-models).
[2] libvirt-devel discussion noting cpu-models prints "all CPU models are accepted" for aarch64/s390x.


Critical: The error message string is incorrect and will never match libvirt's actual output.

libvirt prints "all CPU models are accepted" for unsupported architectures, not "architecture is not supported by CPU driver". This means the condition on line 85 will never trigger, and unsupported architectures won't be skipped as intended.

Fix: Replace the error message string with the correct one:

 # Check if the architecture is not supported; log it and skip to the next architecture.
-if "architecture is not supported by CPU driver" in result.stderr:
+if "all CPU models are accepted" in result.stderr:
     logging.info("%s architecture is not supported by CPU driver as expected" % arch)
     continue
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Check if the architecture is not supported; log it and skip to the next architecture.
if "architecture is not supported by CPU driver" in result.stderr:
logging.info("%s architecture is not supported by CPU driver as expected" % arch)
continue
# Check if the architecture is not supported; log it and skip to the next architecture.
if "all CPU models are accepted" in result.stderr:
logging.info("%s architecture is not supported by CPU driver as expected" % arch)
continue
🤖 Prompt for AI Agents
In libvirt/tests/src/virsh_cmd/host/virsh_cpu_models.py around lines 84 to 87,
the substring checked in result.stderr is wrong and will never match libvirt
output; replace the check for "architecture is not supported by CPU driver" with
"all CPU models are accepted" so the condition triggers for unsupported
architectures, keep the logging and continue behavior the same.

@Anushree-Mathur
Copy link
Contributor Author

Before applying the patch:

JOB ID     : 18fb71e10ea62035e01fcbb2adfae035fb845815
JOB LOG    : /home/Anu/tests/results/job-2025-11-24T00.54-18fb71e/job.log
 (1/3) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: STARTED
 (1/3) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: PASS (44.04 s)
 (2/3) type_specific.io-github-autotest-libvirt.virsh.cpu_models.positive_test.local_host.auto_get_arch: STARTED
 (2/3) type_specific.io-github-autotest-libvirt.virsh.cpu_models.positive_test.local_host.auto_get_arch: FAIL: error: failed to get CPU model names\nerror: this function is not supported by the connection driver: 'm68k' architecture is not supported by CPU driver\n (4.27 s)
 (3/3) io-github-autotest-libvirt.remove_guest.without_disk: STARTED
 (3/3) io-github-autotest-libvirt.remove_guest.without_disk: PASS (4.29 s)

After applying the patch:

 (1/3) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: STARTED
 (1/3) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: PASS (42.89 s)
 (2/3) type_specific.io-github-autotest-libvirt.virsh.cpu_models.positive_test.local_host.auto_get_arch: STARTED
 (2/3) type_specific.io-github-autotest-libvirt.virsh.cpu_models.positive_test.local_host.auto_get_arch: PASS (4.93 s)
 (3/3) io-github-autotest-libvirt.remove_guest.without_disk: STARTED
 (3/3) io-github-autotest-libvirt.remove_guest.without_disk: PASS (4.48 s)

In debug.log it will log the information as:

[stdlog] 2025-11-24 00:57:19,153 avocado.utils.process process          L0475 DEBUG| [stderr] error: this function is not supported by the connection driver: 'sparc64' architecture is not supported by CPU driver
[stdlog] 2025-11-24 00:57:19,154 avocado.utils.process process          L0719 INFO | Command '/sbin/virsh -c 'qemu:///system' cpu-models sparc64 ' finished with 1 after 0.027434404s
[stdlog] 2025-11-24 00:57:19,154 avocado.virttest.virsh virsh            L0869 DEBUG| status: 1
[stdlog] 2025-11-24 00:57:19,154 avocado.virttest.virsh virsh            L0870 DEBUG| stdout:
[stdlog] 2025-11-24 00:57:19,154 avocado.virttest.virsh virsh            L0871 DEBUG| stderr: error: failed to get CPU model names
[stdlog] error: this function is not supported by the connection driver: 'sparc64' architecture is not supported by CPU driver
[stdlog] 2025-11-24 00:57:19,154 avocado.virsh_cpu_models virsh_cpu_models L0087 INFO | sparc64 architecture is not supported by current CPU driver as expected

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.

1 participant