Skip to content

Conversation

@leidwang
Copy link
Contributor

@leidwang leidwang commented Dec 12, 2025

ID:4798

Summary by CodeRabbit

  • New Features

    • Added a Windows-only VSock data-transfer test to validate host–guest file transfers over VSOCK with configurable transfer port.
    • End-to-end MD5 checksum verification to ensure data integrity after transfer.
  • Tests

    • Automates deployment of test tooling into the guest, generates random test data, runs sender/receiver concurrently, and verifies results and logs end-to-end.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 12, 2025

Walkthrough

Adds a new Windows-only VSock data transfer test consisting of a config file qemu/tests/cfg/vsock_transfer_data.cfg and a test module qemu/tests/vsock_transfer_data.py. The module introduces a VSockTransfer class with methods to run a guest-side server thread, a host-side client thread, and a run method to coordinate both. A module-level run(test, params, env) function boots and logs into the guest, copies or locates the test tool, generates source data, constructs server and client commands (including send/receive templates and VSock port), executes the transfer, verifies MD5 checksums between host and guest, logs results, and closes the session.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Thread synchronization and signaling between server_thread and client_thread.
  • Construction, quoting/escaping, and execution of guest-side and host-side command lines.
  • File generation, transfer, and MD5 checksum computation/verification across host and guest.
  • Session lifecycle, thread joining, and error/exception handling.

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 accurately describes the main change: adding a script to test data transfer via vsock, which is exactly what the two new files (config and Python test script) accomplish.
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

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b9ff9c and 73bbfc5.

📒 Files selected for processing (2)
  • qemu/tests/cfg/vsock_transfer_data.cfg (1 hunks)
  • qemu/tests/vsock_transfer_data.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • qemu/tests/vsock_transfer_data.py
  • qemu/tests/cfg/vsock_transfer_data.cfg

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46fefae and a0963ab.

📒 Files selected for processing (2)
  • qemu/tests/cfg/vsock_transfer_data.cfg (1 hunks)
  • qemu/tests/vsock_transfer_data.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
qemu/tests/vsock_transfer_data.py (1)
provider/win_driver_utils.py (1)
  • get_driver_inf_path (123-155)
🔇 Additional comments (1)
qemu/tests/cfg/vsock_transfer_data.cfg (1)

1-21: Configuration is correctly implemented.

The vsock_transfer_data test configuration properly separates host and guest commands: dd and socat execute on the Linux host via process.system_output(), while certutil and the viosocklib test tool execute in the Windows guest via session.cmd_output(). The test module correctly retrieves and applies these parameters, with the send_data_cmd properly formatted with the guest CID at runtime (line 79 of vsock_transfer_data.py). All configuration parameters are used as intended.

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

♻️ Duplicate comments (6)
qemu/tests/vsock_transfer_data.py (6)

18-21: Critical race condition: server_ready signal set prematurely.

This issue was previously flagged and remains unresolved. The server_ready event is set at line 19 before the server command at line 20 actually starts executing or becomes ready to accept connections. This creates a race where the client thread may attempt to connect before the server is listening.

Additionally:

  • session.cmd_output(cmd) has no timeout and will block indefinitely if the command hangs
  • Exceptions are not caught, so thread failures will be silent

</review_comment_end -->


23-27: Add timeout and error handling; reconsider hard-coded sleep.

This issue was previously flagged and remains unresolved. The client thread has several issues:

  1. Line 25: The hard-coded 1-second sleep is a brittle timing assumption that may be insufficient if the server takes longer to initialize
  2. Line 26: process.system_output(cmd) has no timeout and will hang indefinitely if the command stalls
  3. No exception handling means errors are silently lost

</review_comment_end -->


46-47: Update docstring to match actual test purpose.

This issue was previously flagged. The docstring says "Vsock bridge service test" but the test is actually for vsock data transfer validation, as indicated by the test name and implementation.

</review_comment_end -->


64-68: Critical: Validate array access and device retrieval.

These issues were previously flagged and remain unresolved:

Line 67 uses split()[0] without verifying the list is non-empty, which will raise an IndexError if params["vsocks"] is empty or whitespace-only.

Line 68 retrieves a device and parameter without validating they exist, which can result in None or raise exceptions if the vsock device is not properly configured.

</review_comment_end -->


70-74: Add validation and ensure cleanup of generated files.

These issues were previously flagged and remain unresolved:

Line 72 performs string manipulation (path.rfind("\\")) without validating that the backslash exists, potentially resulting in incorrect paths.

Line 73 copies the test tool without verifying the source file exists.

Line 74 generates a 100MB test file on the host without any cleanup mechanism, which will accumulate over repeated test runs.

</review_comment_end -->


82-90: Critical: Validate array access and normalize MD5 comparison.

These issues were previously flagged and remain unresolved:

Lines 84 and 86 perform array access without validation:

  • Line 84: split()[0] will raise IndexError if md5sum output is empty or malformed
  • Line 86: splitlines()[1] will raise IndexError if certutil output has fewer than 2 lines

Additionally, line 87 compares MD5 hashes as raw strings without normalization (case-insensitive, strip whitespace), which could cause false failures.

</review_comment_end -->

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0963ab and 8ad7827.

📒 Files selected for processing (2)
  • qemu/tests/cfg/vsock_transfer_data.cfg (1 hunks)
  • qemu/tests/vsock_transfer_data.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
qemu/tests/vsock_transfer_data.py (1)
provider/win_driver_utils.py (1)
  • get_driver_inf_path (123-155)

@leidwang leidwang force-pushed the issue4798 branch 2 times, most recently from 8b9ff9c to 2215553 Compare December 12, 2025 03:03
@leidwang
Copy link
Contributor Author

JOB LOG : /root/avocado/job-results/job-2025-12-12T00.31-37ee4b8/job.log
(1/1) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.vsock_transfer_data.q35: STARTED
(1/1) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.Win2022.x86_64.io-github-autotest-qemu.vsock_transfer_data.q35: PASS (99.16 s)

@leidwang
Copy link
Contributor Author

Hi @JinLiul Could you please help review this PR?Thanks.

@JinLiul
Copy link
Contributor

JinLiul commented Dec 22, 2025

LGTM.

@vivianQizhu
Copy link
Contributor

@leidwang Do we have vsock data transfer test existed for Linux? Is that possible to reuse some of the test?

@leidwang
Copy link
Contributor Author

leidwang commented Jan 8, 2026

@leidwang Do we have vsock data transfer test existed for Linux? Is that possible to reuse some of the test?

Yes, there are. However, Windows testing and Linux testing have many different configurations and steps, and currently Linux test scripts combine many different vsock test scenarios. Adding Windows vsock testing to the current Linux test script would make the Linux script very complex, so I decided to write a separate script for Windows testing.Thanks!

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