Skip to content

Conversation

@leidwang
Copy link
Contributor

@leidwang leidwang commented Dec 23, 2025

ID:4796

Summary by CodeRabbit

  • New Features
    • Added VirtIO Socket (VSock) support for Windows guests, enabling host–guest file transfers with MD5 integrity checks.
  • Tests
    • Added Windows test configuration and automated validation for VSock, including hotplug scenarios and transfer verification.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 23, 2025

Walkthrough

Adds Windows VirtIO Socket test support: introduces a VSockTransfer class and a viosock_test function in provider/win_driver_installer_test.py to perform threaded host–guest data transfers and MD5 verification on Windows guests. Adds a Windows-only test configuration block in qemu/tests/cfg/virtio_win_socket_test.cfg with tool paths, commands, and a hotplug variant. Updates qemu/tests/vsock_hotplug.py to branch on guest OS, invoking viosock_test for Windows guests while retaining existing tool discovery and transfer logic for non-Windows guests; also imports the new Windows test helper.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

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 'virtio_win_socket_test: vsock hotplug testing' accurately reflects the main changes in the changeset, which add VSock hotplug testing support for Windows VirtIO drivers.
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: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d63e29e and c021316.

📒 Files selected for processing (3)
  • provider/win_driver_installer_test.py
  • qemu/tests/cfg/virtio_win_socket_test.cfg
  • qemu/tests/vsock_hotplug.py
🧰 Additional context used
🧬 Code graph analysis (2)
qemu/tests/vsock_hotplug.py (3)
provider/win_driver_installer_test.py (1)
  • viosock_test (515-545)
qemu/tests/vsock_test.py (3)
  • compile_nc_vsock (13-41)
  • send_data_from_guest_to_host (118-158)
  • check_guest_vsock_conn_exit (161-178)
qemu/tests/vsock_negative_test.py (2)
  • check_data_received (11-26)
  • kill_host_receive_process (30-40)
provider/win_driver_installer_test.py (1)
provider/win_driver_utils.py (1)
  • get_driver_inf_path (123-155)
🔇 Additional comments (3)
qemu/tests/cfg/virtio_win_socket_test.cfg (1)

1-27: Configuration looks reasonable for Windows vsock hotplug testing.

The configuration correctly sets up Windows-specific vsock test parameters including tool paths, data transfer commands, and hotplug variant. The check_vsock_cmd now outputs all present devices, and the device_pattern is used for matching.

provider/win_driver_installer_test.py (1)

32-32: LGTM! Driver list entries are correctly added.

The viosock driver, its hardware IDs, and device name are properly added in parallel to the existing lists.

Also applies to: 47-47, 62-62

qemu/tests/vsock_hotplug.py (1)

8-8: Import added for Windows vsock test support.

The import of viosock_test from provider.win_driver_installer_test correctly enables Windows-specific vsock handling.


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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
qemu/tests/vsock_hotplug.py (1)

54-77: Fix variable scope issue causing pipeline failure.

The variable device_str is only assigned in the else block (line 59) for Linux, but is used unconditionally in the dmesg_check block (lines 62-77). When os_type == "windows", device_str is never defined, causing a NameError and the reported pylint error E0606.

🔎 Proposed fix
 output = session.cmd_output(check_vsock_cmd)
 if os_type == "windows":
     print("%s %s" % (device_pattern, output))
     if device_pattern not in output:
         test.fail('Not find vsock device: "%s"' % device_pattern)
+    device_str = None  # Windows doesn't need device_str for dmesg check
 else:
     device_str = re.findall(r"%s\s%s" % (addr_pattern, device_pattern), output)

 if params.get("dmesg_check") == "yes":
+    if device_str is None:
+        test.log.info("Skipping dmesg check for Windows")
+    elif not device_str:
-    if not device_str:
         test.fail('check_vsock_cmd failed, no device "%s"' % device_pattern)
     else:

Alternatively, restructure to only perform dmesg check for Linux:

 output = session.cmd_output(check_vsock_cmd)
 if os_type == "windows":
     print("%s %s" % (device_pattern, output))
     if device_pattern not in output:
         test.fail('Not find vsock device: "%s"' % device_pattern)
 else:
     device_str = re.findall(r"%s\s%s" % (addr_pattern, device_pattern), output)
