* [KVM-Autotest] Add multihost migration support to cpuflags
@ 2012-01-31 14:40 Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 1/5] virt: Check illegal instruction code Jiří Župka
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Jiří Župka @ 2012-01-31 14:40 UTC (permalink / raw)
To: autotest, kvm, kvm-autotest, lmr, ldoktor, jzupka
This patch series adds support to kvm cpuflags test and changes the way
which kvm multi-host tests are started by control file.
Pull-Request: https://github.com/autotest/autotest/pull/144
^ permalink raw reply [flat|nested] 6+ messages in thread
* [KVM-Autotest][PATCH 1/5] virt: Check illegal instruction code
2012-01-31 14:40 [KVM-Autotest] Add multihost migration support to cpuflags Jiří Župka
@ 2012-01-31 14:40 ` Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 2/5] virt: Add aliases to class Flag Jiří Župka
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jiří Župka @ 2012-01-31 14:40 UTC (permalink / raw)
To: autotest, kvm, kvm-autotest, lmr, ldoktor, jzupka
Add a check on the base VM class for illegal
instruction code executed by the VM. That
check is performed on the serial console
output.
Signed-off-by: Jiří Župka <jzupka@redhat.com>
---
client/virt/virt_vm.py | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/client/virt/virt_vm.py b/client/virt/virt_vm.py
index 32593c1..d4fb47d 100644
--- a/client/virt/virt_vm.py
+++ b/client/virt/virt_vm.py
@@ -133,6 +133,18 @@ class VMDeadKernelCrashError(VMError):
return ("VM is dead due to a kernel crash:\n%s" % self.kernel_crash)
+class VMInvalidInstructionCode(VMError):
+ def __init__(self, invalid_code):
+ VMError.__init__(self, invalid_code)
+ self.invalid_code = invalid_code
+
+ def __str__(self):
+ error = ""
+ for invalid_code in self.invalid_code:
+ error += "%s" % (invalid_code)
+ return ("Invalid instruction was executed on VM:\n%s" % error)
+
+
class VMAddressError(VMError):
pass
@@ -656,6 +668,21 @@ class BaseVM(object):
raise VMDeadKernelCrashError(match.group(0))
+ def verify_illegal_instructonn(self):
+ """
+ Find illegal instruction code on VM serial console output.
+
+ @raise: VMInvalidInstructionCode, in case a wrong instruction code.
+ """
+ if self.serial_console is not None:
+ data = self.serial_console.get_output()
+ match = re.findall(r".*trap invalid opcode.*\n", data,
+ re.MULTILINE)
+
+ if match:
+ raise VMInvalidInstructionCode(match)
+
+
def get_params(self):
"""
Return the VM's params dict. Most modified params take effect only
--
1.7.7.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [KVM-Autotest][PATCH 2/5] virt: Add aliases to class Flag.
2012-01-31 14:40 [KVM-Autotest] Add multihost migration support to cpuflags Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 1/5] virt: Check illegal instruction code Jiří Župka
@ 2012-01-31 14:40 ` Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 3/5] kvm test: Introduce multi_host.srv Jiří Župka
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jiří Župka @ 2012-01-31 14:40 UTC (permalink / raw)
To: autotest, kvm, kvm-autotest, lmr, ldoktor, jzupka
The patch solve problem with doubled name of cpuflags
sse4_1, sse4.1 etc. in cpuflag test.
Signed-off-by: Jiří Župka <jzupka@redhat.com>
---
client/virt/virt_utils.py | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/client/virt/virt_utils.py b/client/virt/virt_utils.py
index a367ffe..20ed4ba 100644
--- a/client/virt/virt_utils.py
+++ b/client/virt/virt_utils.py
@@ -1294,8 +1294,12 @@ class Flag(str):
"""
Class for easy merge cpuflags.
"""
- def __init__(self, *args, **kwargs):
- super(Flag, self).__init__( *args, **kwargs)
+ aliases = {}
+
+ def __new__(cls, flag):
+ if flag in Flag.aliases:
+ flag = Flag.aliases[flag]
+ return str.__new__(cls, flag)
def __eq__(self, other):
s = set(self.split("|"))
@@ -1324,6 +1328,12 @@ kvm_map_flags_to_test = {
}
+kvm_map_flags_aliases = {
+ 'sse4.1' :'sse4_1',
+ 'sse4.2' :'sse4_2',
+ }
+
+
def kvm_flags_to_stresstests(flags):
"""
Covert [cpu flags] to [tests]
--
1.7.7.6
_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [KVM-Autotest][PATCH 3/5] kvm test: Introduce multi_host.srv
2012-01-31 14:40 [KVM-Autotest] Add multihost migration support to cpuflags Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 1/5] virt: Check illegal instruction code Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 2/5] virt: Add aliases to class Flag Jiří Župka
@ 2012-01-31 14:40 ` Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 4/5] virt deps: Reduces memory usage of test Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 5/5] kvm test: Add multihost migration support to cpuflag test Jiří Župka
4 siblings, 0 replies; 6+ messages in thread
From: Jiří Župka @ 2012-01-31 14:40 UTC (permalink / raw)
To: autotest, kvm, kvm-autotest, lmr, ldoktor, jzupka
We had migration_control.srv which worked with old
version of kvm config files (tests.cfg, subtest.cfg,
etc..). Because config files were changed this control
code stopped working.
This patch repairs this problem and renames the file
to the more correct and generic name multi-host.srv.
Also, added new configuration file tests-shared.cfg
which contains shared data among single host and multi
host tests.
The changes are useful for multihost tests, since
we can use a lot of configuration from regular single
host tests.
Signed-off-by: Jiří Župka <jzupka@redhat.com>
---
client/tests/kvm/migration_control.srv | 123 --------------------------
client/tests/kvm/multi-host-tests.cfg.sample | 43 +++++++++
client/tests/kvm/multi_host.srv | 106 ++++++++++++++++++++++
client/tests/kvm/tests-shared.cfg.sample | 48 ++++++++++
client/tests/kvm/tests.cfg.sample | 43 +---------
5 files changed, 198 insertions(+), 165 deletions(-)
delete mode 100644 client/tests/kvm/migration_control.srv
create mode 100644 client/tests/kvm/multi-host-tests.cfg.sample
create mode 100644 client/tests/kvm/multi_host.srv
create mode 100644 client/tests/kvm/tests-shared.cfg.sample
diff --git a/client/tests/kvm/migration_control.srv b/client/tests/kvm/migration_control.srv
deleted file mode 100644
index c669ccd..0000000
--- a/client/tests/kvm/migration_control.srv
+++ /dev/null
@@ -1,123 +0,0 @@
-AUTHOR = "Yolkfull Chow <yzhou@redhat.com>"
-TIME = "SHORT"
-NAME = "KVM Test (migration across multiple hosts)"
-TEST_CATEGORY = "Functional"
-TEST_CLASS = "Virtualization"
-TEST_TYPE = "Server"
-DOC = """
-Migrate KVM guest between two hosts. It parses the base config file, restricts
-it with appropriate parameters, generates the test dicts, modify the test_dicts
-so there's a distinction between the migration roles ('dest' or 'source').
-"""
-
-import sys, os, commands, glob, shutil, logging, random
-from autotest_lib.server import utils
-from autotest_lib.client.common_lib import cartesian_config
-
-# Specify the directory of autotest before you start this test
-AUTOTEST_DIR = '/usr/local/autotest'
-
-# Specify the root directory that on client machines
-rootdir = '/tmp/kvm_autotest_root'
-
-KVM_DIR = os.path.join(AUTOTEST_DIR, 'client/tests/kvm')
-
-
-def generate_mac_address():
- r = random.SystemRandom()
- mac = "9a:%02x:%02x:%02x:%02x:%02x" % (r.randint(0x00, 0xff),
- r.randint(0x00, 0xff),
- r.randint(0x00, 0xff),
- r.randint(0x00, 0xff),
- r.randint(0x00, 0xff))
- return mac
-
-
-def run(pair):
- logging.info("KVM migration running on source host [%s] and destination "
- "host [%s]\n", pair[0], pair[1])
-
- source = hosts.create_host(pair[0])
- dest = hosts.create_host(pair[1])
- source_at = autotest.Autotest(source)
- dest_at = autotest.Autotest(dest)
-
- cfg_file = os.path.join(KVM_DIR, "tests_base.cfg")
-
- if not os.path.exists(cfg_file):
- raise error.JobError("Config file %s was not found", cfg_file)
-
- # Get test set (dictionary list) from the configuration file
- parser = cartesian_config.Parser()
- test_variants = """
-image_name(_.*)? ?<= /tmp/kvm_autotest_root/images/
-cdrom(_.*)? ?<= /tmp/kvm_autotest_root/
-floppy ?<= /tmp/kvm_autotest_root/
-Linux:
- unattended_install:
- kernel ?<= /tmp/kvm_autotest_root/
- initrd ?<= /tmp/kvm_autotest_root/
-qemu_binary = /usr/libexec/qemu-kvm
-qemu_img_binary = /usr/bin/qemu-img
-only qcow2
-only virtio_net
-only virtio_blk
-only smp2
-only no_pci_assignable
-only smallpages
-only Fedora.14.64
-only migrate_multi_host
-nic_mode = tap
-nic_mac_nic1 = %s
-""" % (generate_mac_address())
- parser.parse_file(cfg_file)
- parser.parse_string(test_variants)
- test_dicts = parser.get_dicts()
-
- source_control_file = dest_control_file = """
-kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests/kvm')
-sys.path.append(kvm_test_dir)\n
-"""
- for params in test_dicts:
- params['srchost'] = source.ip
- params['dsthost'] = dest.ip
- params['rootdir'] = rootdir
-
- source_params = params.copy()
- source_params['role'] = "source"
-
- dest_params = params.copy()
- dest_params['role'] = "destination"
- dest_params['migration_mode'] = "tcp"
-
- # Report the parameters we've received
- print "Test parameters:"
- keys = params.keys()
- keys.sort()
- for key in keys:
- logging.debug(" %s = %s", key, params[key])
-
- source_control_file += ("job.run_test('kvm', tag='%s', params=%s)" %
- (source_params['shortname'], source_params))
- dest_control_file += ("job.run_test('kvm', tag='%s', params=%s)" %
- (dest_params['shortname'], dest_params))
-
- logging.info('Source control file:\n%s', source_control_file)
- logging.info('Destination control file:\n%s', dest_control_file)
- dest_command = subcommand(dest_at.run,
- [dest_control_file, dest.hostname])
-
- source_command = subcommand(source_at.run,
- [source_control_file, source.hostname])
-
- parallel([dest_command, source_command])
-
-# Grab the pairs (and failures)
-(pairs, failures) = utils.form_ntuples_from_machines(machines, 2)
-
-# Log the failures
-for failure in failures:
- job.record("FAIL", failure[0], "kvm", failure[1])
-
-# Now run through each pair and run
-job.parallel_simple(run, pairs, log=False)
diff --git a/client/tests/kvm/multi-host-tests.cfg.sample b/client/tests/kvm/multi-host-tests.cfg.sample
new file mode 100644
index 0000000..17a41e3
--- /dev/null
+++ b/client/tests/kvm/multi-host-tests.cfg.sample
@@ -0,0 +1,43 @@
+# Copy this file to multi-host-tests.cfg and edit it.
+#
+# This file contains the test set definitions for multi host tests.
+
+# Include the shared test files.
+include tests-shared.cfg
+
+# Here are the test sets variants. The variant 'qemu_kvm_windows_quick' is
+# fully commented, the following ones have comments only on noteworthy points
+variants:
+ # Runs qemu-kvm, Windows Vista 64 bit guest OS, install, boot, shutdown
+ - @qemu_migrate_multi_host:
+ qemu_binary = /usr/bin/qemu-kvm
+ qemu_img_binary = /usr/bin/qemu-img
+ qemu_io_binary = /usr/bin/qemu-io
+ nic_mode = tap
+ only qcow2
+ only virtio_net
+ only virtio_blk
+ only smp2
+ only no_pci_assignable
+ only no_9p_export
+ only smallpages
+ only Fedora.15.64
+ only migrate_multi_host
+
+ # Runs qemu, f16 64 bit guest OS, install, boot, shutdown
+ - @qemu_cpuflags_multi_host:
+ qemu_binary = /usr/bin/qemu-kvm
+ qemu_img_binary = /usr/bin/qemu-img
+ qemu_io_binary = /usr/bin/qemu-io
+ nic_mode = tap
+ only qcow2
+ only virtio_net
+ only virtio_blk
+ only smp2
+ only no_pci_assignable
+ only no_9p_export
+ only smallpages
+ only Fedora.15.64
+ only cpuflags_multi_host
+
+only qemu_cpuflags_multi_host
diff --git a/client/tests/kvm/multi_host.srv b/client/tests/kvm/multi_host.srv
new file mode 100644
index 0000000..15acbb3
--- /dev/null
+++ b/client/tests/kvm/multi_host.srv
@@ -0,0 +1,106 @@
+AUTHOR = "Jiri Zupka <jzupka@redhat.com>"
+TIME = "SHORT"
+NAME = ""
+TEST_CATEGORY = "Functional"
+TEST_CLASS = "Virtualization"
+TEST_TYPE = "Server"
+DOC = "KVM tests (multi-host) server control"
+Runs tests across multiple hosts. It uses the config file
+'multi-host-tests.cfg' in order to yield the appropriate
+dicts for the multi host test.
+"""
+
+import sys, os, commands, glob, shutil, logging, random
+from autotest_lib.server import utils
+from autotest_lib.client.common_lib import cartesian_config, error
+
+# Specify the directory of autotest before you start this test
+AUTOTEST_DIR = job.clientdir
+
+KVM_DIR = os.path.join(AUTOTEST_DIR, 'tests', 'kvm')
+
+
+def generate_mac_address():
+ r = random.SystemRandom()
+ mac = "9a:%02x:%02x:%02x:%02x:%02x" % (r.randint(0x00, 0xff),
+ r.randint(0x00, 0xff),
+ r.randint(0x00, 0xff),
+ r.randint(0x00, 0xff),
+ r.randint(0x00, 0xff))
+ return mac
+
+
+def run(pair):
+ logging.info("KVM test running on source host [%s] and destination "
+ "host [%s]\n", pair[0], pair[1])
+
+ source = hosts.create_host(pair[0])
+ dest = hosts.create_host(pair[1])
+ source_at = autotest.Autotest(source)
+ dest_at = autotest.Autotest(dest)
+
+ cfg_file = os.path.join(KVM_DIR, "multi-host-tests.cfg")
+
+ if not os.path.exists(cfg_file):
+ raise error.JobError("Config file %s was not found", cfg_file)
+
+ # Get test set (dictionary list) from the configuration file
+ parser = cartesian_config.Parser()
+ parser.parse_file(cfg_file)
+ test_dicts = parser.get_dicts()
+
+ source_control_file = dest_control_file = """
+testname = "kvm"
+bindir = os.path.join(job.testdir, testname)
+job.install_pkg(testname, 'test', bindir)
+
+kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests', 'kvm')
+sys.path.append(kvm_test_dir)
+"""
+ import sys
+
+ for params in test_dicts:
+ params['srchost'] = source.ip
+ params['dsthost'] = dest.ip
+
+ for nic in params.get('nics',"").split():
+ params['nic_mac_%s' % nic] = generate_mac_address()
+
+ source_params = params.copy()
+ source_params['role'] = "source"
+
+ dest_params = params.copy()
+ dest_params['role'] = "destination"
+ dest_params['migration_mode'] = "tcp"
+
+ # Report the parameters we've received
+ print "Test parameters:"
+ keys = params.keys()
+ keys.sort()
+ for key in keys:
+ logging.debug(" %s = %s", key, params[key])
+
+ source_control_file += ("job.run_test('kvm', tag='%s', params=%s)" %
+ (source_params['shortname'], source_params))
+ dest_control_file += ("job.run_test('kvm', tag='%s', params=%s)" %
+ (dest_params['shortname'], dest_params))
+
+ logging.info('Source control file:\n%s', source_control_file)
+ logging.info('Destination control file:\n%s', dest_control_file)
+ dest_command = subcommand(dest_at.run,
+ [dest_control_file, dest.hostname])
+
+ source_command = subcommand(source_at.run,
+ [source_control_file, source.hostname])
+
+ parallel([dest_command, source_command])
+
+# Grab the pairs (and failures)
+(pairs, failures) = utils.form_ntuples_from_machines(machines, 2)
+
+# Log the failures
+for failure in failures:
+ job.record("FAIL", failure[0], "kvm", failure[1])
+
+# Now run through each pair and run
+job.parallel_simple(run, pairs, log=False)
diff --git a/client/tests/kvm/tests-shared.cfg.sample b/client/tests/kvm/tests-shared.cfg.sample
new file mode 100644
index 0000000..9de3b93
--- /dev/null
+++ b/client/tests/kvm/tests-shared.cfg.sample
@@ -0,0 +1,48 @@
+# Copy this file to tests-shared.cfg and edit it.
+#
+# This file contains the base test set definitions, shared among single host
+# and multi host jobs.
+
+# Include the base config files.
+include base.cfg
+include subtests.cfg
+include guest-os.cfg
+include guest-hw.cfg
+include cdkeys.cfg
+include virtio-win.cfg
+
+# Virtualization type (kvm or libvirt)
+# TODO: Update code to use vm_library + vm_type + vm_subtype
+# i.e. (libvirt/none) + (qemu/kvm/xen) + (hvm/paravirt)
+vm_type = kvm
+
+# Modify/comment the following lines if you wish to modify the paths of the
+# image files, ISO files or qemu binaries.
+#
+# As for the defaults:
+# * qemu and qemu-img are expected to be found under /usr/bin/qemu-kvm and
+# /usr/bin/qemu-img respectively.
+# * All image files are expected under /tmp/kvm_autotest_root/images/
+# * All install iso files are expected under /tmp/kvm_autotest_root/isos/
+# * The parameters cdrom_unattended, floppy, kernel and initrd are generated
+# by KVM autotest, so remember to put them under a writable location
+# (for example, the cdrom share can be read only)
+image_name(_.*)? ?<= /tmp/kvm_autotest_root/images/
+cdrom(_.*)? ?<= /tmp/kvm_autotest_root/
+floppy ?<= /tmp/kvm_autotest_root/
+Linux..unattended_install:
+ kernel ?<= /tmp/kvm_autotest_root/
+ initrd ?<= /tmp/kvm_autotest_root/
+
+# You may provide information about the DTM server for WHQL tests here:
+#whql:
+# server_address = 10.20.30.40
+# server_shell_port = 10022
+# server_file_transfer_port = 10023
+# Note that the DTM server must run rss.exe (available under deps/),
+# preferably with administrator privileges.
+
+# Uncomment the following lines to enable abort-on-error mode:
+#abort_on_error = yes
+#kill_vm.* ?= no
+#kill_unresponsive_vms.* ?= no
diff --git a/client/tests/kvm/tests.cfg.sample b/client/tests/kvm/tests.cfg.sample
index e03e007..c91a58b 100644
--- a/client/tests/kvm/tests.cfg.sample
+++ b/client/tests/kvm/tests.cfg.sample
@@ -3,17 +3,7 @@
# This file contains the test set definitions. Define your test sets here.
# Include the base config files.
-include base.cfg
-include subtests.cfg
-include guest-os.cfg
-include guest-hw.cfg
-include cdkeys.cfg
-include virtio-win.cfg
-
-# Virtualization type (kvm or libvirt)
-# TODO: Update code to use vm_library + vm_type + vm_subtype
-# i.e. (libvirt/none) + (qemu/kvm/xen) + (hvm/paravirt)
-vm_type = kvm
+include tests-shared.cfg
# Here you can override the image name for our custom linux and windows guests
#
@@ -36,24 +26,6 @@ CustomGuestWindows:
#image_name = /dev/mapper/vg_windows_guest
#image_raw_device = yes
-# Modify/comment the following lines if you wish to modify the paths of the
-# image files, ISO files or qemu binaries.
-#
-# As for the defaults:
-# * qemu and qemu-img are expected to be found under /usr/bin/qemu-kvm and
-# /usr/bin/qemu-img respectively.
-# * All image files are expected under /tmp/kvm_autotest_root/images/
-# * All install iso files are expected under /tmp/kvm_autotest_root/isos/
-# * The parameters cdrom_unattended, floppy, kernel and initrd are generated
-# by KVM autotest, so remember to put them under a writable location
-# (for example, the cdrom share can be read only)
-image_name(_.*)? ?<= /tmp/kvm_autotest_root/images/
-cdrom(_.*)? ?<= /tmp/kvm_autotest_root/
-floppy ?<= /tmp/kvm_autotest_root/
-Linux..unattended_install:
- kernel ?<= /tmp/kvm_autotest_root/
- initrd ?<= /tmp/kvm_autotest_root/
-
# Here are the test sets variants. The variant 'qemu_kvm_windows_quick' is
# fully commented, the following ones have comments only on noteworthy points
variants:
@@ -156,18 +128,5 @@ variants:
only CustomGuestLinux
only migrate
-# You may provide information about the DTM server for WHQL tests here:
-#whql:
-# server_address = 10.20.30.40
-# server_shell_port = 10022
-# server_file_transfer_port = 10023
-# Note that the DTM server must run rss.exe (available under deps/),
-# preferably with administrator privileges.
-
-# Uncomment the following lines to enable abort-on-error mode:
-#abort_on_error = yes
-#kill_vm.* ?= no
-#kill_unresponsive_vms.* ?= no
-
# Choose your test list from the testsets defined
only qemu_kvm_f16_quick
--
1.7.7.6
_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [KVM-Autotest][PATCH 4/5] virt deps: Reduces memory usage of test
2012-01-31 14:40 [KVM-Autotest] Add multihost migration support to cpuflags Jiří Župka
` (2 preceding siblings ...)
2012-01-31 14:40 ` [KVM-Autotest][PATCH 3/5] kvm test: Introduce multi_host.srv Jiří Župka
@ 2012-01-31 14:40 ` Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 5/5] kvm test: Add multihost migration support to cpuflag test Jiří Župka
4 siblings, 0 replies; 6+ messages in thread
From: Jiří Župka @ 2012-01-31 14:40 UTC (permalink / raw)
To: autotest, kvm, kvm-autotest, lmr, ldoktor, jzupka
This change is necessary because there is a
problem with network bandwidth during migration.
Signed-off-by: Jiří Župka <jzupka@redhat.com>
---
client/virt/deps/test_cpu_flags/stress.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/client/virt/deps/test_cpu_flags/stress.c b/client/virt/deps/test_cpu_flags/stress.c
index 13d0505..ae424c2 100644
--- a/client/virt/deps/test_cpu_flags/stress.c
+++ b/client/virt/deps/test_cpu_flags/stress.c
@@ -7,7 +7,7 @@
#include "tests.h"
-#define size (40000000)
+#define size (4194304)
void AddTwo(float *aa, float *bb, int num_threads) {
{
--
1.7.7.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [KVM-Autotest][PATCH 5/5] kvm test: Add multihost migration support to cpuflag test
2012-01-31 14:40 [KVM-Autotest] Add multihost migration support to cpuflags Jiří Župka
` (3 preceding siblings ...)
2012-01-31 14:40 ` [KVM-Autotest][PATCH 4/5] virt deps: Reduces memory usage of test Jiří Župka
@ 2012-01-31 14:40 ` Jiří Župka
4 siblings, 0 replies; 6+ messages in thread
From: Jiří Župka @ 2012-01-31 14:40 UTC (permalink / raw)
To: autotest, kvm, kvm-autotest, lmr, ldoktor, jzupka
Signed-off-by: Jiří Župka <jzupka@redhat.com>
---
client/tests/kvm/tests/cpuflags.py | 284 +++++++++++++++++++++++++++++++-----
client/virt/subtests.cfg.sample | 17 ++-
2 files changed, 263 insertions(+), 38 deletions(-)
diff --git a/client/tests/kvm/tests/cpuflags.py b/client/tests/kvm/tests/cpuflags.py
index 6f281d0..c2111d4 100644
--- a/client/tests/kvm/tests/cpuflags.py
+++ b/client/tests/kvm/tests/cpuflags.py
@@ -1,4 +1,4 @@
-import logging, re, random, os, time
+import logging, re, random, os, time, socket, pickle
from autotest_lib.client.common_lib import error, utils
from autotest_lib.client.virt import kvm_vm
from autotest_lib.client.virt import virt_utils, aexpect
@@ -14,10 +14,9 @@ def run_cpuflags(test, params, env):
@param params: Dictionary with the test parameters.
@param env: Dictionary with test environment.
"""
+ virt_utils.Flag.aliases = virt_utils.kvm_map_flags_aliases
qemu_binary = virt_utils.get_path('.', params.get("qemu_binary", "qemu"))
- cpuflags_path = os.path.join(test.virtdir, "deps")
- cpuflags_tar = "cpuflags-test.tar.bz2"
cpuflags_src = os.path.join(test.virtdir, "deps", "test_cpu_flags")
smp = int(params.get("smp", 1))
@@ -25,8 +24,9 @@ def run_cpuflags(test, params, env):
mig_timeout = float(params.get("mig_timeout", "3600"))
mig_protocol = params.get("migration_protocol", "tcp")
- mig_speed = params.get("mig_speed", "1G")
+ mig_speed = params.get("mig_speed", "100M")
+ multi_host_migration = params.get("multi_host_migration", "no")
class HgFlags(object):
def __init__(self, cpu_model, extra_flags=set([])):
@@ -62,7 +62,8 @@ def run_cpuflags(test, params, env):
virtual_flags)
- def start_guest_with_cpuflags(cpuflags, smp=None):
+ def start_guest_with_cpuflags(cpuflags, smp=None, migration=False,
+ wait=True):
"""
Try to boot guest with special cpu flags and try login in to them.
"""
@@ -74,10 +75,15 @@ def run_cpuflags(test, params, env):
vm_name = "vm1-cpuflags"
vm = kvm_vm.VM(vm_name, params_b, test.bindir, env['address_cache'])
env.register_vm(vm_name, vm)
- vm.create()
+ if (migration is True):
+ vm.create(migration_mode=mig_protocol)
+ else:
+ vm.create()
vm.verify_alive()
- session = vm.wait_for_login()
+ session = None
+ if wait:
+ session = vm.wait_for_login()
return (vm, session)
@@ -228,8 +234,10 @@ def run_cpuflags(test, params, env):
"""
session = vm.wait_for_login()
vm.copy_files_to(cpuflags_src, dst_dir)
+ session.cmd("sync")
session.cmd("cd %s; make EXTRA_FLAGS='';" %
os.path.join(dst_dir, "test_cpu_flags"))
+ session.cmd("sync")
session.close()
@@ -293,7 +301,30 @@ def run_cpuflags(test, params, env):
return cpu_model
- def test_qemu_interface():
+ def parse_cpu_model():
+ """
+ Parse cpu_models from config file.
+
+ @return: [(cpumodel, extra_flags)]
+ """
+ cpu_models = params.get("cpu_models","").split()
+ if not cpu_models:
+ cpu_models = get_cpu_models()
+
+ logging.debug("CPU models found: %s", str(cpu_models))
+ models = []
+ for cpu_model in cpu_models:
+ try:
+ (cpu_model, extra_flags) = cpu_model.split(":")
+ extra_flags = set(map(virt_utils.Flag, extra_flags.split(",")))
+ except ValueError:
+ cpu_model = cpu_model
+ extra_flags = set([])
+ models.append((cpu_model,extra_flags))
+ return models
+
+
+ def test_qemu_interface_group():
"""
1) <qemu-kvm-cmd> -cpu ?model
2) <qemu-kvm-cmd> -cpu ?dump
@@ -349,23 +380,20 @@ def run_cpuflags(test, params, env):
test_qemu_dump()
test_qemu_cpuid()
+
class test_temp(Subtest):
def clean(self):
logging.info("cleanup")
if (hasattr(self, "vm")):
self.vm.destroy(gracefully=False)
- def test_boot_guest():
+
+ def test_boot_guest_group():
"""
1) boot with cpu_model
2) migrate with flags
3) <qemu-kvm-cmd> -cpu model_name,+Flag
"""
- cpu_models = params.get("cpu_models","").split()
- if not cpu_models:
- cpu_models = get_cpu_models()
- logging.debug("CPU models found: %s", str(cpu_models))
-
# 1) boot with cpu_model
class test_boot_cpu_model(test_temp):
def test(self, cpu_model):
@@ -460,29 +488,18 @@ def run_cpuflags(test, params, env):
if fwarn_flags:
raise error.TestFail("Qemu did not warn the use of "
"flags %s" % str(fwarn_flags))
- for cpu_model in cpu_models:
- try:
- (cpu_model, extra_flags) = cpu_model.split(":")
- extra_flags = set(map(virt_utils.Flag, extra_flags.split(",")))
- except ValueError:
- cpu_model = cpu_model
- extra_flags = set([])
+ for (cpu_model, extra_flags) in parse_cpu_model():
test_fail_boot_with_host_unsupported_flags(cpu_model, extra_flags)
test_boot_cpu_model(cpu_model)
test_boot_cpu_model_and_additional_flags(cpu_model, extra_flags)
- def test_stress_guest():
+ def test_stress_guest_group():
"""
4) fail boot unsupported flags
5) check guest flags under load cpu, system (dd)
6) online/offline CPU
"""
- cpu_models = params.get("cpu_models","").split()
- if not cpu_models:
- cpu_models = get_cpu_models()
- logging.debug("CPU models found: %s", str(cpu_models))
-
# 4) check guest flags under load cpu, stress and system (dd)
class test_boot_guest_and_try_flags_under_load(test_temp):
def test(self, cpu_model, extra_flags):
@@ -602,20 +619,217 @@ def run_cpuflags(test, params, env):
" migration.")
- for cpu_model in cpu_models:
- try:
- (cpu_model, extra_flags) = cpu_model.split(":")
- extra_flags = set(map(virt_utils.Flag, extra_flags.split(",")))
- except ValueError:
- cpu_model = cpu_model
- extra_flags = set([])
+ for (cpu_model, extra_flags) in parse_cpu_model():
test_boot_guest_and_try_flags_under_load(cpu_model, extra_flags)
test_online_offline_guest_CPUs(cpu_model, extra_flags)
test_migration_with_additional_flags(cpu_model, extra_flags)
+ def net_send_object(socket, obj):
+ """
+ Send python object over network.
+
+ @param ip_addr: ipaddres of waiter for data.
+ @param obj: object to send
+ """
+ data = pickle.dumps(obj, pickle.HIGHEST_PROTOCOL)
+ socket.sendall("%6d" % len(data))
+ socket.sendall(data)
+
+
+ def net_recv_object(socket, timeout=60):
+ """
+ Receive python object over network.
+
+ @param ip_addr: ipaddres of waiter for data.
+ @param obj: object to send
+ @return: object from network
+ """
+ try:
+ time_start = time.time()
+ data = ""
+ d_len = int(socket.recv(6))
+
+ while (len(data) < d_len and (time.time() - time_start) < timeout):
+ data += socket.recv(d_len - len(data))
+
+ data = pickle.loads(data)
+ return data
+ except:
+ error.TestFail("Failed to receive python object over the network")
+ raise
+
+
+ def test_multi_host_migration_group():
+ class test_multi_host_migration(test_temp):
+ def test(self, cpu_model, extra_flags):
+ """
+ Test migration between multiple hosts.
+ """
+ def guest_active(vm):
+ o = vm.monitor.info("status")
+ if isinstance(o, str):
+ return "status: running" in o
+ else:
+ return o.get("status") == "running"
+
+ 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 += ",+" + fadd
+
+ for fdel in flags.host_unsupported_flags:
+ cpuf_model += ",-" + fdel
+
+ install_path = "/tmp"
+ login_timeout = int(params.get("login_timeout", 360))
+ role = params.get("role")
+ srchost = params.get("srchost")
+ dsthost = params.get("dsthost")
+ # Port used to communicate info between source and destination
+ comm_port = int(params.get("comm_port", 12324))
+ comm_timeout = float(params.get("comm_timeout", "10"))
+ regain_ip_cmd = params.get("regain_ip_cmd", "dhclient")
+
+ if role == 'source':
+ (self.vm, session) = start_guest_with_cpuflags(cpuf_model,
+ smp)
+
+ install_cpuflags_test_on_vm(self.vm, install_path)
+
+ Flags = check_cpuflags_work(self.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]))
+
+ session.sendline("nohup dd if=/dev/[svh]da of=/tmp/"
+ "stressblock bs=10MB count=100 &")
+
+ cmd = ("nohup %s/cpuflags-test --stress %s%s &" %
+ (os.path.join(install_path, "test_cpu_flags"), smp,
+ virt_utils.kvm_flags_to_stresstests(Flags[0] &
+ flags.guest_flags)))
+ logging.debug("Guest_flags: %s",str(flags.guest_flags))
+ logging.debug("Working_flags: %s",str(Flags[0]))
+ logging.debug("Start stress on guest: %s", cmd)
+ session.sendline(cmd)
+
+ # Listen on a port to get the migration port received from
+ # dest machine
+ s_socket = socket.socket(socket.AF_INET,
+ socket.SOCK_STREAM)
+ s_socket.bind(('', comm_port))
+ s_socket.listen(1)
+ s_socket.settimeout(comm_timeout)
+
+ # Wait 30 seconds for source and dest to reach this point
+ test.job.barrier(srchost,
+ 'socket_started', 120).rendezvous(srchost,
+ dsthost)
+
+ c_socket = s_socket.accept()[0]
+
+ mig_port = int(c_socket.recv(6))
+ logging.info("Received from destination the"
+ " migration port %s" % mig_port)
+ c_socket.close()
+
+ #Wait for start cpuflags-test stress.
+ time.sleep(10)
+ logging.info("Start migrating now...")
+ self.vm.monitor.migrate_set_speed(mig_speed)
+ self.vm.migrate(dest_host=dsthost, remote_port=mig_port)
+
+ # Wait up to 30 seconds for dest to reach this point
+ test.job.barrier(srchost,
+ 'mig_finished', 30).rendezvous(srchost,
+ dsthost)
+
+ elif role == 'destination':
+ # Wait up to login_timeout + 30 seconds for the source to
+ # reach this point
+ (self.vm, _) = start_guest_with_cpuflags(cpuf_model,
+ smp,
+ True,
+ False)
+
+ test.job.barrier(dsthost, 'socket_started',
+ login_timeout + 120).rendezvous(srchost,
+ dsthost)
+
+ c_socket = socket.socket(socket.AF_INET,
+ socket.SOCK_STREAM)
+ c_socket.settimeout(comm_timeout)
+ c_socket.connect((srchost, comm_port))
+
+ logging.info("Communicating to source migration"
+ " port %s" % self.vm.migration_port)
+ c_socket.send("%d" % self.vm.migration_port)
+ c_socket.close()
+
+ # Wait up to mig_timeout + 30 seconds for the source to
+ # reach this point: migration finished
+ test.job.barrier(dsthost, 'mig_finished',
+ mig_timeout + 30).rendezvous(srchost,
+ dsthost)
+
+ if not guest_active(self.vm):
+ raise error.TestFail("Guest not active after"
+ " migration")
+
+ logging.info("Migrated guest appears to be running")
+
+ # Log into the guest again
+ logging.info("Logging into migrated guest after"
+ " migration...")
+ session_serial = self.vm.wait_for_serial_login(timeout=
+ login_timeout)
+ session_serial.cmd(regain_ip_cmd)
+
+ self.vm.verify_illegal_instructonn()
+
+ session = self.vm.wait_for_login(timeout=login_timeout)
+
+ try:
+ session.cmd('killall cpuflags-test')
+ except aexpect.ShellCmdError:
+ raise error.TestFail("The cpuflags-test program should"
+ " be active after migration and"
+ " it's not.")
+
+ Flags = check_cpuflags_work(self.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]))
+
+ else:
+ raise error.TestError('Invalid role specified')
+
+ for (cpu_model, extra_flags) in parse_cpu_model():
+ test_multi_host_migration(cpu_model, extra_flags)
+
try:
- locals()[params.get("test_type")]()
+ test_type = params.get("test_type")
+ if (test_type in locals()):
+ tests_group = locals()[test_type]
+ tests_group()
+ else:
+ raise error.TestFail("Test group '%s' is not defined in"
+ " cpuflags test" % test_type)
finally:
logging.info("RESULTS:")
for line in Subtest.get_text_result().splitlines():
diff --git a/client/virt/subtests.cfg.sample b/client/virt/subtests.cfg.sample
index 843de30..af84f29 100644
--- a/client/virt/subtests.cfg.sample
+++ b/client/virt/subtests.cfg.sample
@@ -1411,11 +1411,22 @@ variants:
host_spec_flags = "pbe tm ds_cpl monitor acpi dtes64 ht tm2 xtpr est pdcm smx"
variants:
- interface:
- test_type = "test_qemu_interface"
+ test_type = "test_qemu_interface_group"
- boot_guest:
- test_type = "test_boot_guest"
+ test_type = "test_boot_guest_group"
- stress_guest:
- test_type = "test_stress_guest"
+ test_type = "test_stress_guest_group"
+
+ - cpuflags_multi_host:
+ type = cpuflags
+ test_type = test_multi_host_migration_group
+ #Disable all unnecessary vms.
+ vms = ""
+ #Try to start guest with all flags which are supported by host.
+ all_host_supported_flags = "no"
+ cpu_models = "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"
- cpu_hotplug_test:
type = cpu_hotplug
--
1.7.7.6
_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-01-31 14:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-31 14:40 [KVM-Autotest] Add multihost migration support to cpuflags Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 1/5] virt: Check illegal instruction code Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 2/5] virt: Add aliases to class Flag Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 3/5] kvm test: Introduce multi_host.srv Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 4/5] virt deps: Reduces memory usage of test Jiří Župka
2012-01-31 14:40 ` [KVM-Autotest][PATCH 5/5] kvm test: Add multihost migration support to cpuflag test Jiří Župka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).