Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions libvirt/tests/src/sriov/vIOMMU/iommu_device_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,21 @@ def run(test, params, env):
test.log.info("TEST_STEP: Reset the VM.")
session = vm.wait_for_serial_login(
timeout=int(params.get('login_timeout')))
virsh.reset(vm.name, **VIRSH_ARGS)
_match, _text = session.read_until_last_line_matches(
[r"[Ll]ogin:\s*"], timeout=240, internal_timeout=0.5)
session.close()
vm.cleanup_serial_console()
vm.create_serial_console()
session = vm.wait_for_serial_login(
timeout=int(params.get('login_timeout')))
session.close()
Comment on lines 64 to 72
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

Critical: Missing VM reset operation.

The test logs "Reset the VM" but no actual reset command is executed. The current code only recreates the serial console without performing a VM reset operation. The original virsh.reset(vm.name, **VIRSH_ARGS) call appears to have been removed.

The reset should be performed after the initial login and before recreating the console:

 if test_scenario == "reset":
     test.log.info("TEST_STEP: Reset the VM.")
     session = vm.wait_for_serial_login(
         timeout=int(params.get('login_timeout')))
     session.close()
+    virsh.reset(vm.name, **VIRSH_ARGS)
     vm.cleanup_serial_console()
     vm.create_serial_console()
     session = vm.wait_for_serial_login(
         timeout=int(params.get('login_timeout')))
     session.close()
📝 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
test.log.info("TEST_STEP: Reset the VM.")
session = vm.wait_for_serial_login(
timeout=int(params.get('login_timeout')))
virsh.reset(vm.name, **VIRSH_ARGS)
_match, _text = session.read_until_last_line_matches(
[r"[Ll]ogin:\s*"], timeout=240, internal_timeout=0.5)
session.close()
vm.cleanup_serial_console()
vm.create_serial_console()
session = vm.wait_for_serial_login(
timeout=int(params.get('login_timeout')))
session.close()
test.log.info("TEST_STEP: Reset the VM.")
session = vm.wait_for_serial_login(
timeout=int(params.get('login_timeout')))
session.close()
virsh.reset(vm.name, **VIRSH_ARGS)
vm.cleanup_serial_console()
vm.create_serial_console()
session = vm.wait_for_serial_login(
timeout=int(params.get('login_timeout')))
session.close()
🤖 Prompt for AI Agents
In libvirt/tests/src/sriov/vIOMMU/iommu_device_lifecycle.py around lines 64 to
72, the code logs "Reset the VM" but never executes the actual VM reset; restore
the removed virsh.reset(vm.name, **VIRSH_ARGS) call so the VM is reset after the
first serial login and before cleaning/recreating the serial console. Ensure
VIRSH_ARGS is available in scope (import or reference the existing constant) and
call virsh.reset(vm.name, **VIRSH_ARGS) between session.close() and
vm.cleanup_serial_console().

else:
for _ in range(int(params.get('loop_time', '5'))):
test.log.info("TEST_STEP: Reboot the VM.")
session = vm.wait_for_serial_login(
timeout=int(params.get('login_timeout')))
session.sendline(params.get("reboot_command"))
_match, _text = session.read_until_last_line_matches(
[r"[Ll]ogin:\s*"], timeout=240, internal_timeout=0.5)
session.close()
vm.cleanup_serial_console()
vm.create_serial_console()
session = vm.wait_for_serial_login(timeout=int(params.get('login_timeout')))
session.close()
Comment on lines 74 to 82
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

Critical: Missing VM reboot operation.

The test logs "Reboot the VM" but no actual reboot command is executed. The current code only recreates the serial console without performing a VM reboot. The loop runs multiple times without actually rebooting the VM between iterations.

The reboot should be triggered after the initial login:

 for _ in range(int(params.get('loop_time', '5'))):
     test.log.info("TEST_STEP: Reboot the VM.")
     session = vm.wait_for_serial_login(
         timeout=int(params.get('login_timeout')))
+    session.cmd("reboot")
     session.close()
     vm.cleanup_serial_console()
     vm.create_serial_console()
     session = vm.wait_for_serial_login(timeout=int(params.get('login_timeout')))
     session.close()
📝 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
for _ in range(int(params.get('loop_time', '5'))):
test.log.info("TEST_STEP: Reboot the VM.")
session = vm.wait_for_serial_login(
timeout=int(params.get('login_timeout')))
session.sendline(params.get("reboot_command"))
_match, _text = session.read_until_last_line_matches(
[r"[Ll]ogin:\s*"], timeout=240, internal_timeout=0.5)
session.close()
vm.cleanup_serial_console()
vm.create_serial_console()
session = vm.wait_for_serial_login(timeout=int(params.get('login_timeout')))
session.close()
for _ in range(int(params.get('loop_time', '5'))):
test.log.info("TEST_STEP: Reboot the VM.")
session = vm.wait_for_serial_login(
timeout=int(params.get('login_timeout')))
session.cmd("reboot")
session.close()
vm.cleanup_serial_console()
vm.create_serial_console()
session = vm.wait_for_serial_login(timeout=int(params.get('login_timeout')))
session.close()
🤖 Prompt for AI Agents
In libvirt/tests/src/sriov/vIOMMU/iommu_device_lifecycle.py around lines 74 to
82, the loop logs "Reboot the VM" but never actually reboots; after the initial
login and session.close() insert a vm.reboot() call so the VM is restarted
before cleaning and recreating the serial console, then keep the subsequent
vm.cleanup_serial_console(), vm.create_serial_console(), and the
wait_for_serial_login() call to verify the VM came back up.


session = vm.wait_for_serial_login(
Expand Down