[PATCH] KVM Test: Call postprocess_vm before postprocess_image.

2011-08-04 Thread fyang
From: Feng Yang fy...@redhat.com

Current we call postprocess_image befor postprocess_vm.
If exception is thrown in postprocess_image, postprocess_vm will
be skipped. So vm could not be killed, it may fail following case
 in same loop.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/virt/virt_env_process.py |   25 -
 1 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/client/virt/virt_env_process.py b/client/virt/virt_env_process.py
index 12918eb..8fd5c21 100644
--- a/client/virt/virt_env_process.py
+++ b/client/virt/virt_env_process.py
@@ -163,7 +163,7 @@ def process_command(test, params, env, command, 
command_timeout,
 raise
 
 
-def process(test, params, env, image_func, vm_func):
+def process(test, params, env, image_func, vm_func, vm_first=False):
 
 Pre- or post-process VMs and images according to the instructions in 
params.
 Call image_func for each image listed in params and vm_func for each VM.
@@ -177,13 +177,20 @@ def process(test, params, env, image_func, vm_func):
 # Get list of VMs specified for this test
 for vm_name in params.objects(vms):
 vm_params = params.object_params(vm_name)
-# Get list of images specified for this VM
-for image_name in vm_params.objects(images):
-image_params = vm_params.object_params(image_name)
-# Call image_func for each image
-image_func(test, image_params)
-# Call vm_func for each vm
-vm_func(test, vm_params, env, vm_name)
+if not vm_first:
+# Get list of images specified for this VM
+for image_name in vm_params.objects(images):
+image_params = vm_params.object_params(image_name)
+# Call image_func for each image
+image_func(test, image_params)
+# Call vm_func for each vm
+vm_func(test, vm_params, env, vm_name)
+else:
+vm_func(test, vm_params, env, vm_name)
+for image_name in vm_params.objects(images):
+image_params = vm_params.object_params(image_name)
+image_func(test, image_params)
+
 
 
 @error.context_aware
@@ -293,7 +300,7 @@ def postprocess(test, params, env):
 error.context(postprocessing)
 
 # Postprocess all VMs and images
-process(test, params, env, postprocess_image, postprocess_vm)
+process(test, params, env, postprocess_image, postprocess_vm, 
vm_first=True)
 
 # Terminate the screendump thread
 global _screendump_thread, _screendump_thread_termination_event
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM Test: Remove duplicated _close_sock function calls in kvm_monitor.py

2011-08-04 Thread fyang
From: Feng Yang fy...@redhat.com

self._close_sock will be called two times in HumanMonitor.__init__ and
QMPMonitor.__init__ in exception.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/virt/kvm_monitor.py |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/client/virt/kvm_monitor.py b/client/virt/kvm_monitor.py
index 3980da8..c96f062 100644
--- a/client/virt/kvm_monitor.py
+++ b/client/virt/kvm_monitor.py
@@ -174,7 +174,6 @@ class HumanMonitor(Monitor):
 # Find the initial (qemu) prompt
 s, o = self._read_up_to_qemu_prompt(20)
 if not s:
-self._close_sock()
 raise MonitorProtocolError(Could not find (qemu) prompt 
after connecting to monitor. 
Output so far: %r % o)
@@ -432,7 +431,6 @@ class QMPMonitor(Monitor):
 try:
 json
 except NameError:
-self._close_sock()
 raise MonitorNotSupportedError(QMP requires the json module 
(Python 2.6 and up))
 
@@ -447,7 +445,6 @@ class QMPMonitor(Monitor):
 break
 time.sleep(0.1)
 else:
-self._close_sock()
 raise MonitorProtocolError(No QMP greeting message received)
 
 # Issue qmp_capabilities
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM Test: Drop sre module in script and use re module.

2011-08-04 Thread fyang
From: Feng Yang fy...@redhat.com

sre moudle have been deprecated in python 2.6

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/virt/virt_test_setup.py |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/client/virt/virt_test_setup.py b/client/virt/virt_test_setup.py
index 1539cac..f2ff38b 100644
--- a/client/virt/virt_test_setup.py
+++ b/client/virt/virt_test_setup.py
@@ -1,7 +1,7 @@
 
 Library to perform pre/post test setup for KVM autotest.
 
-import os, logging, time, re, sre, random
+import os, logging, time, re, random
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin import utils
 
@@ -60,7 +60,7 @@ class TransparentHugePageConfig(object):
 tmp_list = re.split(';', test_config)
 while len(tmp_list)  0:
 tmp_cfg = tmp_list.pop()
-test_cfg[re.split(:, tmp_cfg)[0]] = sre.split(:, tmp_cfg)[1]
+test_cfg[re.split(:, tmp_cfg)[0]] = re.split(:, tmp_cfg)[1]
 # Save host current config, so we can restore it during cleanup
 # We will only save the writeable part of the config files
 original_config = {}
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM Test: Catch AttributeError and make screendump thread continue.

2011-06-28 Thread fyang
From: Feng Yang fy...@redhat.com

screendump is start before vm creating.  At most time, it is ok.

But when setting start_vm to no, then create vm in tests script.
This may could not work. screendump thread exit for AttributeError exception.
Some of our unattended_install case fail for this reason.

In order to fix this issue, we may:
1. catch AttributeError exception and make screendump thread continue.
This way is easy fix, but if we do not need vm in a case, screendump thread
will still alive, and print useless debug log.

2. start screendmup thread in vm.create(), then close it in vm.destroy().
This need more work and may bring other problem.

This patch use first way. Please help comment it.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/virt/virt_env_process.py |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/client/virt/virt_env_process.py b/client/virt/virt_env_process.py
index 1eb8ecf..ac3c6f1 100644
--- a/client/virt/virt_env_process.py
+++ b/client/virt/virt_env_process.py
@@ -433,6 +433,9 @@ def _take_screendumps(test, params, env):
 except kvm_monitor.MonitorError, e:
 logging.warn(e)
 continue
+except AttributeError, e:
+logging.warn(e)
+continue
 if not os.path.exists(temp_filename):
 logging.warn(VM '%s' failed to produce a screendump, vm.name)
 continue
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] KVM Test: Add a new kvm subtest multi_disk.