-
-if params.get("dmesg_check") == "yes":
-    if not device_str:
-        test.fail('check_vsock_cmd failed, no device "%s"' % device_pattern)
-    else:
-        address = re.findall(addr_pattern, device_str[0])[0]
-        chk_dmesg_cmd = "dmesg"
-        output = re.findall(address, session.cmd_output(chk_dmesg_cmd))
-        if not output:
-            test.fail("dmesg failed, no info related to %s" % address)
-        else:
-            error_msg = ""
-            for o in output:
-                if re.search(r"fail|error", o, re.I):
-                    error_msg += "%s" % o
-                    break
-            if error_msg:
-                test.fail("dmesg check failed: %s" % error_msg)
+    
+    if params.get("dmesg_check") == "yes":
+        if not device_str:
+            test.fail('check_vsock_cmd failed, no device "%s"' % device_pattern)
+        else:
+            address = re.findall(addr_pattern, device_str[0])[0]
+            chk_dmesg_cmd = "dmesg"
+            output = re.findall(address, session.cmd_output(chk_dmesg_cmd))
+            if not output:
+                test.fail("dmesg failed, no info related to %s" % address)
+            else:
+                error_msg = ""
+                for o in output:
+                    if re.search(r"fail|error", o, re.I):
+                        error_msg += "%s" % o
+                        break
+                if error_msg:
+                    test.fail("dmesg check failed: %s" % error_msg)
🧹 Nitpick comments (1)
qemu/tests/vsock_hotplug.py (1)

99-101: Use already-defined os_type variable for consistency.

Line 100 calls params.get("os_type") again, but os_type was already fetched at line 34. Using the existing variable improves consistency and avoids redundant dictionary lookups.

🔎 Proposed fix
 finally:
     # For windows testing, transfer_file() will remove the file
-    if params.get("os_type") == "linux":
+    if os_type == "linux":
         session.cmd_output("rm -f %s" % tmp_file)
     session.close()
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89b4300 and b36a2c5.

📒 Files selected for processing (3)
  • provider/win_driver_installer_test.py
  • qemu/tests/cfg/virtio_win_socket_test.cfg
  • qemu/tests/vsock_hotplug.py
🧰 Additional context used
🪛 GitHub Actions: CI
qemu/tests/vsock_hotplug.py

[error] 62-62: pylint: E0606 - Possibly using variable 'device_str' before assignment (possibly-used-before-assignment). Command: 'pylint .'


[error] 1-1: Process completed with exit code 2.

🔇 Additional comments (2)
provider/win_driver_installer_test.py (1)

32-32: LGTM! Driver list additions are consistent.

The viosock driver has been properly added to all three parallel lists (driver names, HWIDs, and device names), maintaining consistency with the existing pattern.

Also applies to: 47-47, 62-62

qemu/tests/vsock_hotplug.py (1)

8-8: LGTM! Import added for Windows vsock testing.

The import of viosock_test from provider.win_driver_installer_test is appropriate for the Windows-specific vsock data transfer path.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
qemu/tests/vsock_hotplug.py (1)

53-77: Fix: device_str is undefined when os_type == "windows".

The pipeline failure (Pylint E0606) correctly identifies that device_str is only assigned in the else branch (line 59), but the dmesg_check block (lines 61-77) references it unconditionally. If a Windows test runs with dmesg_check == "yes", this will cause a NameError.

🔎 Proposed fix
     output = session.cmd_output(check_vsock_cmd)
     if os_type == "windows":
         print("%s %s" % (device_pattern, output))
         if device_pattern not in output:
             test.fail('Not find vsock device: "%s"' % device_pattern)
     else:
         device_str = re.findall(r"%s\s%s" % (addr_pattern, device_pattern), output)

-    if params.get("dmesg_check") == "yes":
+        if params.get("dmesg_check") == "yes":
-        if not device_str:
-            test.fail('check_vsock_cmd failed, no device "%s"' % device_pattern)
-        else:
-            address = re.findall(addr_pattern, device_str[0])[0]
-            chk_dmesg_cmd = "dmesg"
-            output = re.findall(address, session.cmd_output(chk_dmesg_cmd))
-            if not output:
-                test.fail("dmesg failed, no info related to %s" % address)
+            if not device_str:
+                test.fail('check_vsock_cmd failed, no device "%s"' % device_pattern)
             else:
-                error_msg = ""
-                for o in output:
-                    if re.search(r"fail|error", o, re.I):
-                        error_msg += "%s" % o
-                        break
-                if error_msg:
-                    test.fail("dmesg check failed: %s" % error_msg)
+                address = re.findall(addr_pattern, device_str[0])[0]
+                chk_dmesg_cmd = "dmesg"
+                output = re.findall(address, session.cmd_output(chk_dmesg_cmd))
+                if not output:
+                    test.fail("dmesg failed, no info related to %s" % address)
+                else:
+                    error_msg = ""
+                    for o in output:
+                        if re.search(r"fail|error", o, re.I):
+                            error_msg += "%s" % o
+                            break
+                    if error_msg:
+                        test.fail("dmesg check failed: %s" % error_msg)

