Re: [Autotest] Biweekly upstream qemu-kvm test report (using autotest + manual) - Week 28

2012-07-20 Thread Qingtang Zhou
* On 2012-07-20 22:52:21 +0800, lei yang (yanglei.f...@gmail.com) wrote:
> Hi
> 
> seems there is no virtio_console testing.which I have no one pass
> and why some of the below cases is mannual, and they are not in the
Because we have no guest agent test case in autotest now. though I'm
working on it. lol
> defalut tests.cfg
> 
> Lei
> 
> 
> On Fri, Jul 20, 2012 at 8:20 PM, Prem Karat
>  wrote:
> > Folks,
> > Please find the result of upstream testing. This time we got a kernel panic
> > error while compiling mainline kernel (3.5.rc7). Hence we could verify only
> > mainline qemu-kvm.
> >
> > We are analysing the failures and we will raise the bugs with the 
> > appropriate
> > community.
> >
> > Host Kernel: Kernel: 3.1.0-7.fc16.x86_64
> > KVM Version:  1.1.50 (qemu-kvm-devel)
> > Date: Thu Jul 19 17:51:29 2012
> > Stat: 59 tests executed - 40 have passed 19 Failed
> > Number of Bugs raised: 2
> > https://bugzilla.kernel.org/show_bug.cgi?id=44901
> > https://github.com/autotest/autotest/issues/467
> >
> >
> > Tests Failed:
> >
> > ..
> >  Test Name  
> > ResultRun time
> > ..
> >
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.autotest.ffsb
> > FAIL   29
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.autotest.disktest
> > FAIL   24
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.autotest.hackbench   
> > FAIL   22
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.autotest.cpu_hotplug 
> > FAIL   57
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.block_stream 
> > FAIL  159
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.linux_s3 
> > FAIL  303
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.cpuflags.boot_guest.qemu_boot_cpu_model
> >   FAIL 2280
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.cpuflags.boot_guest.qemu_boot_cpu_model_and_flags
> > FAIL 2483
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.cpuflags.stress_guest.qemu_test_boot_guest_and_try_flags_under_load
> >   FAIL 2859
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.cpuflags.stress_guest.qemu_test_online_offline_guest_CPUs
> > FAIL 2619
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.cpuflags.stress_guest.qemu_test_migration_with_additional_flags
> >   FAIL 2665
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.cgroup.blkio_throttle
> > FAIL2
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.cgroup.blkio_throttle_multi
> >   FAIL  344
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.cgroup.cpu_share 
> > FAIL1
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.cgroup.cpuset_cpus   
> > FAIL1
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.cgroup.freezer   
> > FAIL2
> > -
> >
> >
> > Tests Passed:
> >
> > ...
> >  Test Name  
> > ResultRun time
> > ...
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.autotest.dbench  
> > PASS  131
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.autotest.ebizzy  
> > PASS   22
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.autotest.stress  
> > PASS   88
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.autotest.sleeptest   
> > PASS   55
> > kvm.qed.virtio_blk.smp2.virtio_net.RHEL.6.2.x86_64.autotest.i

[PATCH] virt test: multicast: Correct multicast_guest.py script path

2012-06-11 Thread Qingtang Zhou
Signed-off-by: Qingtang Zhou 
---
 client/virt/tests/multicast.py |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/client/virt/tests/multicast.py b/client/virt/tests/multicast.py
index 13e3f0d..3fc1084 100644
--- a/client/virt/tests/multicast.py
+++ b/client/virt/tests/multicast.py
@@ -53,7 +53,7 @@ def run_multicast(test, params, env):
 prefix = re.findall("\d+.\d+.\d+", mcast)[0]
 suffix = int(re.findall("\d+", mcast)[-1])
 # copy python script to guest for joining guest to multicast groups
-mcast_path = os.path.join(test.bindir, "scripts/multicast_guest.py")
+mcast_path = os.path.join(test.virtdir, "scripts/multicast_guest.py")
 vm.copy_files_to(mcast_path, "/tmp")
 output = session.cmd_output("python /tmp/multicast_guest.py %d %s %d" %
 (mgroup_count, prefix, suffix))
