Skip to content

Add guest boot sanity tests with passthrough device support - #4372

Open
dhsrivas wants to merge 1 commit into
autotest:masterfrom
dhsrivas:qemu_pci_pass
Open

Add guest boot sanity tests with passthrough device support#4372
dhsrivas wants to merge 1 commit into
autotest:masterfrom
dhsrivas:qemu_pci_pass

Conversation

@dhsrivas

@dhsrivas dhsrivas commented Sep 1, 2025

Copy link
Copy Markdown
 Add test and configurations to validate the following scenarios:

1. Launch guests in different guest interrupt modes:
   a. AVIC
   b. APIC
   c. x2APIC
   d. x2AVIC
2. Boot the above guests with vCPU counts: 512, 288, 256, 254, 128, 64
3. Boot guests with PCI passthrough devices.
4. Boot guests with emulated AMD IOMMU and emulated Intel IOMMU.

Notes:
1. AVIC and APIC support fewer than 255 vCPUs.
2. x2APIC and x2AVIC modes require extended-apicid=on, or the presence
   of emulated AMD IOMMU / emulated Intel IOMMU, to support booting with
   >255 vCPUs.

This patch depends on

Summary by CodeRabbit

Release Notes

  • Tests
    • Added test configurations for PCI passthrough scenarios with multiple IOMMU and CPU virtualization mode combinations.
    • Added guest boot sanity test for VFIO PCI passthrough across various APIC and virtualization modes.

@dhsrivas
dhsrivas force-pushed the qemu_pci_pass branch 2 times, most recently from 0c55772 to 5f97b03 Compare September 1, 2025 21:15
@coderabbitai

coderabbitai Bot commented Oct 16, 2025

Copy link
Copy Markdown

Walkthrough

Adds four new QEMU test configuration files under qemu/tests/cfg (emulated_amd_iommu.cfg, iommu_accelerated_guest_mode.cfg, iommu_guest_mode.cfg, vfio_pci_passthrough.cfg) that define PCI passthrough/IOMMU test matrices with multiple vCPU topologies, APIC/AVIC/x2APIC modes, and host constraints (Linux, x86_64, AMD). Adds qemu/tests/qemu_pci_passthrough.py, a test implementation that checks host AVIC/x2AVIC support, prepares and binds PCI devices to vfio-pci, boots/configures the VM with IOMMU options, verifies dmesg for APIC modes, collects guest details, and performs cleanup including device unbind/rebind.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ 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 'Add guest boot sanity tests with passthrough device support' accurately reflects the main changes: new test configurations and a test implementation for guest boot validation with PCI passthrough device support across multiple interrupt modes and vCPU configurations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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: 1

🧹 Nitpick comments (8)
qemu/tests/cfg/emulated_amd_iommu.cfg (2)

21-24: Fill the TODO: add passthrough variant (device required to validate IOMMU).

Add a variant that sets pci_device to a valid host BDF and exercises AMD IOMMU with a real device; otherwise this config never validates remapping paths.

I can propose a variant block wired to vfio_pci_passthrough.cfg conventions if you share the target device format.


1-3: Gate all AMD-IOMMU variants on minimum QEMU version.

required_qemu = [8.2.90,) appears only under no_passthrough. The AMD IOMMU device and flags should be version-gated across all variants.

Apply at the top-level or duplicate under x2apic_emul_amd_iommu and x2avic_emul_amd_iommu.

Also applies to: 50-57

qemu/tests/cfg/iommu_accelerated_guest_mode.cfg (1)

52-65: Document host prerequisites for AVIC/x2AVIC runs.

Given kvm_probe_module_parameters = "avic=1", add a brief note/guard that kvm_amd must be (re)loaded with avic=1 and that msr-tools is available for probes, to reduce false positives and test flakiness.

qemu/tests/cfg/vfio_pci_passthrough.cfg (1)

12-14: Align irqchip setting with other configs.

Consider adding machine_type_extra_params = "kernel-irqchip=split" here too for consistency with the x86 test matrix, especially when mixing large vCPU counts and x2APIC modes.

qemu/tests/cfg/iommu_guest_mode.cfg (1)

63-69: Clarify Intel IOMMU emulation on AMD host.

