forked from autotest/tp-libvirt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request autotest#5713 from cliping/panic
migration: Add case to verify panic device
- Loading branch information
Showing
2 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
- migrate.panic_device: | ||
type = migrate_with_panic_device | ||
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" | ||
migrate_desturi_port = "22" | ||
migrate_desturi_type = "ssh" | ||
virsh_migrate_desturi = "qemu+ssh://${migrate_dest_host}/system" | ||
image_convert = 'no' | ||
server_ip = "${migrate_dest_host}" | ||
server_user = "${remote_user}" | ||
server_pwd = "${migrate_dest_pwd}" | ||
start_vm = 'no' | ||
crash_action = "coredump-restart" | ||
expected_match = "crashed.*(panicked).*" | ||
dump_file_path = "/var/lib/libvirt/qemu/dump" | ||
panic_dev = {"model": "isa", "addr_type": "isa", "addr_iobase": "0x505"} | ||
aarch64: | ||
panic_dev = {"model": "pvpanic", "addr_type": "pci"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import aexpect | ||
|
||
from virttest import remote | ||
from virttest import virsh | ||
|
||
from virttest.libvirt_xml import vm_xml | ||
from virttest.utils_libvirt import libvirt_vmxml | ||
from virttest.utils_test import libvirt | ||
|
||
from provider.migration import base_steps | ||
|
||
|
||
def run(test, params, env): | ||
""" | ||
Verify panic device works well after migration. | ||
:param test: test object | ||
:param params: Dictionary with the test parameters | ||
:param env: Dictionary with test environment. | ||
""" | ||
def setup_test(): | ||
""" | ||
Setup step | ||
""" | ||
panic_model = params.get("panic_model") | ||
addr_type = params.get("addr_type") | ||
addr_iobase = params.get("addr_iobase") | ||
dump_file_path = params.get("dump_file_path") | ||
crash_action = params.get("crash_action") | ||
panic_dev = eval(params.get("panic_dev")) | ||
|
||
test.log.info("Setup steps.") | ||
migration_obj.setup_connection() | ||
# Cleanup dump file | ||
cmd = "rm -f %s/*" % dump_file_path | ||
remote.run_remote_cmd(cmd, params) | ||
|
||
vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name) | ||
libvirt_vmxml.modify_vm_device(vmxml, 'panic', panic_dev) | ||
vmxml.on_crash = crash_action | ||
vmxml.sync() | ||
test.log.info("Guest xml now is: %s", vmxml) | ||
vm.start() | ||
vm.wait_for_login().close() | ||
|
||
def verify_test(): | ||
""" | ||
Verify step | ||
""" | ||
dest_uri = params.get("virsh_migrate_desturi") | ||
expected_match = params.get("expected_match") | ||
dump_file_path = params.get("dump_file_path") | ||
|
||
test.log.info("Verify steps.") | ||
migration_obj.verify_default() | ||
|
||
backup_uri, vm.connect_uri = vm.connect_uri, dest_uri | ||
vm.cleanup_serial_console() | ||
vm.create_serial_console() | ||
remote_vm_session = vm.wait_for_serial_login(timeout=360) | ||
try: | ||
remote_vm_session.cmd("systemctl stop kdump", ignore_all_errors=True) | ||
remote_vm_session.cmd("echo 1 > /proc/sys/kernel/sysrq") | ||
remote_vm_session.cmd_status_output("echo c > /proc/sysrq-trigger", timeout=3) | ||
except aexpect.ShellTimeoutError: | ||
# This is expected | ||
pass | ||
except Exception: | ||
# This is unexpected | ||
raise | ||
|
||
remote_vm_session.close() | ||
ret = virsh.domstate(vm_name, extra="--reason", uri=dest_uri, debug=True) | ||
libvirt.check_result(ret, expected_match=expected_match) | ||
|
||
# Check dump file | ||
cmd = "ls %s" % dump_file_path | ||
ret = remote.run_remote_cmd(cmd, params, ignore_status=False) | ||
if vm_name not in ret.stdout_text.strip(): | ||
test.fail("Not found dump file.") | ||
|
||
vm.destroy() | ||
vm.connect_uri = backup_uri | ||
|
||
vm_name = params.get("migrate_main_vm") | ||
vm = env.get_vm(vm_name) | ||
migration_obj = base_steps.MigrationBase(test, vm, params) | ||
|
||
try: | ||
setup_test() | ||
migration_obj.run_migration() | ||
verify_test() | ||
finally: | ||
migration_obj.cleanup_connection() |