-- 
1.7.10

--
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


Re: [PATCH] virt-test: support static ip address in framework

2011-12-19 Thread Qingtang Zhou
* On 2011-12-19 21:11:32 +0800, Amos Kong (ak...@redhat.com) wrote:
> Sometime, we need to test with guest(s) which have static ip
> address(es).
> eg. No real/emulated DHCP server in test environment.
> eg. Test with old image we don't want to change the net config.
> eg. Test when DHCP exists problem.
> 
> This is an example of using static ip address:
> 1. edit ifcfg-eth0 of guest to assign static IP
>(192.168.100.110). You can also do this by install
>post-script/serial.
> 2. add and setup bridge in host
># brctl addbr vbr
># ifconfig vbr 192.168.100.1
> 3. add script for setup tap device
>/etc/qemu-ifup-vbr
>| #!/bin/sh
>| switch=vbr
>| /sbin/ifconfig $1 0.0.0.0 up
>| /usr/sbin/brctl addif ${switch} $1
>| /usr/sbin/brctl setfd ${switch} 0
>| /usr/sbin/brctl stp ${switch} off
> 4. assign parameters in config file and execute test as usual
>test.cfg:
>| ip_nic1 = 192.168.100.110
>| mac_nic1 = 11:22:33:44:55:67
>| bridge = vbr
> 
> Signed-off-by: Amos Kong 
> ---
>  client/tests/kvm/base.cfg.sample |3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/client/tests/kvm/base.cfg.sample 
> b/client/tests/kvm/base.cfg.sample
> index 411decf..c86ec1f 100644
> --- a/client/tests/kvm/base.cfg.sample
> +++ b/client/tests/kvm/base.cfg.sample
> @@ -17,6 +17,9 @@ nics = nic1
>  # Connect NIC devices to host bridge device
>  bridge = virbr0
>  
> +# Tell framework of nic1's static ip address
> +ip_nic1 = 192.168.100.110
oops, Amos, better to comment out this line in patch, if this patch applied,
all nic1 will use this static ip, it interrupts our normal testing process.
Who need the static ip should add this line by himself.

> +
>  # List of block device object names (whitespace seperated)
>  images = image1
>  # List of optical device object names
> diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
> index fa258c3..1fb177f 100644
> --- a/client/virt/kvm_vm.py
> +++ b/client/virt/kvm_vm.py
> @@ -821,7 +821,12 @@ class VM(virt_vm.BaseVM):
>  if mac:
>  virt_utils.set_mac_address(self.instance, vlan, mac)
>  else:
> -virt_utils.generate_mac_address(self.instance, vlan)
> +mac = virt_utils.generate_mac_address(self.instance, 
> vlan)
> +
> +if nic_params.get("ip"):
> +self.address_cache[mac] = nic_params.get("ip")
> +logging.debug("(address cache) Adding static cache 
> entry: "
> +  "%s ---> %s" % (mac, nic_params.get("ip")))
>  
>  # Assign a PCI assignable device
>  self.pci_assignable = None
--
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


Re: [Autotest] [PATCH 1/3] KVM-Test: kickstart script: Add pre-installation script for dumping anaconda log

2011-07-06 Thread Qingtang Zhou
* On 2011-07-05 12:54:34 -0300, Lucas Meneghel Rodrigues (l...@redhat.com) 
wrote:
> On Tue, 2011-06-28 at 17:44 +0800, Qingtang Zhou wrote:
> > Anaconda log will help us to analyse failure of installation.
> 
> Hi Qingtang, I have verified the code, have a couple of comments on one
> of the patches. We have a problem though:
> 
> I did test it in my laptop, with both the default atbr0 bridge and
> virbr0, and the side effect of the patchset is that the guest can't
> signal the host the installation has ended. I can't commit the patchset
> in this state, since it brings a major regression. I spend some time
> looking and thinking about it, but the problem is not immediately
> apparent.
> 
> So, would you take the time to fix my comments and test on a setup,
> using the default autotest bridge, figure out the problem and send me an
> updated version? I need to work on other stuff, but if you have any
> problems let me know.