Since only HostCpuVendor.amd is set, a short comment that intel_iommu = yes is intentionally emulated on AMD hosts would help avoid confusion.

qemu/tests/qemu_pci_passthrough.py (3)

128-139: Make device parsing robust and avoid repeated splits.

Use split() (any whitespace) once, validate, and iterate by value. This simplifies the loop and avoids empty entries.

Apply this refactor:

-            # Prepare for pci passthrough
-            for i in range(len(pci_device.split(" "))):
-                # Check if device input is valid
-                if pci_device.split(" ")[i] not in pci.get_pci_addresses():
-                    test.cancel("Please provide valid pci device input.")
-
-                driver_list.append(pci.get_driver(pci_device.split(" ")[i]))
-                pci.attach_driver(pci_device.split(" ")[i], "vfio-pci")
-                params["extra_params"] += (
-                    f" -device vfio-pci,host={pci_device.split(' ')[i]}"
-                )
+            # Prepare for pci passthrough
+            devices = [d for d in pci_device.split() if d]
+            for dev in devices:
+                if dev not in pci.get_pci_addresses():
+                    test.cancel("Please provide valid pci device input.")
+                driver_list.append(pci.get_driver(dev))
+                pci.attach_driver(dev, "vfio-pci")
+                params["extra_params"] += f" -device vfio-pci,host={dev}"

57-70: Guard rdmsr calls; cancel gracefully when msr-tools is missing.

process.run() will error if rdmsr is not installed. Convert to a guarded call and cancel with a clear message.

Apply pattern to both support checks:

-            out = process.run(cmd, sudo=True, shell=True).stdout_text.strip()
+            try:
+                out = process.run(cmd, sudo=True, shell=True).stdout_text.strip()
+            except process.CmdError as e:
+                test.cancel(f"msr-tools (rdmsr) not available or failed: {e}")

78-85: Avoid stale dmesg matches; clear or bound log window before checks.

check_kernel_logs() can match older lines. Clear dmesg (or start a watcher) before enabling AVIC/x2AVIC, then check.

For example, call a dmesg reset before module setup:

  • dmesg.clear_dmesg() prior to AVIC enablement
  • then run checks for "AVIC enabled" and "x2AVIC enabled"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02fbc5f and 6836866.

📒 Files selected for processing (5)
  • qemu/tests/cfg/emulated_amd_iommu.cfg (1 hunks)
  • qemu/tests/cfg/iommu_accelerated_guest_mode.cfg (1 hunks)
  • qemu/tests/cfg/iommu_guest_mode.cfg (1 hunks)
  • qemu/tests/cfg/vfio_pci_passthrough.cfg (1 hunks)
  • qemu/tests/qemu_pci_passthrough.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
qemu/tests/qemu_pci_passthrough.py (1)
provider/storage_benchmark.py (1)
  • session (83-90)
🔇 Additional comments (1)
qemu/tests/qemu_pci_passthrough.py (1)

113-122: Ensure kvm_amd is actually (re)loaded with avic=1.

The test only validates via dmesg; it doesn’t enforce loading kvm_amd with the requested parameter. Confirm the harness applies kvm_probe_module_parameters or explicitly (re)load kvm_amd with that param here.

If not already handled by the framework, add:

  • linux_modules.configure_module("kvm_amd", "CONFIG_KVM_AMD", module_parameters=kvm_probe_module_parameters)

Comment on lines +163 to +173
if pci_device != "":
for i in range(len(pci_device.split(" "))):
if pci_device.split(" ")[i] not in pci.get_pci_addresses():
break
if driver_list[i] is None:
cur_driver = pci.get_driver(pci_device.split(" ")[i])
if cur_driver is not None:
pci.unbind(cur_driver, pci_device.split(" ")[i])
else:
pci.attach_driver(pci_device.split(" ")[i], driver_list[i])
except ValueError as e:

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

Fix cleanup: original driver not restored; loop breaks early; may leave devices bound to vfio.

  • Using break skips remaining devices.
  • Restoring logic runs only when driver_list[i] is None, which is inverted, and can call attach_driver(..., None).

Apply this diff to correctly unbind vfio and restore original drivers:

