Skip to content

Conversation

qingwangrh
Copy link
Contributor

@qingwangrh qingwangrh commented Mar 12, 2025

ID:3493,4505

Summary by CodeRabbit

  • Tests

    • Enhanced block performance test infrastructure with improved disk verification procedures and multi-queue detection.
    • Added architecture-specific compatibility constraints to test configuration.
  • Chores

    • Optimized internal test code structure and streamlined configuration management.

@qingwangrh
Copy link
Contributor Author

python ConfigTest.py --testcase=block_performance_test.with_multi_queue --guestname=RHEL.9.6.0 --firmware=default_bios --clone=no

It can not hit same issue on same host (many cpus)

@qingwangrh qingwangrh force-pushed the 3493_fix_guest_check_mq_number branch from a8a0adb to e99aee7 Compare March 12, 2025 05:55
@qingwangrh
Copy link
Contributor Author

@XueqiangWei @fbq815 Please help to review, thanks.

XueqiangWei
XueqiangWei previously approved these changes Mar 12, 2025
Copy link
Contributor

@XueqiangWei XueqiangWei left a comment

Choose a reason for hiding this comment

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

LGTM,
Acked-by: [email protected]

@XueqiangWei
Copy link
Contributor

@fbq815 Could you please help to review it, thanks.

@fbq815
Copy link
Contributor

fbq815 commented Sep 17, 2025

@qingwangrh I've check but all the tests failed on s390x, could you please check details in jira task? I've check but all the tests failed on s390x, could you please check details in jira task? Also, this case is breaking my host environment when it failed, have you try to replace the bin in this case? I didn't find it by checking. I would get this after the case failed: [root@l47 yum.repos.d]# ls
-bash: /usr/bin/ls: cannot execute binary file: Exec format error

@fbq815
Copy link
Contributor

fbq815 commented Sep 26, 2025

@qingwangrh after offline discussion, there's some product issue block this test, maybe it's better if you link the product issue to the jira issue for this patch, thanks!

@qingwangrh
Copy link
Contributor Author

Some machines will hit This KVMAUTOMA-4505 block_performance_test: find wrong empty disk result in data corruption.
It is irrelevant with the patch.

@fbq815
Copy link
Contributor

fbq815 commented Oct 21, 2025

@qingwangrh after offline discussion, based on the issue mentioned, test environment enfluence and test strategy on s390x, I prefer you set this issue to x86 only, please help update test case and test case tracker google sheet as well.

@qingwangrh
Copy link
Contributor Author

@fbq815 Please re-test it. thanks

@fbq815
Copy link
Contributor

fbq815 commented Oct 23, 2025

After offline dicussion with @PaulYuuu, this case was not enabled on s390x before, the test strategy on s390x don't include performance and the original test would ruin the /usr/bin on my host. It's not really relate to this patch, but I cannot approve it, I suggest you set this as x86 only to merge it.

1. fix mq number count error
2. fix find empty disk error

There is error in previous code if it has big number queues.
It only count the first line result of command output.

Signed-off-by: qingwangrh <[email protected]>
@qingwangrh qingwangrh force-pushed the 3493_fix_guest_check_mq_number branch from 8d2bae4 to 68490bb Compare October 23, 2025 14:01
@coderabbitai
Copy link

coderabbitai bot commented Oct 23, 2025

Walkthrough

Updates to the block performance test module and configuration: removed unused import, enhanced disk validation with wipefs checks, simplified command output parsing, added architecture exclusions, and refined multi-queue detection command logic.

Changes

Cohort / File(s) Summary
Block Performance Test Updates
qemu/tests/block_performance_test.py
Removed unused re import. Enhanced umount with wipefs cleanup. Added pre-check in auto_select_disk to skip disks with existing signatures. Simplified check_default_mq parsing to direct integer conversion with debug logging.
Block Performance Test Configuration
qemu/tests/cfg/block_performance_test.cfg
Added no s390 s390x architecture exclusions. Commented out explicit disk selection. Updated check_default_mq_cmd to count mapped multi-queue entries via ls /sys/block/%s/mq/ -p|grep /|wc -l.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A rabbit hops through tests so bright,
Wipefs cleans the disks just right,
No s390x paths to roam,
Parsing cleaned, now feels like home!
Hopping faster, tests take flight!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "block_performance_test:fix mq number count error" accurately describes the core technical fix in this PR. The changes show that the main modification addresses how the multi-queue (mq) number is counted: the check_default_mq_cmd is updated to use a different command for counting (using grep /|wc -l to count mapped entries), and the parsing logic is replaced with direct integer conversion. The title is concise, specific to the actual problem being solved, and clearly communicates the primary change that reviewers would see when scanning commit history.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

🧹 Nitpick comments (3)
qemu/tests/cfg/block_performance_test.cfg (1)

122-122: Consider a more robust directory counting approach.