Oh, ok, I will test my code with this 2 kinds of bridge. 

> 
> Cheers,
> 
> Lucas
> 
--
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 3/3] KVM Test: Add get anaconda log config in config file

2011-06-28 Thread Qingtang Zhou

Signed-off-by: Qingtang Zhou 
---
 client/tests/kvm/tests_base.cfg.sample |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/tests_base.cfg.sample 
b/client/tests/kvm/tests_base.cfg.sample
index 4db011d..0fefa3b 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -1208,6 +1208,7 @@ variants:
 # hold your kickstart file
 #extra_params += " --append 'ks=floppy nicdelay=60 
console=ttyS0,115200 console=tty0'"
 extra_params += " --append 'ks=cdrom nicdelay=60 
console=ttyS0,115200 console=tty0'"
+get_anaconda_log = yes
 
 variants:
 - 8.32:
@@ -1724,6 +1725,7 @@ variants:
 # hold your kickstart file
 #extra_params += " --append 'ks=floppy nicdelay=60 
console=ttyS0,115200 console=tty0'"
 extra_params += " --append 'ks=cdrom nicdelay=60 
console=ttyS0,115200 console=tty0'"
+get_anaconda_log = yes
 
 variants:
 - 3.9.i386:
-- 
1.7.4.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 2/3] KVM-Test: unattended_install.py: Get anaconda log and save it to log file

2011-06-28 Thread Qingtang Zhou
This patch will save guest's anaconda log to 'anaconda.log' in debug directory.

Signed-off-by: Qingtang Zhou 
---
 client/tests/kvm/tests/unattended_install.py |   31 ++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/tests/unattended_install.py 
b/client/tests/kvm/tests/unattended_install.py
index 50a8c7a..d631404 100644
--- a/client/tests/kvm/tests/unattended_install.py
+++ b/client/tests/kvm/tests/unattended_install.py
@@ -494,6 +494,28 @@ class UnattendedInstallConfig(object):
 raise ValueError("Unexpected installation method %s" %
  self.medium)
 
+def _get_anaconda_log(vm, log_file):
+port = int(vm.params.get("guest_port_unattended_install")) - 1
+port = vm.get_port(port)
+
+anaconda_logfile = open(log_file, 'w')
+
+while True:
+client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+try:
+client.connect((vm.get_address(), port))
+install_log = client.recv(10240)
+if install_log != "":
+anaconda_logfile.write(install_log)
+anaconda_logfile.flush()
+client.send("ok %s\n" % str(time.time()))
+except (socket.error, virt_vm.VMAddressError):
+pass
+finally:
+client.close()
+time.sleep(1)
+
+anaconda_logfile.close()
 
 @error.context_aware
 def run_unattended_install(test, params, env):
@@ -524,6 +546,13 @@ def run_unattended_install(test, params, env):
  "(%d min)", install_timeout, install_timeout/60)
 error.context("waiting for installation to finish")
 
+get_anaconda_log = params.get("get_anaconda_log") == "yes"
+if get_anaconda_log:
+log_file = os.path.join(test.debugdir, "anaconda.log")
+bg = virt_utils.Thread(_get_anaconda_log,
+kwargs={"vm": vm, "log_file": log_file})
+bg.start()
+
 start_time = time.time()
 while (time.time() - start_time) < install_timeout:
 try:
@@ -539,6 +568,8 @@ def run_unattended_install(test, params, env):
 try:
 client.connect((vm.get_address(), port))
 if client.recv(1024) == "done":
+if get_anaconda_log:
+bg.join()
 break
 except (socket.error, virt_vm.VMAddressError):
 pass
-- 
1.7.4.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/3] KVM-Test: kickstart script: Add pre-installation script for dumping anaconda log

2011-06-28 Thread Qingtang Zhou
Anaconda log will help us to analyse failure of installation.

