提交 b65d99b6 编写于 作者: X Xueqiang Wei

fix lack_flag_check.unknown_flag

1. The behavior is different after run "-cpu 'model_name',+unknown,check"
   between RHEL7 and RHEL6
   (after qemu output "CPU feature unknown not found" qemu exit in RHEL7,
    but qemu not exit in RHEL6)
2. The behavior in RHEL6 is not the one we really want, but it's
   just an usability issue (as using invalid flag names is not supported),
   so developper didn't backport the fix to RHEL6.
3. in auto script, add check point:
   qemu output "CPU feature unknown not found"
Signed-off-by: NXueqiang Wei <xuwei@redhat.com>
上级 afc12362
......@@ -26,6 +26,8 @@
out_flags += " x2apic"
variants:
- unknown_flag:
start_vm = no
qemu_output = "CPU feature unknown not found"
cpu_model_flags = ",+unknown,check"
- unsupported_flags:
cpu_model_flags = ",+sse4a,+aes,+ssse3,+sse4.2,check"
......
......@@ -6,6 +6,7 @@ from autotest.client.shared import utils, error
from virttest import utils_misc
from virttest import data_dir
from virttest import virt_vm
@error.context_aware
......@@ -139,80 +140,96 @@ def run(test, params, env):
error.context("Boot guest with -cpu %s,%s" %
(guest_cpumodel, extra_flags), logging.info)
vm.verify_alive()
timeout = float(params.get("login_timeout", 240))
session = vm.wait_for_login(timeout=timeout)
# Get qemu model
host_cpumodel = utils_misc.get_host_cpu_models()
if guest_cpumodel not in host_cpumodel:
qemu_model = host_cpumodel[0]
if params.get("start_vm") == "no" and "unknown,check" in extra_flags:
params["start_vm"] = "yes"
try:
vm.create()
except virt_vm.VMCreateError, detail:
error.context("qemu process is defunct.%s" % detail, logging.info)
finally:
if vm.is_alive():
process_output = vm.process.get_output()
else:
process_output = str(detail)
if params["qemu_output"] not in process_output:
raise error.TestFail("no qemu output: %s" % params["qemu_output"])
vm.destroy()
else:
qemu_model = guest_cpumodel
error.context("Get model %s support flags" % qemu_model, logging.info)
# Get flags for every reg from model's info
models_info = utils.system_output("cat %s" % cpuinfo_file).split("x86")
model_info = qemu_model_info(models_info, qemu_model)
reg_list = params.get("reg_list", "feature_edx ").split()
model_support_flags = " "
if model_info:
for reg in reg_list:
reg_flags = qemu_support_flag(model_info, reg)
if reg_flags:
model_support_flags += " %s" % reg_flags
model_support_flags = set(map(utils_misc.Flag,
model_support_flags.split()))
error.context("Get guest flags", logging.info)
guest_flags = get_guest_cpuflags(session)
error.context("Get expected flag list", logging.info)
# out_flags is definded in dump file, but not in guest
out_flags = params.get("out_flags", " ").split()
out_flags = set(map(utils_misc.Flag, out_flags))
# no_check_flags is definded in all_support_flags, but not in guest and host
no_check_flags = params.get("no_check_flags", " ").split()
no_check_flags = set(map(utils_misc.Flag, no_check_flags))
# option_flags are generated by kernel or kvm, which are not definded in
# dump file, but can be displayed in guest
option_flags = params.get("option_flags", " ").split()
if params['smp'] == '1' and 'up' not in option_flags:
option_flags.append('up')
option_flags = set(map(utils_misc.Flag, option_flags))
# add_flags are exposed by +flag
add_flags = get_extra_flag(extra_flags, "+")
# del_flags are disabled by -flag
del_flags = get_extra_flag(extra_flags, "-", lack_check=True)
expected_flags = ((model_support_flags | add_flags) -
del_flags - out_flags)
# get all flags for host lack flag checking
check_flags = get_extra_flag(extra_flags, "+", lack_check=True)
check_flags = check_flags - no_check_flags
host_flags = set(map(utils_misc.Flag, host_flags))
lack_flags = set(expected_flags | check_flags) - host_flags
if "check" in extra_flags:
error.context("Check lack flag in host", logging.info)
process_output = vm.process.get_output()
miss_warn = []
if lack_flags:
for flag in lack_flags:
if flag not in process_output:
miss_warn.extend(flag.split())
if miss_warn:
raise error.TestFail("no warning for lack flag %s" % miss_warn)
error.context("Compare guest flags with expected flags", logging.info)
all_support_flags = get_all_support_flags()
missing_flags = expected_flags - guest_flags
unexpect_flags = (guest_flags - expected_flags -
all_support_flags - option_flags)
if missing_flags or unexpect_flags:
raise error.TestFail("missing flags:\n %s\n"
"more flags than expected:\n %s\n"
"expected flags:\n %s\n"
"guest flags:\n %s\n"
% (missing_flags, unexpect_flags, expected_flags,
guest_flags))
vm.verify_alive()
timeout = float(params.get("login_timeout", 240))
session = vm.wait_for_login(timeout=timeout)
# Get qemu model
host_cpumodel = utils_misc.get_host_cpu_models()
if guest_cpumodel not in host_cpumodel:
qemu_model = host_cpumodel[0]
else:
qemu_model = guest_cpumodel
error.context("Get model %s support flags" % qemu_model, logging.info)
# Get flags for every reg from model's info
models_info = utils.system_output("cat %s" % cpuinfo_file).split("x86")
model_info = qemu_model_info(models_info, qemu_model)
reg_list = params.get("reg_list", "feature_edx ").split()
model_support_flags = " "
if model_info:
for reg in reg_list:
reg_flags = qemu_support_flag(model_info, reg)
if reg_flags:
model_support_flags += " %s" % reg_flags
model_support_flags = set(map(utils_misc.Flag,
model_support_flags.split()))
error.context("Get guest flags", logging.info)
guest_flags = get_guest_cpuflags(session)
error.context("Get expected flag list", logging.info)
# out_flags is definded in dump file, but not in guest
out_flags = params.get("out_flags", " ").split()
out_flags = set(map(utils_misc.Flag, out_flags))
# no_check_flags is definded in all_support_flags, but not in guest and host
no_check_flags = params.get("no_check_flags", " ").split()
no_check_flags = set(map(utils_misc.Flag, no_check_flags))
# option_flags are generated by kernel or kvm, which are not definded in
# dump file, but can be displayed in guest
option_flags = params.get("option_flags", " ").split()
if params['smp'] == '1' and 'up' not in option_flags:
option_flags.append('up')
option_flags = set(map(utils_misc.Flag, option_flags))
# add_flags are exposed by +flag
add_flags = get_extra_flag(extra_flags, "+")
# del_flags are disabled by -flag
del_flags = get_extra_flag(extra_flags, "-", lack_check=True)
expected_flags = ((model_support_flags | add_flags) -
del_flags - out_flags)
# get all flags for host lack flag checking
check_flags = get_extra_flag(extra_flags, "+", lack_check=True)
check_flags = check_flags - no_check_flags
host_flags = set(map(utils_misc.Flag, host_flags))
lack_flags = set(expected_flags | check_flags) - host_flags
if "check" in extra_flags and "unknown" not in extra_flags:
error.context("Check lack flag in host", logging.info)
process_output = vm.process.get_output()
miss_warn = []
if lack_flags:
for flag in lack_flags:
if flag not in process_output:
miss_warn.extend(flag.split())
if miss_warn:
raise error.TestFail("no warning for lack flag %s" % miss_warn)
error.context("Compare guest flags with expected flags", logging.info)
all_support_flags = get_all_support_flags()
missing_flags = expected_flags - guest_flags
unexpect_flags = (guest_flags - expected_flags -
all_support_flags - option_flags)
if missing_flags or unexpect_flags:
raise error.TestFail("missing flags:\n %s\n"
"more flags than expected:\n %s\n"
"expected flags:\n %s\n"
"guest flags:\n %s\n"
% (missing_flags, unexpect_flags, expected_flags,
guest_flags))
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册