This moves the dmesg_check block inside the Linux (else) branch since dmesg is a Linux-only command and device_str is only available there.

♻️ Duplicate comments (2)
provider/win_driver_installer_test.py (1)

470-479: Race condition: server_ready is signaled before server is actually listening.

The server_ready.set() is called before session.cmd_output(cmd) executes the server command. This means the client may attempt to connect before the server is actually listening, causing a connection failure. The event should be set after the server is ready, but since session.cmd_output() is blocking, a different synchronization approach is needed.

Consider using a non-blocking command execution or adding a delay in the client, or restructuring to start the server asynchronously and detect when it's ready.

🔎 Proposed fix - add delay workaround
 def server_thread(self, session, cmd):
     """
     Execute server command in guest VM

     :param session: VM session object
     :param cmd: Server command to execute
     """
-    self.server_ready.set()
-    result = session.cmd_output(cmd)
-    self.results["server"] = ("success", result)
+    try:
+        self.server_ready.set()
+        result = session.cmd_output(cmd)
+        self.results["server"] = ("success", result)
+    except Exception as e:
+        self.results["server"] = ("error", str(e))

 def client_thread(self, cmd):
     """
     Execute client command on host

     :param cmd: Client command to execute
     """
-    self.server_ready.wait()
-    time.sleep(1)
-    result = process.system_output(cmd)
-    self.results["client"] = ("success", result)
+    try:
+        self.server_ready.wait()
+        time.sleep(3)  # Increased delay to allow server startup
+        result = process.system_output(cmd, shell=True)
+        self.results["client"] = ("success", result)
+    except Exception as e:
+        self.results["client"] = ("error", str(e))

Note: The exception handling aspect was also flagged in past reviews.

qemu/tests/vsock_hotplug.py (1)

98-102: tmp_file is undefined for Windows path, causing NameError.

If os_type == "windows", the code skips lines 82-97 where tmp_file is defined. However, the finally block references tmp_file on line 101. Although the condition checks for Linux, the variable reference itself occurs in all paths when Python parses the condition.

Additionally, as noted in past reviews, the Windows path is missing the simple_unplug call for dev_vsock.

🔎 Proposed fix
     # Transfer data from guest to host
+    tmp_file = None
     try:
         if os_type == "windows":
             viosock_test(test, params, vm, guest_cid)
+            vm.devices.simple_unplug(dev_vsock, vm.monitor)
         else:
             vsock_test_tool = params["vsock_test_tool"]
             if vsock_test_tool == "nc_vsock":
                 tool_bin = vsock_test.compile_nc_vsock(test, vm, session)
             elif vsock_test_tool == "ncat":
                 tool_bin = path.find_command("ncat")
             else:
                 raise ValueError(f"unsupported test tool: {vsock_test_tool}")
             tmp_file = "/tmp/vsock_file_%s" % utils_misc.generate_random_string(6)
             rec_session = vsock_test.send_data_from_guest_to_host(
                 session, tool_bin, guest_cid, tmp_file
             )
             vsock_negative_test.check_data_received(test, rec_session, tmp_file)
             vm.devices.simple_unplug(dev_vsock, vm.monitor)
             vsock_negative_test.kill_host_receive_process(test, rec_session)
             vsock_test.check_guest_vsock_conn_exit(test, session)
     finally:
-        # For windows testing, transfer_file() will remove the file
-        if params.get("os_type") == "linux":
+        if tmp_file:
             session.cmd_output("rm -f %s" % tmp_file)
         session.close()
🧹 Nitpick comments (2)
provider/win_driver_installer_test.py (1)

523-545: Missing cleanup of test artifacts.

The function creates/copies several files but doesn't clean them up:

  1. Host-side: source file created by generate_file_cmd (referenced as src_file_path)
  2. Guest-side: test tool copied to C:\ and the received data file

Consider adding cleanup in a finally block or documenting that cleanup is the caller's responsibility.

🔎 Proposed fix
 def viosock_test(test, params, vm, guest_cid):
     """
-    Trasfer data from host to VM via vsock
+    Transfer data from host to VM via vsock

     :param test: kvm test object.
     :param params: the dict used for parameters.
     :param vm: vm object.
+    :param guest_cid: Guest CID for vsock connection.
     """
     session = vm.wait_for_login()
