提交 7c09d9c0 编写于 作者: S Suqin Huang 提交者: Lucas Meneghel Rodrigues

qemu: Add new test check_unhalt_vcpu

(1) Use qemu-img to create an unbootable image.
(2) Start vm with the image created by step 1.
(3) Use ps get qemu-kvm process %cpu, if greater
    than 90%, report fail.
Signed-off-by: NQingtang Zhou <qzhou@redhat.com>
Signed-off-by: NYiqiao Pu <ypu@redhat.com>
Signed-off-by: NSuqin Huang <shuang@redhat.com>
Signed-off-by: Nsshang <sshang@redhat.com>
上级 07b5a3f4
- check_unhalt_vcpu:
testcase = 'check_unhalt_vcpu'
type = check_unhalt_vcpu
images += " unbootable"
boot_drive = no
boot_drive_unbootable = yes
image_boot_unbootable = yes
image_name_unbootable = images/unbootable
image_size_unbootable = 10M
image_format_unbootable = qcow2
force_create_image_unbootable = yes
kill_vm = yes
remove_image_unbootable = yes
cpu_get_usage_cmd = PID=%s; top -n1 -b -p $PID | awk "{ if(\$1==$PID) {print \$9} }"
import logging, time
from autotest.client.shared import error
from autotest.client import utils
def run_check_unhalt_vcpu(test, params, env):
"""
Check unhalt vcpu of guest.
1) Use qemu-img create any image which can not boot.
2) Start vm with the image created by step 1
3) Use ps get qemu-kvm process %cpu, if greater than 90%, report fial.
"""
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
pid = vm.get_pid()
if not pid:
raise error.TestError("Could not get QEMU's PID")
sleep_time = params.get("sleep_time", 60)
time.sleep(sleep_time)
cpu_get_usage_cmd = params["cpu_get_usage_cmd"]
cpu_get_usage_cmd = cpu_get_usage_cmd % pid
cpu_usage = utils.system_output(cpu_get_usage_cmd)
try:
cpu_usage = float(cpu_usage)
except ValueError, detail:
raise error.TestError("Could not get correct cpu usage value with cmd"
" '%s', detail: '%s'" % (cpu_get_usage_cmd, detail))
logging.info("Guest's reported CPU usage: %s", cpu_usage)
if cpu_usage >= 90:
raise error.TestFail("Guest have unhalt vcpu.")
logging.info("Guest vcpu work normally")
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册