2011-05-25 Thread fyang
From: Feng Yang fy...@redhat.com

This case test multi disk suport in kvm guest os. It can work on Linux and
Windows guest.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/tests/multi_disk.py |  127 ++
 1 files changed, 127 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/multi_disk.py

diff --git a/client/tests/kvm/tests/multi_disk.py 
b/client/tests/kvm/tests/multi_disk.py
new file mode 100644
index 000..262a65d
--- /dev/null
+++ b/client/tests/kvm/tests/multi_disk.py
@@ -0,0 +1,127 @@
+import logging, re, random
+from autotest_lib.client.common_lib import error
+
+def run_multi_disk(test, params, env):
+
+Test multi disk suport of guest, this case will:
+1)create disks image in configuration file
+2)start the guest with those disks.
+3)format those disks.
+4)cope file into / out of those disks.
+5)compare the original file and the copyed file by md5 or fc comand.
+6) Repeat step 3-5 if need
+
+@param test: kvm test object
+@param params: Dictionary with the test parameters
+@param env: Dictionary with test environment.
+
+vm = env.get_vm(params[main_vm])
+vm.verify_alive()
+session = vm.wait_for_login(timeout=int(params.get(login_timeout, 360)))
+
+images = params.get(images).split()
+n_repeat = int(params.get(n_repeat, 1))
+image_num = len(images)
+disk_num = 0
+file_system = params.get(file_system).split()
+fs_num = len(file_system)
+cmd_timeout = float(params.get(cmd_timeout, 360))
+re_str = params.get(re_str)
+block_list = params.get(block_list).split()
+try:
+if params.get(clean_cmd):
+cmd = params.get(clean_cmd)
+session.cmd_status_output(cmd)
+if params.get(pre_cmd):
+cmd = params.get(pre_cmd)
+(s,output) = session.cmd_status_output(cmd, timeout=cmd_timeout)
+if s != 0:
+raise error.TestFail(Create partition on disk failed.\n
+ Output is:%s \n % output)
+cmd = params.get(list_volume_command)
+(s,output) = session.cmd_status_output(cmd, timeout=cmd_timeout)
+if s != 0:
+raise error.TestFail(List volume command failed.\n
+ Output is:%s\n % output)
+disks = re.findall(re_str, output)
+disks.sort()
+logging.debug(Volume list that meet regular expressions: %s % disks)
+if len(disks)  image_num:
+raise error.TestFail(Fail to list all the volume!)
+
+tmp_list = []
+for disk in disks:
+if disk.strip() in block_list:
+tmp_list.append(disk)
+for disk in tmp_list:
+logging.info(No need check volume %s % disk)
+disks.remove(disk)
+
+for i in range(n_repeat):
+logging.info(iterations: %s %(i + 1))
+for disk in disks:
+disk = disk.strip()
+
+logging.info(Format disk: %s... % disk)
+index = random.randint(0,fs_num -1)
+
+# Random select one file system from file_system
+fs = file_system[index].strip()
+cmd = params.get(format_command) % (fs, disk)
+(s, output) = session.cmd_status_output(cmd,
+timeout=cmd_timeout)
+if s != 0:
+raise error.TestFail(Format disk failed with output: %s %
+output)
+if params.get(mount_command):
+cmd = params.get(mount_command) % (disk, disk, disk)
+(s, output) = session.cmd_status_output(cmd)
+if s != 0:
+raise error.TestFail(Mount disk failed. Output: %s %
+ output)
+
+for disk in disks:
+disk = disk.strip()
+
+logging.info(Performing I/O on disk: %s... % disk)
+cmd_list = params.get(cmd_list).split()
+for cmd_l in cmd_list:
+if params.get(cmd_l):
+cmd = params.get(cmd_l) % disk
+(s, output) = session.cmd_status_output(cmd,
+   
timeout=cmd_timeout)
+if s != 0:
+raise error.TestFail(Failed command: %. 
Output:%s %
+  
(cmd,output))
+cmd = params.get(compare_command)
+(s, output) = session.cmd_status_output(cmd)
+if s != 0:
+raise error.TestFail(Fail to compare two files. 
Output:%s %
+   

[PATCH 2/2] KVM Test: sample configure for multi_disk test case.

2011-05-25 Thread fyang
From: Feng Yang fy...@redhat.com

Test this configure with nic_mode = tap
Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/tests_base.cfg.sample |   91 +++-
 1 files changed, 89 insertions(+), 2 deletions(-)

diff --git a/client/tests/kvm/tests_base.cfg.sample 
b/client/tests/kvm/tests_base.cfg.sample
index f8a0e30..4faeddc 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -930,6 +930,47 @@ variants:
 background_cmd = for i in 1 2 3 4; do (dd if=/dev/urandom 
of=/tmp/file bs=102400 count=1000 ); done
 check_cmd = ps -a |grep dd
 login_timeout = 360
+- multi_disk:
+type = multi_disk
+force_create_image = yes
+force_create_image_image1 = no
+remove_image = yes
+remove_image_image1 = no
+cmd_timeout = 1000
+block_list = C: D: vda vda1 vda2 hda hda1 hda2 sda sda1 sda2
+variants:
+- signal_repeat:
+images +=  stg
+image_format_stg = qcow2
+image_name_stg = storage
+image_size_stg = 1G
+n_repeat = 10
+- max_disk:
+only virtio_blk
+images +=  stg stg2 stg3 stg4 stg5 stg6 stg7 stg8 stg9 stg10 
stg11 stg12 stg13 stg14 stg15 stg16 stg17 stg18 stg19 stg20 stg21 stg22 stg23
+image_name_stg = storage
+image_name_stg2 = storage2
+image_name_stg3 = storage3
+image_name_stg4 = storage4
+image_name_stg5 = storage5
+image_name_stg6 = storage6
+image_name_stg7 = storage7
+image_name_stg8 = storage8
+image_name_stg9 = storage9
+image_name_stg10 = storage10
+image_name_stg11 = storage11
+image_name_stg12 = storage12
+image_name_stg13 = storage13
+image_name_stg14 = storage14
+image_name_stg15 = storage15
+image_name_stg16 = storage16
+image_name_stg17 = storage17
+image_name_stg18 = storage18
+image_name_stg19 = storage19
+image_name_stg20 = storage20
+image_name_stg21 = storage21
+image_name_stg22 = storage22
+image_name_stg23 = storage23
 
 - qemu_img:
 type = qemu_img
@@ -1114,6 +1155,28 @@ variants:
 nicdriver_unload:
 readlink_command = readlink -e
 sys_path = /sys/class/net/%s/device/driver
+multi_disk:
+show_mount_cmd = mount|gawk '/mnt/{print $1}'
+clean_cmd = \rm -rf /mnt/*
+cmd_list = copy_to_command copy_from_command
+file_system = ext3 ext2
+mount_command = mkdir /mnt/%s  mount /dev/%s /mnt/%s
+umount_command = umount /dev/%s  rmdir /mnt/%s
+list_volume_command = cd /dev  \ls [vhs]d?
+re_str = [vhs]d[a-z]
+format_command = echo y | mkfs -t %s /dev/%s
+copy_to_command = \cp -rf /bin/ls /mnt/%s
+copy_from_command = \cp -rf /mnt/%s/ls /tmp/ls
+compare_command = cd /bin  md5sum ls  /tmp/ls.md5  cd /tmp  
md5sum -c ls.md5
+check_result_key_word = OK
+max_disk:
+ images +=  stg24 stg25 stg26 stg27
+ image_name_stg24 = storage24
+ image_name_stg25 = storage25
+ image_name_stg26 = storage26
+ image_name_stg27 = storage27
+ list_volume_command = cd /dev  \ls vd*
+ re_str = [vhs]d[a-z][^0-9]
 
 variants:
 - Fedora:
@@ -1644,7 +1707,7 @@ variants:
 
 variants:
 - 3.9.i386:
-no setup autotest linux_s3 guest_s4 shutdown
+no setup autotest linux_s3 guest_s4 shutdown multi_disk
 image_name = rhel3-32
 mem_chk_cmd = dmidecode | awk -F: '/Maximum Capacity/ 
{print $2}'
 install:
@@ -1666,7 +1729,7 @@ variants:
 md5sum_1m_cd1 = 5f10c9417c7b8372b3456c1b5f3f9ed0
 
 - 3.9.x86_64:
-no setup autotest linux_s3 guest_s4 shutdown
+no setup autotest linux_s3 guest_s4 shutdown multi_disk
 image_name = rhel3-64
 mem_chk_cmd = dmidecode | awk -F: '/Maximum Capacity/ 
{print $2}'
 install:
@@ -2017,6 +2080,24 @@ variants:
 clean_cmd = del
 vmstop:
 guest_path = C:\
+multi_disk:
+block_list +=  E:
+shell_port = 23
+shell_client = telnet
+post_cmd = del c:\cmd.exe
+file_system = ntfs fat32
+

[PATCH] KVM Test: Correct file_transfer import link.

2011-05-19 Thread fyang
From: Feng Yang fy...@redhat.com

   modified:   client/tests/kvm/tests/set_link.py
   modified:   client/virt/tests/nic_promisc.py
   modified:   client/virt/tests/nicdriver_unload.py

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/tests/set_link.py|2 +-
 client/virt/tests/nic_promisc.py  |2 +-
 client/virt/tests/nicdriver_unload.py |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/client/tests/kvm/tests/set_link.py 
b/client/tests/kvm/tests/set_link.py
index 94ca30a..ef34c71 100644
--- a/client/tests/kvm/tests/set_link.py
+++ b/client/tests/kvm/tests/set_link.py
@@ -1,6 +1,6 @@
 import logging
 from autotest_lib.client.common_lib import error
-from autotest_lib.client.tests.kvm.tests import file_transfer
+from autotest_lib.client.virt.tests import file_transfer
 from autotest_lib.client.virt import virt_test_utils
 
 
diff --git a/client/virt/tests/nic_promisc.py b/client/virt/tests/nic_promisc.py
index 0ff07b8..de4c4d6 100644
--- a/client/virt/tests/nic_promisc.py
+++ b/client/virt/tests/nic_promisc.py
@@ -1,7 +1,7 @@
 import logging, threading
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin import utils
-from autotest_lib.client.tests.kvm.tests import file_transfer
+from autotest_lib.client.virt.tests import file_transfer
 from autotest_lib.client.virt import virt_test_utils, virt_utils
 
 
diff --git a/client/virt/tests/nicdriver_unload.py 
b/client/virt/tests/nicdriver_unload.py
index 8296523..be0a83f 100644
--- a/client/virt/tests/nicdriver_unload.py
+++ b/client/virt/tests/nicdriver_unload.py
@@ -1,7 +1,7 @@
 import logging, threading, os, time
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin import utils
-from autotest_lib.client.tests.kvm.tests import file_transfer
+from autotest_lib.client.virt.tests import file_transfer
 from autotest_lib.client.virt import virt_test_utils, virt_utils
 
 
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM Test: Switch current working folder in unattended_install.py.

2011-05-19 Thread fyang
From: Feng Yang fy...@redhat.com

Current working folder for
unattended_install_config = UnattendedInstallConfig(test, params)
unattended_install_config.setup()
must be kvm folder.

Signed-off-by: Feng Yang fy...@redhat.com
---
 client/tests/kvm/tests/unattended_install.py |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/tests/unattended_install.py 
b/client/tests/kvm/tests/unattended_install.py
index 50a8c7a..eee1761 100644
--- a/client/tests/kvm/tests/unattended_install.py
+++ b/client/tests/kvm/tests/unattended_install.py
@@ -506,8 +506,11 @@ def run_unattended_install(test, params, env):
 @param params: Dictionary with the test parameters.
 @param env: Dictionary with test environment.
 
+cur_folder = os.getcwd()
+os.chdir(test.bindir)
 unattended_install_config = UnattendedInstallConfig(test, params)
 unattended_install_config.setup()
+os.chdir(cur_folder)
 vm = env.get_vm(params[main_vm])
 vm.create()
 
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html