Signed-off-by: Qingtang Zhou 
---
 client/tests/kvm/unattended/Fedora-10.ks |   35 ++
 client/tests/kvm/unattended/Fedora-11.ks |   35 ++
 client/tests/kvm/unattended/Fedora-12.ks |   35 ++
 client/tests/kvm/unattended/Fedora-13.ks |   35 ++
 client/tests/kvm/unattended/Fedora-14.ks |   35 ++
 client/tests/kvm/unattended/Fedora-8.ks  |   35 ++
 client/tests/kvm/unattended/Fedora-9.ks  |   35 ++
 client/tests/kvm/unattended/RHEL-3-series.ks |   35 ++
 client/tests/kvm/unattended/RHEL-4-series.ks |   35 ++
 client/tests/kvm/unattended/RHEL-5-series.ks |   35 ++
 client/tests/kvm/unattended/RHEL-6-series.ks |   35 ++
 11 files changed, 385 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/unattended/Fedora-10.ks 
b/client/tests/kvm/unattended/Fedora-10.ks
index 081d41a..49bdfbb 100644
--- a/client/tests/kvm/unattended/Fedora-10.ks
+++ b/client/tests/kvm/unattended/Fedora-10.ks
@@ -24,6 +24,41 @@ poweroff
 @development-tools
 ntpdate
 
+%pre --interpreter /usr/bin/python
+import socket, os, sys
+
+try:
+pid = os.fork()
+except OSError, e:
+sys.exit(1)
+
+if pid > 0:
+sys.exit(0)
+
+f = open("/tmp/anaconda.log", 'r')
+sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+os.close(sys.stderr.fileno())
+os.close(sys.stdout.fileno())
+
+sock.bind(('', 12322))
+sock.listen(1)
+
+buf = ""
+while True:
+client, addr = sock.accept()
+o = f.readlines(1024)
+o = "".join(o)
+if buf or o:
+client.send(o)
+data = client.recv(64)
+if "ok" in data:
+buf = ""
+else:
+buf += o
+client.close()
+%end
+
 %post --interpreter /usr/bin/python
 import socket, os
 os.system('dhclient')
diff --git a/client/tests/kvm/unattended/Fedora-11.ks 
b/client/tests/kvm/unattended/Fedora-11.ks
index c339220..17c5721 100644
--- a/client/tests/kvm/unattended/Fedora-11.ks
+++ b/client/tests/kvm/unattended/Fedora-11.ks
@@ -24,6 +24,41 @@ autopart
 ntpdate
 %end
 
+%pre --interpreter /usr/bin/python
+import socket, os, sys
+
+try:
+pid = os.fork()
+except OSError, e:
+sys.exit(1)
+
+if pid > 0:
+sys.exit(0)
+
+f = open("/tmp/anaconda.log", 'r')
+sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+os.close(sys.stderr.fileno())
+os.close(sys.stdout.fileno())
+
+sock.bind(('', 12322))
+sock.listen(1)
+
+buf = ""
+while True:
+client, addr = sock.accept()
+o = f.readlines(1024)
+o = "".join(o)
+if buf or o:
+client.send(o)
+data = client.recv(64)
+if "ok" in data:
+buf = ""
+else:
+buf += o
+client.close()
+%end
+
 %post --interpreter /usr/bin/python
 import socket, os
 os.system('dhclient')
diff --git a/client/tests/kvm/unattended/Fedora-12.ks 
b/client/tests/kvm/unattended/Fedora-12.ks
index c339220..17c5721 100644
--- a/client/tests/kvm/unattended/Fedora-12.ks
+++ b/client/tests/kvm/unattended/Fedora-12.ks
@@ -24,6 +24,41 @@ autopart
 ntpdate
 %end
 