-            if pci_device != "":
-                for i in range(len(pci_device.split(" "))):
-                    if pci_device.split(" ")[i] not in pci.get_pci_addresses():
-                        break
-                    if driver_list[i] is None:
-                        cur_driver = pci.get_driver(pci_device.split(" ")[i])
-                        if cur_driver is not None:
-                            pci.unbind(cur_driver, pci_device.split(" ")[i])
-                        else:
-                            pci.attach_driver(pci_device.split(" ")[i], driver_list[i])
+            if pci_device:
+                devices = [d for d in pci_device.split() if d]
+                for idx, dev in enumerate(devices):
+                    if dev not in pci.get_pci_addresses():
+                        continue
+                    cur_driver = pci.get_driver(dev)
+                    if cur_driver == "vfio-pci":
+                        pci.unbind("vfio-pci", dev)
+                    orig_driver = driver_list[idx] if idx < len(driver_list) else None
+                    if orig_driver:
+                        pci.attach_driver(dev, orig_driver)
📝 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
if pci_device != "":
for i in range(len(pci_device.split(" "))):
if pci_device.split(" ")[i] not in pci.get_pci_addresses():
break
if driver_list[i] is None:
cur_driver = pci.get_driver(pci_device.split(" ")[i])
if cur_driver is not None:
pci.unbind(cur_driver, pci_device.split(" ")[i])
else:
pci.attach_driver(pci_device.split(" ")[i], driver_list[i])
except ValueError as e:
if pci_device:
devices = [d for d in pci_device.split() if d]
for idx, dev in enumerate(devices):
if dev not in pci.get_pci_addresses():
continue
cur_driver = pci.get_driver(dev)
if cur_driver == "vfio-pci":
pci.unbind("vfio-pci", dev)
orig_driver = driver_list[idx] if idx < len(driver_list) else None
if orig_driver:
pci.attach_driver(dev, orig_driver)
except ValueError as e:
🤖 Prompt for AI Agents
In qemu/tests/qemu_pci_passthrough.py around lines 163-173, the rollback loop
breaks early, repeatedly calls split(" ") and inverts the restore logic (can
call attach_driver with None); fix by precomputing addresses =
pci_device.split(" "), iterate with for i, addr in enumerate(addresses) (no
break — use continue), skip addresses not present via if addr not in
pci.get_pci_addresses(): continue, and on cleanup for each present addr: if
driver_list[i] is not None call pci.attach_driver(addr, driver_list[i]) to
restore the original driver, else obtain cur_driver = pci.get_driver(addr) and
if cur_driver is not None call pci.unbind(cur_driver, addr) to unbind any
temporary driver (this avoids attaching None and ensures all devices are
processed).

@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

♻️ Duplicate comments (1)
qemu/tests/qemu_pci_passthrough.py (1)

164-176: Cleanup logic has multiple bugs: break skips remaining devices, potential IndexError on driver_list.

The past review already identified these issues. The break on line 168 should be continue, repeated pci_device.split(" ") calls should be pre-computed, and driver_list[i] can raise IndexError if the setup loop was interrupted before all devices were processed. Please address the fix suggested in the previous review.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@qemu/tests/qemu_pci_passthrough.py` around lines 164 - 176, The cleanup loop
incorrectly calls pci_device.split(" ") repeatedly, uses break (which skips
remaining devices) and can IndexError on driver_list; fix by precomputing
addresses = pci_device.split(" "), iterate for i, addr in enumerate(addresses),
replace the break with continue when addr not in pci.get_pci_addresses(), and
guard driver access (e.g., only use driver_list[i] if i < len(driver_list) or
iterate over zip(addresses, driver_list) when appropriate); keep existing calls
to pci.get_driver(addr), pci.unbind(cur_driver, addr) and
pci.attach_driver(addr, driver) but reference the precomputed addr variable.
🧹 Nitpick comments (2)
qemu/tests/cfg/emulated_amd_iommu.cfg (1)

49-57: Consider reducing duplication between the two IOMMU variants.

The cpu_model_flags and extra_params lines are identical between x2apic_emul_amd_iommu and x2avic_emul_amd_iommu — only kvm_probe_module_parameters differs. You could hoist the shared settings above the variants block to reduce duplication and make future maintenance easier.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@qemu/tests/cfg/emulated_amd_iommu.cfg` around lines 49 - 57, The two variant
entries x2apic_emul_amd_iommu and x2avic_emul_amd_iommu duplicate
cpu_model_flags and extra_params; move those shared keys (cpu_model_flags +=
",+x2apic" and extra_params += " -device amd-iommu,intremap=on,xtsup=on") out of
the per-variant blocks into a common scope above the variants list, and leave
only the differing kvm_probe_module_parameters ("avic=0" vs "avic=1") inside
each variant so the variants only define their unique setting.
qemu/tests/qemu_pci_passthrough.py (1)

