提交 aa1c0ab5 编写于 作者: J Jiří Župka 提交者: Lucas Meneghel Rodrigues

virt: Multihost Cpuflags migration cpu on off

This test adds test which migrate guest with turned off cpu.

1) boot guest on source host
2) disable cpu disable_cpus = "1 2"
3) migrate to destination host
4) check guest if all disabled cpu are still disabled after migration.
*) switch source and dest and repeat migrate migrate_count times.
Signed-off-by: NJiří Župka <jzupka@redhat.com>
上级 98b795a8
......@@ -185,21 +185,42 @@
- cpuflags_multi_host:
type = cpuflags
test_type = test_multi_host_migration
vms = "vm1"
start_vm = no
#Try to start guest with all flags which are supported by host.
all_host_supported_flags = "no"
cpu_model = "core2duo:sse3"
guest_spec_flags = "fxsr_opt hypervisor ds pdpe1gb osxsave svm"
host_spec_flags = "pbe tm ds_cpl monitor acpi dtes64 ht tm2 xtpr est pdcm smx"
mig_timeout = 4800
kill_vm_on_error = yes
disk_prepare_timeout = 360
comm_port = 13234
regain_ip_cmd = killall dhclient; sleep 10; dhclient;
auto_cpu_model = no
variants:
- cpu_stress:
type = cpuflags
test_type = test_multi_host_migration
vms = "vm1"
start_vm = no
#Try to start guest with all flags which are supported by host.
all_host_supported_flags = "no"
cpu_model = "core2duo:sse3"
guest_spec_flags = "fxsr_opt hypervisor ds pdpe1gb osxsave svm"
host_spec_flags = "pbe tm ds_cpl monitor acpi dtes64 ht tm2 xtpr est pdcm smx"
mig_timeout = 4800
kill_vm_on_error = yes
disk_prepare_timeout = 360
comm_port = 13234
regain_ip_cmd = killall dhclient; sleep 10; dhclient;
auto_cpu_model = no
- cpu_offline:
type = cpuflags
test_type = test_multi_host_migration_onoff_cpu
vms = "vm1"
smp = "2"
disable_cpus = "1"
migrate_count = 2
start_vm = no
#Try to start guest with all flags which are supported by host.
all_host_supported_flags = "no"
cpu_model = "core2duo"
guest_spec_flags = "fxsr_opt hypervisor ds pdpe1gb osxsave svm"
host_spec_flags = "pbe tm ds_cpl monitor acpi dtes64 ht tm2 xtpr est pdcm smx"
mig_timeout = 4800
kill_vm_on_error = yes
disk_prepare_timeout = 360
comm_port = 13234
regain_ip_cmd = killall dhclient; sleep 10; dhclient;
auto_cpu_model = no
only default_machine_types
# For RHEL machine type.
......
......@@ -3,6 +3,7 @@ from xml.parsers import expat
from autotest.client.shared import error, utils
from virttest import qemu_vm, virt_vm
from virttest import utils_misc, utils_test, aexpect
from autotest.client.shared.syncdata import SyncData
def run_cpuflags(test, params, env):
......@@ -332,6 +333,34 @@ def run_cpuflags(test, params, env):
vm_session.cmd("echo 1 > %s" % cpu_online)
logging.debug("Guest cpu %d is enabled.", cpu)
def check_online_cpus(vm_session, smp, disabled_cpu):
"""
Disable cpu in guest system.
@param smp: Count of cpu core in system.
@param disable_cpu: List of disabled cpu.
@return: List of CPUs that are still enabled after disable procedure.
"""
online = [0]
for cpu in range(1, smp):
system_cpu_dir = "/sys/devices/system/cpu/"
cpu_online = system_cpu_dir + "cpu%d/online" % (cpu)
cpu_state = vm_session.cmd_output("cat %s" % cpu_online).strip()
if cpu_state == "1":
online.append(cpu)
cpu_proc = vm_session.cmd_output("cat /proc/cpuinfo")
cpu_state_proc = map(lambda x: int(x),
re.findall("processor\s+:\s*(\d+)\n", cpu_proc))
if set(online) != set(cpu_state_proc):
raise error.TestError("Some cpus are disabled but %s are still "
"visible like online in /proc/cpuinfo." %
(set(cpu_state_proc) - set(online)))
return set(online) - set(disabled_cpu)
def install_cpuflags_test_on_vm(vm, dst_dir):
"""
Install stress to vm.
......@@ -913,6 +942,141 @@ def run_cpuflags(test, params, env):
mig = testMultihostMigration(test, params_b, env)
mig.run()
class test_multi_host_migration_onoff_cpu(Test_temp):
def test(self):
"""
Test migration between multiple hosts.
"""
cpu_model, extra_flags = parse_cpu_model()
flags = HgFlags(cpu_model, extra_flags)
logging.debug("Cpu mode flags %s.",
str(flags.quest_cpu_model_flags))
logging.debug("Added flags %s.",
str(flags.cpumodel_unsupport_flags))
cpuf_model = cpu_model
for fadd in extra_flags:
cpuf_model += ",+" + str(fadd)
for fdel in flags.host_unsupported_flags:
cpuf_model += ",-" + str(fdel)
smp = int(params.get("smp"))
disable_cpus = map(lambda cpu: int(cpu),
params.get("disable_cpus", "").split())
install_path = "/tmp"
class testMultihostMigration(utils_test.MultihostMigration):
def __init__(self, test, params, env):
utils_test.MultihostMigration.__init__(self, test, params,
env)
self.srchost = self.params.get("hosts")[0]
self.dsthost = self.params.get("hosts")[1]
self.id = {'src': self.srchost,
'dst': self.dsthost,
"type": "disable_cpu"}
self.migrate_count = int(self.params.get('migrate_count',
'2'))
def ping_pong_migrate(self, sync, worker, check_worker):
for _ in range(self.migrate_count):
logging.info("File transfer not ended, starting"
" a round of migration...")
sync.sync(True, timeout=mig_timeout)
if self.hostid == self.srchost:
self.migrate_wait(["vm1"],
self.srchost,
self.dsthost,
start_work=worker)
elif self.hostid == self.dsthost:
self.migrate_wait(["vm1"],
self.srchost,
self.dsthost,
check_work=check_worker)
tmp = self.dsthost
self.dsthost = self.srchost
self.srchost = tmp
def migration_scenario(self):
sync = SyncData(self.master_id(), self.hostid, self.hosts,
self.id, self.sync_server)
def worker(mig_data):
vm = env.get_vm("vm1")
session = vm.wait_for_login(timeout=self.login_timeout)
install_cpuflags_test_on_vm(vm, install_path)
Flags = check_cpuflags_work(vm, install_path,
flags.all_possible_guest_flags)
logging.info("Woking CPU flags: %s", str(Flags[0]))
logging.info("Not working CPU flags: %s",
str(Flags[1]))
logging.warning("Flags works even if not deffined on"
" guest cpu flags: %s",
str(Flags[0] - flags.guest_flags))
logging.warning("Not tested CPU flags: %s",
str(Flags[2]))
for cpu in disable_cpus:
if cpu < smp:
disable_cpu(session, cpu, True)
else:
logging.warning("There is no enouth cpu"
" in Guest. It is trying to"
"remove cpu:%s from guest with"
" smp:%s." % (cpu, smp))
logging.debug("Guest_flags: %s",
str(flags.guest_flags))
logging.debug("Working_flags: %s", str(Flags[0]))
def check_worker(mig_data):
vm = env.get_vm("vm1")
vm.verify_illegal_instruction()
session = vm.wait_for_login(timeout=self.login_timeout)
really_disabled = check_online_cpus(session, smp,
disable_cpus)
not_disabled = set(really_disabled) & set(disable_cpus)
if not_disabled:
raise error.TestFail("Some of disabled cpus are "
"online. This shouldn't "
"happen. Cpus disabled on "
"srchost:%s, Cpus not "
"disabled on dsthost:%s" %
(disable_cpus, not_disabled))
Flags = check_cpuflags_work(vm, install_path,
flags.all_possible_guest_flags)
logging.info("Woking CPU flags: %s",
str(Flags[0]))
logging.info("Not working CPU flags: %s",
str(Flags[1]))
logging.warning("Flags works even if not deffined on"
" guest cpu flags: %s",
str(Flags[0] - flags.guest_flags))
logging.warning("Not tested CPU flags: %s",
str(Flags[2]))
self.ping_pong_migrate(sync, worker, check_worker)
params_b = params.copy()
params_b["cpu_model"] = cpu_model
mig = testMultihostMigration(test, params_b, env)
mig.run()
test_type = params.get("test_type")
if (test_type in locals()):
tests_group = locals()[test_type]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册