未验证 提交 8e2516a0 编写于 作者: Y Yu Yihuang 提交者: GitHub

Merge pull request #2118 from PaulYuuu/savevm_loadvm

savevm_loadvm: save VM and then load it while VM is running
- savevm_loadvm:
virt_test_type = qemu
type = savevm_loadvm
kill_vm_on_error = yes
kill_vm_gracefully = yes
kill_vm = yes
import logging
from virttest import utils_misc
from virttest import error_context
@error_context.context_aware
def run(test, params, env):
"""
Save VM while it's running, and then load it again.
1) Launch a VM.
2) Save VM via human monitor while VM is running. (unsafe)
3) Check if it exists in snapshots.
4) Load VM via human monitor.
5) Verify kernel and dmesg.
6) Delete snapshot after testing.
:param test: QEMU test object.
:param params: Dictionary with the test parameters.
:param env: Dictionary with test environment.
"""
snapshot_tag = "vm_" + utils_misc.generate_random_string(8)
os_type = params["os_type"]
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
vm.wait_for_login().close()
try:
error_context.base_context("Saving VM to %s" % snapshot_tag,
logging.info)
vm.monitor.human_monitor_cmd("savevm %s" % snapshot_tag)
vm_snapshots = vm.monitor.info("snapshots")
if snapshot_tag not in vm_snapshots:
test.fail("Failed to save VM to %s" % snapshot_tag)
error_context.context("Loading VM from %s" % snapshot_tag,
logging.info)
vm.monitor.human_monitor_cmd("loadvm %s" % snapshot_tag)
if os_type == "linux":
vm.verify_kernel_crash()
vm.verify_dmesg()
finally:
if snapshot_tag in vm.monitor.info("snapshots"):
vm.monitor.human_monitor_cmd("delvm %s" % snapshot_tag)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册