-    path = win_driver_utils.get_driver_inf_path(
-        session, test, params["virtio_win_media_type"], params["driver_name"]
-    )
-    test_tool_src_path = path[: path.rfind("\\")] + "\\" + params["test_tool"]
-    session.cmd_output("xcopy %s C:\\ /y" % test_tool_src_path)
-    process.system_output(params["generate_file_cmd"])
-    server_cmd = params["receive_data_cmd"]
-    client_cmd = params["send_data_cmd"] % guest_cid
-
-    LOG_JOB.info("Transfer data from host to VM")
-    transfer = VSockTransfer()
-    transfer.run(session, server_cmd, client_cmd)
-
-    LOG_JOB.info("Check src and dst file's md5sum")
-    src_output = process.system_output("md5sum %s" % params["src_file_path"]).decode()
-    src_md5_sum = src_output.split()[0]
-    dst_output = session.cmd_output(params["md5sum_check_cmd"])
-    dst_md5_sum = dst_output.splitlines()[1]
-    if src_md5_sum != dst_md5_sum:
-        test.fail("File md5sum is not the same after transfer from host to guest")
-    else:
-        LOG_JOB.info("MD5 verification passed")
+    try:
+        path = win_driver_utils.get_driver_inf_path(
+            session, test, params["virtio_win_media_type"], params["driver_name"]
+        )
+        test_tool_src_path = path[: path.rfind("\\")] + "\\" + params["test_tool"]
+        session.cmd_output("xcopy %s C:\\ /y" % test_tool_src_path)
+        process.system_output(params["generate_file_cmd"])
+        server_cmd = params["receive_data_cmd"]
+        client_cmd = params["send_data_cmd"] % guest_cid
+
+        LOG_JOB.info("Transfer data from host to VM")
+        transfer = VSockTransfer()
+        transfer.run(session, server_cmd, client_cmd)
+
+        LOG_JOB.info("Check src and dst file's md5sum")
+        src_output = process.system_output("md5sum %s" % params["src_file_path"]).decode()
+        src_md5_sum = src_output.split()[0]
+        dst_output = session.cmd_output(params["md5sum_check_cmd"])
+        dst_lines = dst_output.splitlines()
+        if len(dst_lines) < 2:
+            test.fail("Unexpected certutil output format: %s" % dst_output)
+        dst_md5_sum = dst_lines[1].strip()
+        if src_md5_sum != dst_md5_sum:
+            test.fail("File md5sum is not the same after transfer from host to guest")
+        else:
+            LOG_JOB.info("MD5 verification passed")
+    finally:
+        # Cleanup host-side generated file
+        process.system_output("rm -f %s" % params.get("src_file_path", ""), ignore_status=True)
+        session.close()
qemu/tests/vsock_hotplug.py (1)

54-57: Consider using logging instead of print.

Line 55 uses a bare print() statement for debug output. The rest of the test uses test.log.info for logging. Consider replacing this with proper logging for consistency.

🔎 Proposed fix
     if os_type == "windows":
-        print("%s %s" % (device_pattern, output))
+        test.log.info("Device pattern: %s, Output: %s", device_pattern, output)
         if device_pattern not in output:
             test.fail('Not find vsock device: "%s"' % device_pattern)
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b36a2c5 and d63e29e.

📒 Files selected for processing (3)
  • provider/win_driver_installer_test.py
  • qemu/tests/cfg/virtio_win_socket_test.cfg
  • qemu/tests/vsock_hotplug.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • qemu/tests/cfg/virtio_win_socket_test.cfg
🧰 Additional context used
🧬 Code graph analysis (1)
provider/win_driver_installer_test.py (3)
qemu/tests/vsock_hotplug.py (1)
  • run (13-103)
qemu/tests/win_virtio_driver_installer_uninstall.py (1)
  • run (20-120)
provider/win_driver_utils.py (1)
  • get_driver_inf_path (123-155)
🪛 GitHub Actions: CI
qemu/tests/vsock_hotplug.py

[error] 62-62: Pylint: E0606 possibly using variable 'device_str' before assignment (possibly-used-before-assignment).

🔇 Additional comments (2)
provider/win_driver_installer_test.py (1)

5-5: LGTM for viosock driver infrastructure additions.

The threading import and additions to driver_name_list, device_hwid_list, and device_name_list correctly extend the Windows driver test infrastructure for VirtIO Socket support.