+%pre --interpreter /usr/bin/python
+import socket, os, sys
+
+try:
+pid = os.fork()
+except OSError, e:
+sys.exit(1)
+
+if pid > 0:
+sys.exit(0)
+
+f = open("/tmp/anaconda.log", 'r')
+sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+os.close(sys.stderr.fileno())
+os.close(sys.stdout.fileno())
+
+sock.bind(('', 12322))
+sock.listen(1)
+
+buf = ""
+while True:
+client, addr = sock.accept()
+o = f.readlines(1024)
+o = "".join(o)
+if buf or o:
+client.send(o)
+data = client.recv(64)
+if "ok" in data:
+buf = ""
+else:
+buf += o
+client.close()
+%end
+
 %post --interpreter /usr/bin/python
 import socket, os
 os.system('dhclient')
diff --git a/client/tests/kvm/unattended/Fedora-13.ks 
b/client/tests/kvm/unattended/Fedora-13.ks
index c339220..17c5721 100644
--- a/client/tests/kvm/unattended/Fedora-13.ks
+++ b/client/tests/kvm/unattended/Fedora-13.ks
@@ -24,6 +24,41 @@ autopart
 ntpdate
 %end
 
+%pre --interpreter /usr/bin/python
+import socket, os, sys
+
+try:
+pid = os.fork()
+except OSError, e:
+sys.exit(1)
+
+if pid > 0:
+sys.exit(0)
+
+f = open("/tmp/anaconda.log", 'r')
+sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+os.close(sys.stderr.fileno())
+os.close(sys.stdout.fileno())
+
+sock.bind(('', 12322))
+sock.listen(1)
+
+buf = ""
+while True:
+client,

[PATCH v2] KVM Test: kvm_monitor.py: Close socket explicitly if exception raised in __init__

2011-06-23 Thread Qingtang Zhou
monitor socket will be initiated at the beginning of '*Monitor.__init__',
if exception occur in this function, socket will not be closed correctly.
In this case, socket should be closed explicitly.

Signed-off-by: Qingtang Zhou 
---
 client/virt/kvm_monitor.py |   18 +-
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/client/virt/kvm_monitor.py b/client/virt/kvm_monitor.py
index aff716a..3980da8 100644
--- a/client/virt/kvm_monitor.py
+++ b/client/virt/kvm_monitor.py
@@ -82,11 +82,7 @@ class Monitor:
 def __del__(self):
 # Automatically close the connection when the instance is garbage
 # collected
-try:
-self._socket.shutdown(socket.SHUT_RDWR)
-except socket.error:
-pass
-self._socket.close()
+self._close_sock()
 
 
 # The following two functions are defined to make sure the state is set
@@ -106,6 +102,13 @@ class Monitor:
 return self.name, self.filename, True
 
 
+def _close_sock(self):
+try:
+self._socket.shutdown(socket.SHUT_RDWR)
+except socket.error:
+pass
+self._socket.close()
+
 def _acquire_lock(self, timeout=20):
 end_time = time.time() + timeout
 while time.time() < end_time:
@@ -171,6 +174,7 @@ 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)
@@ -179,6 +183,7 @@ class HumanMonitor(Monitor):
 self._help_str = self.cmd("help", debug=False)
 
 except MonitorError, e:
+self._close_sock()
 if suppress_exceptions:
 logging.warn(e)
 else:
@@ -427,6 +432,7 @@ class QMPMonitor(Monitor):
 try:
 json
 except NameError:
+self._close_sock()
 raise MonitorNotSupportedError("QMP requires the json module "
"(Python 2.6 and up)")
 
@@ -441,12 +447,14 @@ class QMPMonitor(Monitor):
 break
 time.sleep(0.1)
 else:
+self._close_sock()
 raise MonitorProtocolError("No QMP greeting message received")
 
 # Issue qmp_capabilities
 self.cmd("qmp_capabilities")
 
 except MonitorError, e:
+self._close_sock()
 if suppress_exceptions:
 logging.warn(e)
 else:
-- 
1.7.4.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: physical_resources_check: Update case and fix error

2011-06-22 Thread Qingtang Zhou
- update this case, make it easy to get failure from result.
- fix some error in log message.
- close session before exception raised.
- update code style.

