Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
- migration.async_job.abort_before_qemu_layer_mig_start:
type = abort_before_qemu_layer_mig_start
migration_setup = 'yes'
storage_type = 'nfs'
setup_local_nfs = 'yes'
disk_type = "file"
disk_source_protocol = "netfs"
mnt_path_name = ${nfs_mount_dir}
# Console output can only be monitored via virsh console output
only_pty = True
take_regular_screendumps = no
# Extra options to pass after <domain> <desturi>
virsh_migrate_extra = ''
# SSH connection time out
ssh_timeout = 60
# Local URI
virsh_migrate_connect_uri = 'qemu:///system'
virsh_migrate_dest_state = "running"
virsh_migrate_src_state = "shut off"
image_convert = 'no'
server_ip = "${migrate_dest_host}"
server_user = "root"
server_pwd = "${migrate_dest_pwd}"
status_error = "yes"
check_network_accessibility_after_mig = "yes"
migrate_speed = "15"
err_msg = "error: operation aborted: migration out: canceled by client"
migrate_again_status_error = "no"
start_vm = "yes"
variants:
- p2p:
virsh_migrate_options = '--live --p2p --verbose'
variants:
- with_precopy:
variants:
- tcp:
migrate_desturi_port = "16509"
migrate_desturi_type = "tcp"
virsh_migrate_desturi = "qemu+tcp://${migrate_dest_host}/system"
- unix:
transport_type = "unix_proxy"
service_to_check = ""
migrateuri_socket_path = "/var/lib/libvirt/qemu/migrateuri-socket"
desturi_socket_path = "/tmp/desturi-socket"
migrate_desturi_type = "unix_proxy"
virsh_migrate_desturi = "qemu+unix:///system?socket=${desturi_socket_path}"
migrateuri_port = "33334"
port_to_check = "${migrateuri_port}"
virsh_migrate_migrateuri = "unix://${migrateuri_socket_path}"
virsh_migrate_extra = "--migrateuri ${virsh_migrate_migrateuri}"
variants abort_mig:
- domjobabort:
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright Redhat
#
# SPDX-License-Identifier: GPL-2.0
#
# Author: Liping Cheng <[email protected]>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import queue
import threading
import time

from virttest import remote
from virttest import virsh
from virttest.utils_test import libvirt

from provider.migration import base_steps

msg_queue = queue.Queue()


def run_migration(vm_name, dest_uri, option, extra):
"""
Run migration
:param vm_name: VM name
:param dest_uri: virsh uri
:param option: virsh migrate option parameters
:param extra: virsh migrate extra parameters
"""
ret = virsh.migrate(vm_name, dest_uri, option, extra, ignore_status=True, debug=True)
msg_queue.put(ret)


def run(test, params, env):
"""
Abort migration job before qemu layer migration starts, then migrate vm
again.
"""
def setup_test():
"""
Setup steps
"""
test.log.info("Setup steps.")
migration_obj.setup_connection()
remote.run_remote_cmd("pkill -19 virtqemud", params)

Comment on lines +48 to +51
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

Wrong remote command helper/signature. Use migrate_vm.run_remote_cmd with server creds.

remote.run_remote_cmd(params) is not the exported helper; call migrate_vm.run_remote_cmd(command, server_ip, server_user, server_pwd).

Apply:

@@
-from virttest import remote
+from virttest import utils_misc
+from virttest import virsh
+from virttest.utils_test import libvirt
+from provider.migration import base_steps
+from libvirt.tests.src.migration import migrate_vm
@@
-        migration_obj.setup_connection()
-        remote.run_remote_cmd("pkill -19 virtqemud", params)
+        migration_obj.setup_connection()
+        migrate_vm.run_remote_cmd(
+            "pkill -19 virtqemud",
+            params.get("server_ip"),
+            params.get("server_user"),
+            params.get("server_pwd"),
+        )

Note: Keep the new import; repeat the same change for the resume step below.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In libvirt/tests/src/migration/async_job/abort_before_qemu_layer_mig_start.py
around lines 52 to 55, the test is calling the wrong remote helper
(remote.run_remote_cmd with params); replace that call with
migrate_vm.run_remote_cmd(command, server_ip, server_user, server_pwd) — e.g.
migrate_vm.run_remote_cmd("pkill -19 virtqemud", server_ip, server_user,
server_pwd) — and ensure the same change is applied to the resume step later in
the file; keep the new import for migrate_vm as requested.

def run_test():
"""
Run test
"""
dest_uri = params.get("virsh_migrate_desturi")
option = params.get("virsh_migrate_options", "--live --verbose")
extra = params.get("virsh_migrate_extra")
err_msg = params.get("err_msg")

mig_t = threading.Thread(target=run_migration, args=(vm_name, dest_uri, option, extra))
mig_t.start()
time.sleep(3)

virsh.domjobabort(vm_name, debug=True)
remote.run_remote_cmd("pkill -18 virtqemud", params)
mig_t.join()

output = msg_queue.get()
libvirt.check_result(output, err_msg)

Comment on lines +67 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 | 🟠 Major

Avoid hangs: add timeouts to join() and queue.get().

Ensure the test fails fast instead of blocking indefinitely.

Apply:

-        remote.run_remote_cmd("pkill -18 virtqemud", params)
-        mig_t.join()
-
-        output = msg_queue.get()
+        migrate_vm.run_remote_cmd(
+            "pkill -18 virtqemud",
+            params.get("server_ip"),
+            params.get("server_user"),
+            params.get("server_pwd"),
+        )
+        mig_t.join(timeout=int(params.get("ssh_timeout", 60)))
+        if mig_t.is_alive():
+            test.error("Migration thread did not exit in time after abort")
+        try:
+            output = msg_queue.get(timeout=int(params.get("ssh_timeout", 60)))
+        except queue.Empty:
+            test.error("No migrate result retrieved from worker thread")
         libvirt.check_result(output, err_msg)

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In libvirt/tests/src/migration/async_job/abort_before_qemu_layer_mig_start.py
around lines 80 to 85, the test calls mig_t.join() and msg_queue.get() without
timeouts which can hang indefinitely; update to pass timeouts (e.g.
join(timeout=... ) and get(timeout=... )) and check their results so the test
fails fast: after join(timeout) assert the thread is not alive (or raise/fail if
it is), and wrap msg_queue.get(timeout) in a try/except for queue.Empty (or
check for None) to raise a clear test failure if no message arrives within the
timeout. Ensure the chosen timeout values are reasonable for the test
environment and that failure paths log/raise an informative error.

vm_name = params.get("migrate_main_vm")

vm = env.get_vm(vm_name)
migration_obj = base_steps.MigrationBase(test, vm, params)

try:
setup_test()
run_test()
migration_obj.run_migration_again()
migration_obj.verify_default()
finally:
migration_obj.cleanup_connection()