Also applies to: 32-32, 47-47, 62-62

qemu/tests/vsock_hotplug.py (1)

8-8: LGTM for the import.

The import of viosock_test from provider.win_driver_installer_test correctly enables Windows-specific vsock testing.

Comment on lines +515 to +522
def viosock_test(test, params, vm, guest_cid):
"""
Trasfer data from host to VM via vsock
:param test: kvm test object.
:param params: the dict used for parameters.
:param vm: vm object.
"""
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Typo in docstring.

Line 517: "Trasfer" should be "Transfer".

🔎 Proposed fix
 def viosock_test(test, params, vm, guest_cid):
     """
-    Trasfer data from host to VM via vsock
+    Transfer data from host to VM via vsock

     :param test: kvm test object.
     :param params: the dict used for parameters.
     :param vm: vm object.
+    :param guest_cid: Guest CID for vsock connection.
     """
🤖 Prompt for AI Agents
In provider/win_driver_installer_test.py around lines 515 to 522, the docstring
for viosock_test contains a typo: "Trasfer" should be corrected to "Transfer";
update the docstring line to read "Transfer data from host to VM via vsock" so
the spelling is correct and documentation is accurate.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
qemu/tests/vsock_hotplug.py (1)

54-69: Potential UnboundLocalError when dmesg_check=yes on Windows.

device_str is set to None on line 54 and only assigned in the else block (Linux path) on line 59. If os_type == "windows" and dmesg_check == "yes", line 62 will check if not device_str: which will be True (since None is falsy), causing the test to fail with a misleading error message.

While dmesg_check = no is set in the config, the code should be defensive.

🔎 Proposed fix
     if params.get("dmesg_check") == "yes":
+        if os_type == "windows":
+            test.error("dmesg_check is not supported on Windows")
         if not device_str:
             test.fail('check_vsock_cmd failed, no device "%s"' % device_pattern)
♻️ Duplicate comments (4)
provider/win_driver_installer_test.py (3)

470-490: Add exception handling to thread methods.

Both server_thread and client_thread lack exception handling. If either command fails, the exception will be silently lost, self.results will remain incomplete, and debugging failures will be difficult.

Also, process.system_output(cmd) on line 489 may need shell=True if send_data_cmd contains shell constructs like pipes.

🔎 Proposed fix
 def server_thread(self, session, cmd):
-    self.server_ready.set()
-    result = session.cmd_output(cmd)
-    self.results["server"] = ("success", result)
+    try:
+        self.server_ready.set()
+        result = session.cmd_output(cmd)
+        self.results["server"] = ("success", result)
+    except Exception as e:
+        self.results["server"] = ("error", str(e))

 def client_thread(self, cmd):
-    self.server_ready.wait()
-    time.sleep(1)
-    result = process.system_output(cmd)
-    self.results["client"] = ("success", result)
+    try:
+        self.server_ready.wait()
+        time.sleep(1)
+        result = process.system_output(cmd, shell=True)
+        self.results["client"] = ("success", result)
+    except Exception as e:
+        self.results["client"] = ("error", str(e))

515-522: Fix typo in docstring and add missing parameter documentation.

Line 517: "Trasfer" should be "Transfer". Also, the guest_cid parameter is not documented.

🔎 Proposed fix
 def viosock_test(test, params, vm, guest_cid):
     """
-    Trasfer data from host to VM via vsock
+    Transfer data from host to VM via vsock

     :param test: kvm test object.
     :param params: the dict used for parameters.
     :param vm: vm object.
+    :param guest_cid: Guest CID for vsock connection.
     """

523-545: Session not closed and transfer results not validated.

  1. The session opened on line 523 is never closed, leading to a resource leak.
  2. The transfer.run() result is not validated—if either thread fails (once exception handling is added), the failure goes undetected.
  3. Line 541 assumes certutil output has the MD5 hash on the second line without bounds checking, risking an IndexError. It also lacks .strip() which may cause comparison failures.
🔎 Proposed fix
 def viosock_test(test, params, vm, guest_cid):
     ...
     session = vm.wait_for_login()
