virt.libvirt_vm: Fix disk cache option

We were not reflecting the present of the cache
option on the virt-install command.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Virt tests: Move image_func outside the loop of vms

Update process put image_func outside the loop of vms to make the
image_func can work for cases don't need to boot up vm. Such as some
tests related with qcow2.

And fix the missing docstring for vm_first.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
virt: Add vhost_threads and vcpu_threads to VM object

Record vhost_net threads ID and vcpus threads ID to vm object
after creating VM.

Signed-off-by: Amos Kong <akong@redhat.com>
virt_test_utils: Add pin_vm_threads

This function is used to pin vhost and vcpu threads of VM to
host cpu (in same numa node).

Signed-off-by: Amos Kong <akong@redhat.com>
virt-test: add NTttcp subtests

This case will test tcp throughput between 2 windows guests,
or between 1 guest and 1 external Windows host.

When test between guest and external Windows host,
'receiver_address' should be set to external Windows' ip address.

NTttcp is not a freely redistributable binary, so you *must* download it
from microsoft and be in agreement with its EULA. See @see tag for a
complete download link and also documentation on how to integrate it to
your autotest setup.

@see: http://msdn.microsoft.com/en-us/windows/hardware/gg463264
@see: http://download.microsoft.com/download/f/1/e/f1e1ac7f-e632-48ea-83ac-56b016318735/NT%20Testing%20TCP%20Tool.msi
@see: https://github.com/autotest/autotest/wiki/KVMAutotest-Networking

! ntttcp.au3: This script will sign "End-user license agreement"
!   for you, please don't use this script if you don't agree EULA.

This test will generate result files with 'standard' format,
split different items by '|', use one line as the title.
We can analyze them by a general modules.
    raw_output_1.RHS:
      buf(k)| throughput(Mbit/s)
           ...
          64| 2407.548
         128| 2102.254
         256| 4930.362
         512| 4723.035
        1024| 4725.334

Changes from v1:
- pin vcpus/vhost_net threads to numa node
- add autoio script for ntttcp test
- user should put msi and autoit script to iso
- fix threads sync issue
- set test time to 30 seconds
- support to use fixed receiver buf or use same buf as sender
- 30 seconds is not enough, assign buf number to 2000000

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
Signed-off-by: Amos Kong <akong@redhat.com>
virt-test: Refactor netperf test and add analysis module

Always use a VM as netperf server, we can use
another VM/localhost/external host as the netperf
clients.
We setup env and launch test by executing remote
ssh commands, you need to configure the IP of
local/external host in configure file, VMs' IP
can be got automatically.
Generate a file with 'standard' format at the end of test,
then we can analyze them by general module.

Changes from v1:
- record packet bytes
- enable arp_ignore
- get packet info from ifconfig
- shape functions
- don't change ssh config
- use server.hosts.ssh_host.SSHHost to setup ssh

Signed-off-by: Amos Kong <akong@redhat.com>
netperf: pin guest vcpus/memory/vhost thread to numa node

Dynamically checking hardware and pin guest cpu threads and
guest memory to last numa node

Changes from v1:
- assign numanode to -1 for netperf test

Signed-off-by: Amos Kong <akong@redhat.com>
virt: Introduce regression testing infrastructure

> regression.py:
Usage: python regression.py $testname $dir1 $dir2 $configfile
 'regression' module is used to compare the test results
 of two jobs, we can use it (regression.compare()) at
 the end of control file, this script can also be used directly.

Example:
| # python regression.py netperf /result1-dir /result2-dir perf.conf

> analyzer.py:
Usage: python analyzer.py "$results list1" "$results list2" $log_file
 It's used to compute average, standard deviation, augment rate, etc,
 and compare two test results (standard format).

 It can be used directly, example:
| # python analyzer.py "result-v1-1.RHS result-v1-2.RHS" \
|   "result-v2-1.RHS result-v2-2.RHS result-v2-3.RHS" log.txt
| Thu Jan  5 10:17:24 2012
|
| == Avg1 SD Augment Rate ==========================
|     TCP_STREAM
|     size|sessions|throughput|   cpu|normalize| ...
|     2048|       2|  14699.17| 31.73|   463.19| ...
| %SD     |     0.0|       0.6|   0.0|      0.8| ...
|     2048|       4|  15935.68| 34.30|   464.66| ...
| %SD     |     0.0|       0.3|   1.7|      1.5| ...
| ...
|
| == AvgS Augment Rate =============================
|     TCP_STREAM
|     size|sessions|throughput|   cpu|normalize| ...
|     2048|       2|   7835.61| 31.66|   247.36| ...
|     2048|       2|   8757.03| 31.94|   274.14| ...
| %       |    +0.0|     +11.8|  +0.9|    +10.8| ...
|     2048|       4|  12000.65| 32.38|   370.62| ...
|     2048|       4|  13641.20| 32.27|   423.29| ...
| %       |    +0.0|     +13.7|  -0.3|    +14.2| ...
|