Signed-off-by: Qingtang Zhou 
---
 client/tests/kvm/tests/physical_resources_check.py |  178 +++-
 1 files changed, 96 insertions(+), 82 deletions(-)

diff --git a/client/tests/kvm/tests/physical_resources_check.py 
b/client/tests/kvm/tests/physical_resources_check.py
index 5415a09..4e2df06 100644
--- a/client/tests/kvm/tests/physical_resources_check.py
+++ b/client/tests/kvm/tests/physical_resources_check.py
@@ -17,70 +17,31 @@ def run_physical_resources_check(test, params, env):
 @param params: Dictionary with the test parameters
 @param env: Dictionary with test environment.
 """
-vm = env.get_vm(params["main_vm"])
-vm.verify_alive()
-timeout = int(params.get("login_timeout", 360))
-session = vm.wait_for_login(timeout=timeout)
-
-logging.info("Starting physical resources check test")
-logging.info("Values assigned to VM are the values we expect "
- "to see reported by the Operating System")
-# Define a failure counter, as we want to check all physical
-# resources to know which checks passed and which ones failed
-n_fail = 0
-
-# We will check HDs with the image name
-image_name = virt_vm.get_image_filename(params, test.bindir)
-
-# Check cpu count
-logging.info("CPU count check")
-expected_cpu_nr = int(params.get("smp"))
-actual_cpu_nr = vm.get_cpu_count()
-if expected_cpu_nr != actual_cpu_nr:
-n_fail += 1
-logging.error("CPU count mismatch:")
-logging.error("Assigned to VM: %s", expected_cpu_nr)
-logging.error("Reported by OS: %s", actual_cpu_nr)
-
-# Check memory size
-logging.info("Memory size check")
-expected_mem = int(params.get("mem"))
-actual_mem = vm.get_memory_size()
-if actual_mem != expected_mem:
-n_fail += 1
-logging.error("Memory size mismatch:")
-logging.error("Assigned to VM: %s", expected_mem)
-logging.error("Reported by OS: %s", actual_mem)
-
 # Define a function for checking number of hard drivers & NICs
 def check_num(devices, info_cmd, check_str):
-f_fail = 0
+f_fail = []
 expected_num = params.objects(devices).__len__()
 o = ""
 try:
 o = vm.monitor.info(info_cmd)
 except kvm_monitor.MonitorError, e:
-f_fail += 1
-logging.error(e)
-logging.error("info/query monitor command failed (%s)", info_cmd)
+fail_log =  e + "\n"
+fail_log += "info/query monitor command failed (%s)" % info_cmd
+f_fail.append(fail_log)
+logging.error(fail_log)
 
 actual_num = string.count(o, check_str)
 if expected_num != actual_num:
-f_fail += 1
-logging.error("%s number mismatch:")
-logging.error("Assigned to VM: %d", expected_num)
-logging.error("Reported by OS: %d", actual_num)
+fail_log =  "%s number mismatch:\n" % str(devices)
+fail_log += "Assigned to VM: %d\n" % expected_num
+fail_log += "Reported by OS: %d" % actual_num
+f_fail.append(fail_log)
+logging.error(fail_log)
 return expected_num, f_fail
 
-logging.info("Hard drive count check")
-n_fail += check_num("images", "block", image_name)[1]
-
-logging.info("NIC count check")
-n_fail += check_num("nics", "network", "model=")[1]
-
 # Define a function for checking hard drives & NICs' model
 def chk_fmt_model(device, fmt_model, info_cmd, regexp):
-f_fail = 0
+f_fail = []
 devices = params.objects(device)
 for chk_device in devices:
 expected = params.object_params(chk_device).get(fmt_model)
@@ -90,10 +51,10 @@ def run_physical_resources_check(test, params, env):
 try:
 o = vm.monitor.info(info_cmd)
 except kvm_monitor.MonitorError, e:
-f_fail += 1
-logging.error(e)
-logging.error("info/query monitor command failed (%s)",
-  info_cmd)
+fail_log = e + "\n"
+fail_log += "info/query monitor command failed (%s)" % info_cmd
+f_fail.append(fail_log)
+logging.error(fail_log)
 
 device_found = re.findall(regexp, o)
 logging.debug("Found devices:

[PATCH] KVM Test: nicdriver_unload.py: Fix some failure whan running RHEL4.8 guest

2011-03-03 Thread Qingtang Zhou
1. readlink in RHEL4.8 doesn't have a '-e' parameter, replace it with '-f'.
2. nic driver parameter path in '/sys' is different, get it from config file.

Signed-off-by: Qingtang Zhou 
---
 client/tests/kvm/tests/nicdriver_unload.py |   13 ++---
 client/tests/kvm/tests_base.cfg.sample |9 +
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/client/tests/kvm/tests/nicdriver_unload.py 
b/client/tests/kvm/tests/nicdriver_unload.py
index 15a73ce..4849f74 100644
--- a/client/tests/kvm/tests/nicdriver_unload.py
+++ b/client/tests/kvm/tests/nicdriver_unload.py
@@ -26,9 +26,16 @@ def run_nicdriver_unload(test, params, env):
 
 ethname = kvm_test_utils.get_linux_ifname(session_serial,
   vm.get_mac_address(0))
-sys_path = "/sys/class/net/%s/device/driver" % (ethname)
-driver = os.path.basename(session_serial.cmd("readlink -e %s" %
- sys_path).strip())
+
+# get ethernet driver from '/sys' directory.
+# ethtool can do the same thing and doesn't care about os type.
+# if we make sure all guests have ethtool, we can make a change here.
+sys_path = params.get("sys_path") % (ethname)
+
+# readlink in RHEL4.8 doesn't have '-e' param, should use '-f' in RHEL4.8.
+readlink_cmd = params.get("readlink_command", "readlink -e")
+driver = os.path.basename(session_serial.cmd("%s %s" % (readlink_cmd,
+ sys_path)).strip())
 logging.info("driver is %s", driver)
 
 try:
diff --git a/client/tests/kvm/tests_base.cfg.sample 
b/client/tests/kvm/tests_base.cfg.sample
index eef8c97..7616888 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -1009,6 +1009,9 @@ variants:
 file_transfer:
 tmp_dir = /tmp/
 clean_cmd = rm -f
+nicdriver_unload:
+readlink_command = readlink -e
+sys_path = "/sys/class/net/%s/device/driver"
 
 variants:
 - Fedora:
@@ -1602,6 +1605,9 @@ variants:
 cdrom_cd1 = isos/linux/RHEL-4.8-i386-DVD.iso
 md5sum_cd1 = b024f0af5079539d3ef51f71fed0b194
 md5sum_1m_cd1 = 969c197402b9058f28a278c1f807d15b
+nicdriver_unload:
+readlink_command = readlink -f
+sys_path = "/sys/class/net/%s/driver"
 
 
 - 4.8.x86_64:
@@ -1617,6 +1623,9 @@ variants:
 cdrom_cd1 = isos/linux/RHEL-4.8-x86_64-DVD.iso
 md5sum_cd1 = 696bc877b0200cc942626673fcc3fc09
 md5sum_1m_cd1 = b11ac0ef7fd345ad712966972db63886
+nicdriver_unload:
+readlink_command = readlink -f
+sys_path = "/sys/class/net/%s/driver"
 
 
 - 5.3.i386:
-- 
1.7.4.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: Introduce qmp_basic test for RHEL6 host

2011-01-17 Thread Qingtang Zhou
qmp feature provided with RHEL6 is different from qmp in qemu-kvm 0.13.*.
introduce a new test for RHEL6.

Signed-off-by: Qingtang Zhou 
---
 client/tests/kvm/tests/qmp_basic_rhel6.py |  386 +
 client/tests/kvm/tests_base.cfg.sample|3 +
 2 files changed, 389 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/qmp_basic_rhel6.py

diff --git a/client/tests/kvm/tests/qmp_basic_rhel6.py 
b/client/tests/kvm/tests/qmp_basic_rhel6.py
new file mode 100644
index 000..1b780f5
--- /dev/null
+++ b/client/tests/kvm/tests/qmp_basic_rhel6.py
@@ -0,0 +1,386 @@
+import kvm_test_utils, kvm_monitor
+from autotest_lib.client.common_lib import error
+
+def run_qmp_basic(test, params, env):
+"""
+QMP Specification test-suite: this checks if the *basic* protocol conforms
+to its specification, which is file QMP/qmp-spec.txt in QEMU's source tree.
+
+IMPORTANT NOTES:
+
+o Most tests depend heavily on QMP's error information (eg. classes),
+  this might have bad implications as the error interface is going to
+  change in QMP
+
+o Command testing is *not* covered in this suite. Each command has its
+  own specification and should be tested separately
+
+o We use the same terminology as used by the QMP specification,
+  specially with regard to JSON types (eg. a Python dict is called
+  a json-object)
+
+o This is divided in sub test-suites, please check the bottom of this
+  file to check the order in which they are run
+
+TODO:
+
+o Finding which test failed is not as easy as it should be
+
+o Are all those check_*() functions really needed? Wouldn't a
+  specialized class (eg. a Response class) do better?
+"""
+def fail_no_key(qmp_dict, key):
+if not isinstance(qmp_dict, dict):
+raise error.TestFail("qmp_dict is not a dict (it's '%s')" %
+ type(qmp_dict))
+if not key in qmp_dict:
+raise error.TestFail("'%s' key doesn't exist in dict ('%s')" %
+ (key, str(qmp_dict)))
+
+
+def check_dict_key(qmp_dict, key, keytype):
+"""
+Performs the following checks on a QMP dict key:
+
+1. qmp_dict is a dict
+2. key exists in qmp_dict
+3. key is of type keytype
+
+If any of these checks fails, error.TestFail is raised.
+"""
+fail_no_key(qmp_dict, key)
+if not isinstance(qmp_dict[key], keytype):
+raise error.TestFail("'%s' key is not of type '%s', it's '%s'" %
+ (key, keytype, type(qmp_dict[key])))
+
+
+def check_key_is_dict(qmp_dict, key):
+check_dict_key(qmp_dict, key, dict)
+
+
+def check_key_is_list(qmp_dict, key):
+check_dict_key(qmp_dict, key, list)
+
+
+def check_key_is_str(qmp_dict, key):
+check_dict_key(qmp_dict, key, unicode)
+
+
+def check_str_key(qmp_dict, keyname, value=None):
+check_dict_key(qmp_dict, keyname, unicode)
+if value and value != qmp_dict[keyname]:
+raise error.TestFail("'%s' key value '%s' should be '%s'" %
+ (keyname, str(qmp_dict[keyname]), str(value)))
+
+
+def check_key_is_int(qmp_dict, key):
+fail_no_key(qmp_dict, key)
+try:
+int(qmp_dict[key])
+except:
+raise error.TestFail("'%s' key is not of type int, it's '%s'" %
+ (key, type(qmp_dict[key])))
+
+
+def check_bool_key(qmp_dict, keyname, value=None):
+check_dict_key(qmp_dict, keyname, bool)
+if value and value != qmp_dict[keyname]:
+raise error.TestFail("'%s' key value '%s' should be '%s'" %
+ (keyname, str(qmp_dict[keyname]), str(value)))
+
+
+def check_success_resp(resp, empty=False):
+"""
+Check QMP OK response.
+
+@param resp: QMP response
+@param empty: if True, response should not contain data to return
+"""
+check_key_is_dict(resp, "return")
+if empty and len(resp["return"]) > 0:
+raise error.TestFail("success response is not empty ('%s')" %
+ str(resp))
+
+
+def check_error_resp(resp, classname=None, datadict=None):
+"""
+Check QMP error response.
+
+@param resp: QMP response
+@param classname: Expected error class name
+@param datadict: Expected error data dictionary
+&qu