Skip to content

Add Power10 compat mode tests with vcpu plug_unplug!#6899

Open
Anushree-Mathur wants to merge 1 commit into
autotest:masterfrom
Anushree-Mathur:compat_mode_plug_unplug
Open

Add Power10 compat mode tests with vcpu plug_unplug!#6899
Anushree-Mathur wants to merge 1 commit into
autotest:masterfrom
Anushree-Mathur:compat_mode_plug_unplug

Conversation

@Anushree-Mathur

@Anushree-Mathur Anushree-Mathur commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Add Power10 compatibility mode testing for CPU hotplug/unplug on Power11 systems. Enables testing backward compatibility scenarios where guests run with older Power CPU models.

  • Add compat_mode and cpu_model parameters
  • Add with_power10_compat config variant
  • Restrict to POWER11 hosts via config filter
  • Test hotplug/unplug with power10 CPU model

7 testcases have been added, in which it brings up the compat mode guest then run vcpu plug_unplug on the guest having different numa or hugepages configuration.

Signed-off-by: Anushree-Mathur anushree.mathur@linux.ibm.com

Summary by CodeRabbit

  • Tests
    • Added a new test variant for virtual CPU plug/unplug operations with CPU compatibility mode support
    • Extended test framework to handle CPU model configuration and validate vCPU operations under different compatibility settings on supported architectures
    • Improved test coverage for CPU-related vCPU operations

Add Power10 compatibility mode testing for CPU hotplug/unplug on
Power11 systems. Enables testing backward compatibility scenarios
where guests run with older Power CPU models.

- Add compat_mode and cpu_model parameters
- Add with_power10_compat config variant
- Restrict to POWER11 hosts via config filter
- Test hotplug/unplug with power10 CPU model

7 testcases have been added, in which it brings up the compat mode guest then run vcpu plug_unplug on the guest having different numa or hugepages configuration.

Signed-off-by: Anushree-Mathur <anushree.mathur@linux.ibm.com>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

A new with_compat_mode test variant is added to libvirt_vcpu_plug_unplug.cfg under positive_test, restricted to ppc64le/ppc64 and POWER11. It sets compat_mode = "yes", cpu_model = "power10", test_itr = 5, and vCPU values of max=8, current=2, plug=6, unplug=3. Correspondingly, libvirt_vcpu_plug_unplug.py reads compat_mode and cpu_model from params. When compat_mode is active, the test obtains or creates a CPU XML element from vmxml, sets its mode to host-model and model to cpu_model, then persists it back into vmxml before proceeding with vCPU plug/unplug operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly aligns with the main change: adding Power10 compatibility mode tests for vCPU plug/unplug operations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@libvirt/tests/src/libvirt_vcpu_plug_unplug.py`:
- Around line 243-244: The compat_mode variable at line 243 is assigned a raw
string from params.get(), which causes a false-positive when checked with if
compat_mode at line 303, since the string "no" is still truthy. Replace the
assignment of compat_mode with explicit boolean parsing using the same pattern
as other boolean flags in this file (likely params.get_bool() or equivalent), so
that string values like "no" are properly parsed as False instead of being
treated as truthy.
- Around line 307-310: Add the missing imports at the top of the
libvirt_vcpu_plug_unplug.py file to resolve the NameError exceptions. The
exception handler at line 308 references xcepts.LibvirtXMLNotFoundError which
requires importing the xcepts module, and line 310 instantiates VMCPUXML() which
requires importing the VMCPUXML class. Add both imports in the appropriate
import section of the file alongside other existing imports from the virttest
library and related modules.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e6b177d6-e1b8-405f-9e42-e30df56d2015

📥 Commits

Reviewing files that changed from the base of the PR and between c96ab65 and 647f95e.

📒 Files selected for processing (2)
  • libvirt/tests/cfg/libvirt_vcpu_plug_unplug.cfg
  • libvirt/tests/src/libvirt_vcpu_plug_unplug.py

Comment on lines +243 to +244
compat_mode = params.get("compat_mode")
cpu_model = params.get("cpu_model")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use explicit yes/no parsing for compat_mode to avoid false-positive activation.

Line 243 stores a raw string and Line 303 checks truthiness, so "no" would still enter compat-mode logic. Parse it like other flags in this file.

Suggested fix
-    compat_mode = params.get("compat_mode")
-    cpu_model =  params.get("cpu_model")
+    compat_mode = "yes" == params.get("compat_mode", "no")
+    cpu_model = params.get("cpu_model")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libvirt/tests/src/libvirt_vcpu_plug_unplug.py` around lines 243 - 244, The
compat_mode variable at line 243 is assigned a raw string from params.get(),
which causes a false-positive when checked with if compat_mode at line 303,
since the string "no" is still truthy. Replace the assignment of compat_mode
with explicit boolean parsing using the same pattern as other boolean flags in
this file (likely params.get_bool() or equivalent), so that string values like
"no" are properly parsed as False instead of being treated as truthy.