The current command ls /sys/block/%s/mq/ -p|grep /|wc -l works but uses ls with output parsing, which is generally discouraged in scripts.

Consider this more robust alternative:

-                check_default_mq_cmd = "ls /sys/block/%s/mq/ -p|grep /|wc -l"
+                check_default_mq_cmd = "find /sys/block/%s/mq/ -mindepth 1 -maxdepth 1 -type d | wc -l"

That said, for the predictable /sys filesystem structure, the current approach should work reliably.

qemu/tests/block_performance_test.py (2)

432-433: Consider adding error handling to the cleanup command.

The addition of wipefs -a is good for ensuring clean disk state. However, the current command uses forced lazy unmount (-fl) and has no error checking.

Consider making the cleanup more robust:

-        umount_cmd = "umount -fl %s;sleep 3; wipefs -a %s;" % (fio_dir, disk)
+        umount_cmd = "umount -fl %s && sleep 3 && wipefs -a %s || true" % (fio_dir, disk)

Using && ensures wipefs only runs if umount succeeds, and || true prevents the cleanup from failing the test if the disk is already clean.


526-527: Add error handling for the int conversion.

The direct conversion to int is cleaner than string parsing, but lacks error handling if the command output is unexpected.

Consider adding validation:

-        default_mq_nums = int(session.cmd_output(check_default_mq_cmd))
-        logger.debug(default_mq_nums)
+        mq_output = session.cmd_output(check_default_mq_cmd).strip()
+        try:
+            default_mq_nums = int(mq_output)
+        except ValueError:
+            test.fail("Failed to parse mq count from output: %s" % mq_output)
+        logger.debug("Found %d mq queues", default_mq_nums)

This provides clearer error messages if the command output format changes.

📜 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 68490bb.

📒 Files selected for processing (2)
  • qemu/tests/block_performance_test.py (3 hunks)
  • qemu/tests/cfg/block_performance_test.cfg (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
qemu/tests/block_performance_test.py (2)
provider/storage_benchmark.py (1)
  • session (83-90)
qemu/deps/win_driver_install/win_driver_install.py (1)
  • cmd_output (12-28)
🔇 Additional comments (2)
qemu/tests/cfg/block_performance_test.cfg (2)

3-3: Architecture exclusion aligns with PR discussion.

The exclusion of s390 and s390x architectures directly addresses the test failures and host environment damage reported in the PR comments. As noted by fbq815, s390x test strategy does not include performance testing, and the test could break the host environment.


64-64: LGTM - allows enhanced auto-selection.

Commenting out the hard-coded disk selection enables the improved auto-selection logic with wipefs signature checks added in the Python test file.

Comment on lines +487 to +490
sig = process.getoutput("wipefs -ni %s 2>/dev/null" % name)
if sig:
logger.debug("Skip %s due to has signature: %s", name, sig)
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

Verify the wipefs command flags.

The command uses wipefs -ni but standard wipefs does not have an -i flag. The stderr redirection (2>/dev/null) will hide any "invalid option" errors, potentially causing the signature check to fail silently.

Please verify the correct wipefs syntax. If checking for signatures, consider:

-            sig = process.getoutput("wipefs -ni %s 2>/dev/null" % name)
+            sig = process.getoutput("wipefs -n %s 2>/dev/null" % name)

Let me verify the wipefs flags in the environment:


🏁 Script executed:

#!/bin/bash
# Check wipefs version and available flags
wipefs --help 2>&1 | grep -E "^\s*-[a-z]"

# Test the command syntax with a non-existent device to see the error
wipefs -ni /dev/null 2>&1 || true
wipefs -n /dev/null 2>&1 || true

Length of output: 89


The -n flag in wipefs means "Do not print a header line" (noheadings), not signature checking. The -a flag erases all available signatures, with the set of erased signatures restricted using the -t option. No -i flag exists in the official wipefs documentation.

The command wipefs -ni %s 2>/dev/null will silently fail because:

  1. The -i flag is invalid
  2. The stderr redirection hides the error message
  3. The signature check never actually executes

Fix the invalid wipefs flag.

Remove the -i flag:

-            sig = process.getoutput("wipefs -ni %s 2>/dev/null" % name)
+            sig = process.getoutput("wipefs -n %s 2>/dev/null" % name)

Note: This invokes wipefs without options to list signatures (the -n suppresses header output). If the intent is to erase signatures, use wipefs -a instead.

🤖 Prompt for AI Agents
In qemu/tests/block_performance_test.py around lines 487 to 490, the wipefs call
uses an invalid "-i" flag and redirects stderr so the failure is hidden; remove
the "-i" flag so wipefs lists signatures correctly (keep "-n" to suppress
headings) — if the original intent was to erase signatures instead of listing
them, replace the call with "wipefs -a" (and avoid redirecting stderr) so
signature removal is performed and errors are visible.

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.

3 participants