> perf.conf:
 config test related parameters.

perf regression guide:
https://github.com/autotest/autotest/wiki/KVMAutotest-Networking

Changes from v1:
- refactor analysis code
- add standard deviation percent
- only provide mechanism to user, user can use tools directly or use the lib in scripts

Signed-off-by: Amos Kong <akong@redhat.com>
virt.kvm_vm: Support for bool option in _add_option

Let _add_option know about type of this option. It can verify value
and decide which one it uses. Currently it supports bool type
and default.

Signed-off-by: Lukas Doktor <ldoktor@redhat.com>
virt.virt_vm: Add option to create raw images with dd

Adds option to create raw images with dd (non-sparse file unlike
qemu-img one).

Signed-off-by: Lukas Doktor <ldoktor@redhat.com>
tests.cfg.sample: change import order

Currently subtests.cfg is proceeded and then all other configs. My test
needs to override smp parameter in some variant which is currently
impossible.

Using words current order means: we define subtests variants, than we
specify base and guest and other details. In the end we limit what
we want to execute.

My proposed order enables forcing base/guest params in subtest variants.

By words this means we specify base, guest system, cdkeys, etc. and in
the end we define subtests with various variants. Then we limit what
we actually want to execute but now subtest can force varius base/guest
settings.

Signed-off-by: Lukas Doktor <ldoktor@redhat.com>
tests.cgroup: Rework test execution

Complete rework of cgroup test from subtests to singe-test-execution.
It improves stability of testing and allows better test
customiuations. The speed is similar/faster in single variant
execution and a bit slower in all-variants execution compare to
previous version.

Most tests now supports cgroup_test_time, cgroup_test_limit*
and other cfg params for test tweaking.

Also some enhancements were made:
* blkio_bandwidth - support for multiple speeds
* blkio_throttle - support for multiple VMs
* blkio_throttle_multi - support for multiple VMs
* cpu_cfs_util - per vcpu stats
* cpu_share - support for multiple speeds
* cpuset_cpus - per vcpu stats
* cpuset_cpus_switching - time-driven finish
* devices_access - RW and RO testing and QMP support
* freezer
* memory_limit
* memory_memsw_limit - Newly added
* memory_move

+ a lot of bugfixes.

See descriptions for details.

Signed-off-by: Lukas Doktor <ldoktor@redhat.com>
Fix the virsh_start() return value.

If VM is already alive, we should also return True in virsh_start().

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Adds service_libvirtd_control API to libvirt_vm.py file

This patch adds service_libvirtd_control API to libvirt_vm.py file.

Signed-off-by: Gu Yanhua <guyanhua-fnst@cn.fujitsu.com>
virt.libvirt_vm: Fix toplevel dosctring

As it was really outdated.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
base_utils_unittest - Force use of bash when testing shell scaping

In any box that does not point /bin/sh as /bin/bash, the
unittest tends to fail due to slight differences in behavior
among shell versions. As utils.BgJob automatically selects
bash if it's available in the system, we can reasonably
expect that we won't have trouble. In embedded environments,
it might be a different story, but even then the chances of
utils.sh_escape fail to produce an appropriately escaped string
are low.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
client/kernel: fallback to defconfig if no .config is present

due to `mv' not finding the source file. Rather than relying on .config
being present, fallback to defconfig when its not.

Changes from v1:
  * Fix kernel_unittest.py and add a new unittest for
    testing extraversion with no config.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
client/kernexpand: handle 3.0-style kernel versions

Passing in 3.0 to autotest results in messages about
being unable to parse the major/minor version. This
is because the code assumes a 3-digit verions number.
Additionally, the 'raise' in this chunk of code throws
its own exception due to a raw string parameter.

Fix both by having an alternate function to check
post-2.x version numbers, that will also consider
this new naming schema. It's forward compatible,
for the (potentially) far away 4.x times (well,
assuming that the naming schema will remain the
same).

Changes from v2:
 * Open the urls and after that close them

Changes from v1:
 * Rewrite of the original patch code
 * Addition of unittests
 * Fixed incorrect logic that printed unavailable
   URLs when it shouldn't do that
 * Used urllib2 instead of external programs to
   verify the state of a given URL
 * Fixed docstrings and comments
 * Fixed use of string exceptions

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
client/base: fix cleanup_kernels string manipulation

This code uses the length of a variable, which includes the '/boot'
prefix to trim the length of the kernel name, which in turn does not
have the /boot prefix. So this results in bad kernel version strings --
and when using autotest to build kernels, the default control file
results in all kernels being deleted from the system.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
client/boottool: add default entry in set_default if no default exists

If no 'default' entry is in yaboot.conf (the only type of bootloader I
tested on), then boottool --set-default= will fail to change the default
and reboots will go back to the first listed kernel. Fix this by
determining if we have found a default line and if not, inserting one at
the top of the file.

Changes from v1:
 * Fixed perl syntax error

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>