Comment on lines +307 to +310
cpu_xml = vmxml.cpu
except xcepts.LibvirtXMLNotFoundError:
logging.debug("No CPU element found, creating new one")
cpu_xml = VMCPUXML()

Copy link
Copy Markdown

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

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Verify canonical definitions/import patterns for these symbols in this repo.
rg -n "class VMCPUXML|LibvirtXMLNotFoundError" -C2
rg -n "from virttest\.libvirt_xml import xcepts|from virttest\.libvirt_xml\.vm_xml import .*VMCPUXML" -C2

Repository: autotest/tp-libvirt

Length of output: 37962


🏁 Script executed:

head -50 libvirt/tests/src/libvirt_vcpu_plug_unplug.py | cat -n

Repository: autotest/tp-libvirt

Length of output: 1896


🏁 Script executed:

sed -n '305,315p' libvirt/tests/src/libvirt_vcpu_plug_unplug.py | cat -n

Repository: autotest/tp-libvirt

Length of output: 543


Import xcepts and VMCPUXML to fix undefined name errors.

The exception handler at line 308 references xcepts.LibvirtXMLNotFoundError, and line 310 instantiates VMCPUXML(), but neither is imported. This will raise NameError when the fallback path executes.

Fix
 from virttest.libvirt_xml.vm_xml import VMXML
+from virttest.libvirt_xml import xcepts
+from virttest.libvirt_xml.vm_xml import VMCPUXML

Or combine into a single import line:

-from virttest.libvirt_xml.vm_xml import VMXML
+from virttest.libvirt_xml import xcepts
+from virttest.libvirt_xml.vm_xml import VMXML, VMCPUXML
🧰 Tools
🪛 Ruff (0.15.17)

[error] 308-308: Undefined name xcepts

(F821)


[error] 310-310: Undefined name VMCPUXML

(F821)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libvirt/tests/src/libvirt_vcpu_plug_unplug.py` around lines 307 - 310, Add
the missing imports at the top of the libvirt_vcpu_plug_unplug.py file to
resolve the NameError exceptions. The exception handler at line 308 references
xcepts.LibvirtXMLNotFoundError which requires importing the xcepts module, and
line 310 instantiates VMCPUXML() which requires importing the VMCPUXML class.
Add both imports in the appropriate import section of the file alongside other
existing imports from the virttest library and related modules.

Source: Linters/SAST tools

@Anushree-Mathur

Copy link
Copy Markdown
Contributor Author

I request maintainers to merge below patch first, otherwise it will be a conflict between patches!
#6898

Thank you,
Anushree Mathur

@Anushree-Mathur

Copy link
Copy Markdown
Contributor Author

All testcases were passing while running it on P11 system

 (01/21) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: STARTED
 (01/21) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: PASS (93.34 s)
 (02/21) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_compat_mode: STARTED
 (02/21) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_compat_mode: PASS (314.68 s)
 (03/21) io-github-autotest-libvirt.remove_guest.without_disk: STARTED
 (03/21) io-github-autotest-libvirt.remove_guest.without_disk: PASS (7.24 s)
 (04/21) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: STARTED
 (04/21) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: PASS (93.67 s)
 (05/21) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_compat_mode: STARTED
 (05/21) type_specific.io-github-autotest-libvirt.libvirt_vcpu_plug_unplug.positive_test.vcpu_set.live.with_compat_mode: PASS (314.36 s)
 (06/21) io-github-autotest-libvirt.remove_guest.without_disk: STARTED
 (06/21) io-github-autotest-libvirt.remove_guest.without_disk: PASS (7.26 s)
 (07/21) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: STARTED
 (07/21) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: PASS (92.56 s)

Testcases are not running on P10 lpar
I can see that only 14 testcases will run that is import and remove the guest!


 (01/14) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native: STARTED
^C (01/14) io-github-autotest-qemu.unattended_install.import.import.default_install.aio_native:

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