99-112: Consider using the command itself as the log label instead of generic "Debug".

Using "Debug: %s" for all 8 commands makes logs harder to scan. Using the command name as context (e.g., "lscpu output: %s") would improve log readability.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@qemu/tests/qemu_pci_passthrough.py` around lines 99 - 112, The
guest_system_details helper uses identical log labels ("Debug: %s") for multiple
command outputs; update each test.log.debug call in the guest_system_details
function to include the command name or the command string as the label (e.g.,
"os-release: %s", "uname -a: %s", "lspci -k: %s", "lscpu: %s", etc.) so each
debug line clearly indicates which command produced the output; locate the
test.log.debug calls in guest_system_details and replace the generic label with
the corresponding command-specific label.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@qemu/tests/qemu_pci_passthrough.py`:
- Around line 125-141: Pre-compute the device list to avoid repeated splitting
and use split() (not split(" ")) to avoid empty entries: create a local variable
like devices = pci_device.split() before the loop, then iterate for device in
devices; inside the loop replace every pci_device.split(" ")[i] with device when
calling prepare_pci_passthrough(), pci.get_pci_addresses(),
driver_list.append(pci.get_driver(device)), pci.attach_driver(device,
"vfio-pci") and when appending to params["extra_params"] so the checks
(pci.get_pci_addresses()) and updates (driver_list, pci.attach_driver,
params["extra_params"]) operate on the precomputed list and avoid redundant
splits.
- Around line 144-152: The code currently uses broad except Exception blocks
around env_process.preprocess_vm / vm.verify_alive and vm.wait_for_login which
will swallow avocado framework exceptions (TestCancel, TestError, TestFail);
update both try/except blocks to first except and re-raise these framework
exceptions (TestCancel, TestError, TestFail) and then handle other exceptions by
calling test.fail with the original error message so framework outcomes are
preserved; reference the existing symbols env_process.preprocess_vm,
vm.verify_alive, vm.wait_for_login, and test.fail when making the change.

---

Duplicate comments:
In `@qemu/tests/qemu_pci_passthrough.py`:
- Around line 164-176: The cleanup loop incorrectly calls pci_device.split(" ")
repeatedly, uses break (which skips remaining devices) and can IndexError on
driver_list; fix by precomputing addresses = pci_device.split(" "), iterate for
i, addr in enumerate(addresses), replace the break with continue when addr not
in pci.get_pci_addresses(), and guard driver access (e.g., only use
driver_list[i] if i < len(driver_list) or iterate over zip(addresses,
driver_list) when appropriate); keep existing calls to pci.get_driver(addr),
pci.unbind(cur_driver, addr) and pci.attach_driver(addr, driver) but reference
the precomputed addr variable.

---

