From f2a458c6a64a9a4808522fe82d55b7ac434cf6c4 Mon Sep 17 00:00:00 2001 From: Dehan Meng Date: Thu, 21 Nov 2024 16:47:03 +0800 Subject: [PATCH] vioser: Supplement the correct function Avoid case calling case, so add corresponding functions Signed-off-by: Dehan Meng --- qemu/tests/vioser_in_use.py | 10 ++++++++++ qemu/tests/virtio_port_hotplug.py | 33 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/qemu/tests/vioser_in_use.py b/qemu/tests/vioser_in_use.py index 549437a637..098d52cea2 100644 --- a/qemu/tests/vioser_in_use.py +++ b/qemu/tests/vioser_in_use.py @@ -46,6 +46,16 @@ def live_migration_guest(test, params, vm, session): vm.migrate() +def subw_guest_pause_resume(test, params, vm, session): + vm.monitor.cmd("stop") + if not vm.monitor.verify_status("paused"): + test.error("VM is not paused Current status: %s" % vm.monitor.get_status()) + time.sleep(float(params.get("wait_timeout", "1800"))) + vm.monitor.cmd("cont") + if not vm.monitor.verify_status("running"): + test.error("VM is not running. Current status: %s" % vm.monitor.get_status()) + + @error_context.context_aware def vcpu_hotplug_guest(test, params, vm, session): """ diff --git a/qemu/tests/virtio_port_hotplug.py b/qemu/tests/virtio_port_hotplug.py index 7aeb0f8635..94cfd81d7e 100644 --- a/qemu/tests/virtio_port_hotplug.py +++ b/qemu/tests/virtio_port_hotplug.py @@ -8,6 +8,39 @@ from qemu.tests.virtio_serial_file_transfer import transfer_data +@error_context.context_aware +def reboot_guest(test, params, vm, session): + """ + Reboot guest from system_reset or shell. + """ + + vm.reboot(session, method=params["reboot_method"]) + + +@error_context.context_aware +def shutdown_guest(test, params, vm, session): + """ + Shutdown guest via system_powerdown or shell. + """ + + if params.get("shutdown_method") == "shell": + session.sendline(params["shutdown_command"]) + elif params.get("shutdown_method") == "system_powerdown": + vm.monitor.system_powerdown() + if not vm.wait_for_shutdown(int(params.get("shutdown_timeout", 360))): + test.fail("guest refuses to go down") + + +@error_context.context_aware +def live_migration_guest(test, params, vm, session): + """ + Run migrate_set_speed, then migrate guest. + """ + + qemu_migration.set_speed(vm, params.get("mig_speed", "1G")) + vm.migrate() + + @error_context.context_aware def run(test, params, env): """