-    path = win_driver_utils.get_driver_inf_path(
-        session, test, params["virtio_win_media_type"], params["driver_name"]
-    )
-    ...
-    transfer.run(session, server_cmd, client_cmd)
-
-    LOG_JOB.info("Check src and dst file's md5sum")
-    src_output = process.system_output("md5sum %s" % params["src_file_path"]).decode()
-    src_md5_sum = src_output.split()[0]
-    dst_output = session.cmd_output(params["md5sum_check_cmd"])
-    dst_md5_sum = dst_output.splitlines()[1]
-    if src_md5_sum != dst_md5_sum:
-        test.fail("File md5sum is not the same after transfer from host to guest")
-    else:
-        LOG_JOB.info("MD5 verification passed")
+    try:
+        path = win_driver_utils.get_driver_inf_path(
+            session, test, params["virtio_win_media_type"], params["driver_name"]
+        )
+        ...
+        results = transfer.run(session, server_cmd, client_cmd)
+        # Validate transfer results
+        for role in ["server", "client"]:
+            if role not in results:
+                test.fail("Transfer incomplete: %s did not complete" % role)
+            status, output = results[role]
+            if status == "error":
+                test.fail("Transfer failed in %s: %s" % (role, output))
+
+        LOG_JOB.info("Check src and dst file's md5sum")
+        src_output = process.system_output("md5sum %s" % params["src_file_path"]).decode()
+        src_md5_sum = src_output.split()[0]
+        dst_output = session.cmd_output(params["md5sum_check_cmd"])
+        dst_lines = dst_output.splitlines()
+        if len(dst_lines) < 2:
+            test.fail("Unexpected certutil output format: %s" % dst_output)
+        dst_md5_sum = dst_lines[1].strip()
+        if src_md5_sum != dst_md5_sum:
+            test.fail("File md5sum is not the same after transfer from host to guest")
+        else:
+            LOG_JOB.info("MD5 verification passed")
+    finally:
+        session.close()
qemu/tests/vsock_hotplug.py (1)

79-101: Windows path missing device unplug and potential UnboundLocalError for tmp_file.

  1. The Windows branch (lines 80-81) only performs the data transfer but skips device unplug (line 95), leaving the vsock device plugged after the test.

  2. tmp_file is only defined in the Linux path (line 90), but the finally block references it on line 101. If an exception occurs before line 90 in the Linux path, or if the logic changes, this will raise UnboundLocalError.

🔎 Proposed fix
+    tmp_file = None
     try:
         if os_type == "windows":
             viosock_test(test, params, vm, guest_cid)
+            vm.devices.simple_unplug(dev_vsock, vm.monitor)
         else:
             vsock_test_tool = params["vsock_test_tool"]
             ...
             tmp_file = "/tmp/vsock_file_%s" % utils_misc.generate_random_string(6)
             ...
             vm.devices.simple_unplug(dev_vsock, vm.monitor)
             vsock_negative_test.kill_host_receive_process(test, rec_session)
             vsock_test.check_guest_vsock_conn_exit(test, session)
     finally:
-        # For windows testing, transfer_file() will remove the file
-        if params.get("os_type") == "linux":
+        if tmp_file and os_type == "linux":
             session.cmd_output("rm -f %s" % tmp_file)
         session.close()
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d63e29e and c021316.

📒 Files selected for processing (3)
  • provider/win_driver_installer_test.py
  • qemu/tests/cfg/virtio_win_socket_test.cfg
  • qemu/tests/vsock_hotplug.py
🧰 Additional context used
🧬 Code graph analysis (2)
qemu/tests/vsock_hotplug.py (3)
provider/win_driver_installer_test.py (1)
  • viosock_test (515-545)
qemu/tests/vsock_test.py (3)
  • compile_nc_vsock (13-41)
  • send_data_from_guest_to_host (118-158)
  • check_guest_vsock_conn_exit (161-178)
qemu/tests/vsock_negative_test.py (2)
  • check_data_received (11-26)
  • kill_host_receive_process (30-40)
provider/win_driver_installer_test.py (1)
provider/win_driver_utils.py (1)
  • get_driver_inf_path (123-155)
🔇 Additional comments (3)
qemu/tests/cfg/virtio_win_socket_test.cfg (1)

1-27: Configuration looks reasonable for Windows vsock hotplug testing.

The configuration correctly sets up Windows-specific vsock test parameters including tool paths, data transfer commands, and hotplug variant. The check_vsock_cmd now outputs all present devices, and the device_pattern is used for matching.

provider/win_driver_installer_test.py (1)

32-32: LGTM! Driver list entries are correctly added.

The viosock driver, its hardware IDs, and device name are properly added in parallel to the existing lists.

Also applies to: 47-47, 62-62

qemu/tests/vsock_hotplug.py (1)

8-8: Import added for Windows vsock test support.

The import of viosock_test from provider.win_driver_installer_test correctly enables Windows-specific vsock handling.

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