Nitpick comments:
In `@qemu/tests/cfg/emulated_amd_iommu.cfg`:
- Around line 49-57: The two variant entries x2apic_emul_amd_iommu and
x2avic_emul_amd_iommu duplicate cpu_model_flags and extra_params; move those
shared keys (cpu_model_flags += ",+x2apic" and extra_params += " -device
amd-iommu,intremap=on,xtsup=on") out of the per-variant blocks into a common
scope above the variants list, and leave only the differing
kvm_probe_module_parameters ("avic=0" vs "avic=1") inside each variant so the
variants only define their unique setting.

In `@qemu/tests/qemu_pci_passthrough.py`:
- Around line 99-112: The guest_system_details helper uses identical log labels
("Debug: %s") for multiple command outputs; update each test.log.debug call in
the guest_system_details function to include the command name or the command
string as the label (e.g., "os-release: %s", "uname -a: %s", "lspci -k: %s",
"lscpu: %s", etc.) so each debug line clearly indicates which command produced
the output; locate the test.log.debug calls in guest_system_details and replace
the generic label with the corresponding command-specific label.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6836866 and c327b45.

📒 Files selected for processing (5)
  • qemu/tests/cfg/emulated_amd_iommu.cfg
  • qemu/tests/cfg/iommu_accelerated_guest_mode.cfg
  • qemu/tests/cfg/iommu_guest_mode.cfg
  • qemu/tests/cfg/vfio_pci_passthrough.cfg
  • qemu/tests/qemu_pci_passthrough.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • qemu/tests/cfg/iommu_guest_mode.cfg
  • qemu/tests/cfg/iommu_accelerated_guest_mode.cfg

Comment on lines +125 to +141
# Passthrough device/s and validate if passthrough is successful
if pci_device != "":
# Perform pre-checks and prereq enablements before pci passthrough
prepare_pci_passthrough()

# Prepare for pci passthrough
for i in range(len(pci_device.split(" "))):
# Check if device input is valid
if pci_device.split(" ")[i] not in pci.get_pci_addresses():
test.cancel("Please provide valid pci device input.")

driver_list.append(pci.get_driver(pci_device.split(" ")[i]))
pci.attach_driver(pci_device.split(" ")[i], "vfio-pci")
params[
"extra_params"
] += f" -device vfio-pci,host={pci_device.split(' ')[i]}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Pre-compute the device list and use split() instead of split(" ").

pci_device.split(" ") is called 5 times per loop iteration, and split(" ") will produce empty strings if there are consecutive spaces. Split once before the loop and iterate over the result.

♻️ Proposed refactor
         # Passthrough device/s and validate if passthrough is successful
-        if pci_device != "":
+        devices = pci_device.split()
+        if devices:
             # Perform pre-checks and prereq enablements before pci passthrough
             prepare_pci_passthrough()
 
             # Prepare for pci passthrough
-            for i in range(len(pci_device.split(" "))):
+            for dev in devices:
                 # Check if device input is valid
-                if pci_device.split(" ")[i] not in pci.get_pci_addresses():
+                if dev not in pci.get_pci_addresses():
                     test.cancel("Please provide valid pci device input.")
 
-                driver_list.append(pci.get_driver(pci_device.split(" ")[i]))
-                pci.attach_driver(pci_device.split(" ")[i], "vfio-pci")
-                params[
-                    "extra_params"
-                ] += f" -device vfio-pci,host={pci_device.split(' ')[i]}"
+                driver_list.append(pci.get_driver(dev))
+                pci.attach_driver(dev, "vfio-pci")
+                params["extra_params"] += f" -device vfio-pci,host={dev}"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@qemu/tests/qemu_pci_passthrough.py` around lines 125 - 141, Pre-compute the
device list to avoid repeated splitting and use split() (not split(" ")) to
avoid empty entries: create a local variable like devices = pci_device.split()
before the loop, then iterate for device in devices; inside the loop replace
every pci_device.split(" ")[i] with device when calling
prepare_pci_passthrough(), pci.get_pci_addresses(),
driver_list.append(pci.get_driver(device)), pci.attach_driver(device,
"vfio-pci") and when appending to params["extra_params"] so the checks
(pci.get_pci_addresses()) and updates (driver_list, pci.attach_driver,
params["extra_params"]) operate on the precomputed list and avoid redundant
splits.

Comment on lines +144 to +152
try:
env_process.preprocess_vm(test, params, env, params.get("main_vm"))
vm.verify_alive()
except Exception as e:
test.fail(f"Failed to create VM: {str(e)}")
try:
session = vm.wait_for_login(timeout=login_timeout)
except Exception as e:
test.fail(f"Failed to login VM: {str(e)}")

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, check if the file imports avocado exceptions
echo "=== Checking imports in qemu_pci_passthrough.py ==="
cat -n qemu/tests/qemu_pci_passthrough.py | head -50

echo -e "\n=== Searching for avocado imports across codebase ==="
rg -n "from avocado" --type py | head -20

echo -e "\n=== Searching for avocado exception handling patterns ==="
rg -n "except.*TestCancel|except.*TestError|except.*TestFail" --type py | head -20

echo -e "\n=== Checking if avocado is installed or referenced ==="
rg -n "import avocado" --type py | head -10

Repository: autotest/tp-qemu

Length of output: 1714


🌐 Web query:

avocado test framework TestCancel TestError TestFail exception hierarchy

💡 Result:

In Avocado (the avocado-framework test runner), the core test exception hierarchy is:

Exception
└─ avocado.core.exceptions.TestBaseException   (status = "FAIL")
   ├─ avocado.TestError / avocado.core.exceptions.TestError    (status = "ERROR")
   ├─ avocado.TestCancel / avocado.core.exceptions.TestCancel  (status = "CANCEL")
   └─ avocado.TestFail / avocado.core.exceptions.TestFail      (status = "FAIL")
        └─ also inherits from AssertionError

Key points:

  • TestBaseException is the parent of all Avocado test exceptions and inherits from Python Exception. [1]
  • TestError and TestCancel inherit from TestBaseException. [1], [2]
  • TestFail inherits from both TestBaseException and AssertionError (for unittest-style failure compatibility). [1], [2]
  • These exceptions are exposed in the public avocado namespace as avocado.TestFail, avocado.TestError, avocado.TestCancel. [2], [3]

Sources
[1] Avocado core API docs (avocado.core.exceptions): (avocado-framework.readthedocs.io)
[2] Avocado Test API docs (avocado.TestFail/TestError/TestCancel): (avocado-framework.readthedocs.io)
[3] Avocado 52.0 LTS release notes (public availability + behavior equivalence): (avocado-framework.readthedocs.io)

Citations:


Broad except Exception will swallow avocado framework exceptions (TestCancel, TestError, TestFail).

In avocado, these framework exceptions inherit from Exception and are used to classify test results (cancellation, error, failure). Catching bare Exception here converts them to test.fail() calls, misclassifying test outcomes. Catch and re-raise framework exceptions before the broad exception handler.

Proposed fix
+        from avocado.core.exceptions import TestCancel, TestError, TestFail
         try:
             env_process.preprocess_vm(test, params, env, params.get("main_vm"))
             vm.verify_alive()
+        except (TestCancel, TestError, TestFail):
+            raise
         except Exception as e:
             test.fail(f"Failed to create VM: {str(e)}")
         try:
             session = vm.wait_for_login(timeout=login_timeout)
+        except (TestCancel, TestError, TestFail):
+            raise
         except Exception as e:
             test.fail(f"Failed to login VM: {str(e)}")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@qemu/tests/qemu_pci_passthrough.py` around lines 144 - 152, The code
currently uses broad except Exception blocks around env_process.preprocess_vm /
vm.verify_alive and vm.wait_for_login which will swallow avocado framework
exceptions (TestCancel, TestError, TestFail); update both try/except blocks to
first except and re-raise these framework exceptions (TestCancel, TestError,
TestFail) and then handle other exceptions by calling test.fail with the
original error message so framework outcomes are preserved; reference the
existing symbols env_process.preprocess_vm, vm.verify_alive, vm.wait_for_login,
and test.fail when making the change.

Add test and configurations to validate the following scenarios:

1. Launch guests in different guest interrupt modes:
   a. AVIC
   b. APIC
   c. x2APIC
   d. x2AVIC
2. Boot the above guests with vCPU counts: 512, 288, 256, 254, 128, 64
3. Boot guests with PCI passthrough devices.
4. Boot guests with emulated AMD IOMMU and emulated Intel IOMMU.

Notes:
1. AVIC and APIC support fewer than 255 vCPUs.
2. x2APIC and x2AVIC modes require extended-apicid=on, or the presence
   of emulated AMD IOMMU / emulated Intel IOMMU, to support booting with
   >255 vCPUs.

Signed-off-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
@dhsrivas

Copy link
Copy Markdown
Author

@YongxueHong , @zhencliu , @nickzhq Request your review comments. Thank you for your time.

@dhsrivas

Copy link
Copy Markdown
Author

@YongxueHong, @zhencliu, @nickzhq Gentle reminder for reviewing the patch.

@dhsrivas

Copy link
Copy Markdown
Author

@zhencliu @nickzhq Any feedback appreciated—thanks.

@crobinso

Copy link
Copy Markdown
Collaborator

@dhsrivas are you still interested in this patch? the original reviewers are no longer at redhat but we will be restarting reviews soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants