server.autoserv: Use test_output_dir if available for storing results

This is a solution to issue #501 - on a system wide install,
running autotest-remote will try to create a results dir on
a non readable python library area:

$ autotest-remote a
DEBUG:root:unable to import site symbol '_SiteRun', using non-site
implementation
Traceback (most recent call last):
File "/bin/autotest-remote", line 17, in
autoserv.main()
File "/usr/lib/python2.7/site-packages/autotest/server/autoserv.py",
line 193, in main
os.makedirs(results)
File "/usr/lib64/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied:
'/usr/share/autotest/results.2012-08-08-08.54.09'

Use the COMMON.test_output_dir setting on global_config.ini
if available, then fall back to use the cwd to generate the
directory if not available (local install).

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
scheduler.drone_utility: Use test_output_dir for drone tmpdir

This is a solution to #502 - on a system wide install,
drone_utility will try to create a temporary directory
on a non readable python library area:

Aug 08 09:18:14 localhost autotest-scheduler-watcher[1491]: File
"/usr/lib/python2.7/site-packages/autotest/scheduler/drone_utility.py",
line 66, in initialize
Aug 08 09:18:14 localhost autotest-scheduler-watcher[1491]:
self._ensure_directory_exists(temporary_directory)
Aug 08 09:18:14 localhost autotest-scheduler-watcher[1491]: File
"/usr/lib/python2.7/site-packages/autotest/scheduler/drone_utility.py",
line 211, in _ensure_directory_exists
Aug 08 09:18:14 localhost autotest-scheduler-watcher[1491]:
os.makedirs(path)
Aug 08 09:18:14 localhost autotest-scheduler-watcher[1491]: File
"/usr/lib64/python2.7/os.py", line 150, in makedirs
Aug 08 09:18:14 localhost autotest-scheduler-watcher[1491]:
makedirs(head, mode)
Aug 08 09:18:14 localhost autotest-scheduler-watcher[1491]: File
"/usr/lib64/python2.7/os.py", line 157, in makedirs
Aug 08 09:18:14 localhost autotest-scheduler-watcher[1491]: mkdir(name,
mode)
Aug 08 09:18:14 localhost autotest-scheduler-watcher[1491]: OSError:
[Errno 13] Permission denied:
'/usr/lib/python2.7/site-packages/autotest/results'

Use the COMMON.test_output_dir setting on global_config.ini
if available to fix this.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
update epel6 release version

Repo version was advanced recently. Update installation script.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
tests.linus_stress:Copy the *.c file to src dir

Currently, the linus_stress try to copy the source code file
to bindir/src, while it will make the tests dir "none read only".
To copy the file to srcdir to make it work correctly.

Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
virt: Support multi type in kvm test

This patch is useful if we want use existing script to combinate new test case.
We have migrate test script and s4 test script. After this patch it is
easy for us to get s4 after migration or migration after s4 by updating
configure.

Changes from v1:
Fix bug introduced in code merge. Test patch in local.

Signed-off-by: Feng Yang <fyang@redhat.com>
base_utils.py: Add verbose parameter to utils.system to control log cmd or not

This patch add verbose parameter to utils.system and utils.system_output
to control log cmd to debug or not.

Signed-off-by: Feng Yang <fyang@redhat.com>
virt: virt_test_utils.py: Get guest test results from host directly

After guest's autotest finish, the results directory is copied to
host by get_results() function, so no need to get guest's test status
from guest again.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
Acked-by: Yiqiao Pu <ypu@redhat.com>
Signed-off-by: Feng Yang <fyang@redhat.com>
KVM-test: Clean up the tmp files in autotest

Clean up the tmp files in autotest before run a test. Some tmp
files are too large which will make the test failed with no space
left in guest just like iozone test running several times in guest.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
Acked-by: Amos Kong <akong@redhat.com>
Acked-by: Xiaoqing Wei <xwei@redhat.com>
virt_test_utils.py: Add function for restart guest network

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
Signed-off-by: Feng Yang <fyang@redhat.com>
KVM-test: Update flood ping command in ping for multi_nic

Ctrl-C will kill the serial process and always failed the test with
a "Process terminated" warning. So update the flood ping command
to make it return when timeout to ignore to trigger the Ctrl-C.

change from v1:
  - Update the ping command.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
Acked-by: Qingtang Zhou <qzhou@redhat.com>
Signed-off-by: Feng Yang <fyang@redhat.com>
virt: Add one method in get_node_cpus to check cpus for Numa node

In some old version of numactl(0.9.8), the output of the command
"numactl --hardware" will not include the cpus info. So add one
method to get cpus from sysfs when the numactl failed to get it.

canges from v1:
  - try/except add to catch the exceptions
  - comments add and variable name update

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
virt: Add a new module for qemu agents

Now this module mainly contains the QemuAgent class, which
is a wrapper for qemu guest agent.
More detail about qemu guest agent:
 http://wiki.qemu.org/Features/QAPI/GuestAgent

Qemu guest agent provides access to a system-level agent
via standard QMP commands. The host communicate with guest
over virtio-serial or isa-serial device. And guest uses
'/dev/virtio-ports/org.qemu.guest_agent.0' device to send/
receive data from host.

The QemuAgent class needs 2 arguments when initiation.
 * name - Guest agent name, by default in qemu it's
          "org.qemu.guest_agent.0"
 * filename - guest agent socket file path.

This class contains some simple interface now:
 * cmd() - A low-level which can build QMP format cmd string
           and send to guest agent.
 * verify_responsive() - Make sure the guest agent is
           responsive by sending a command.
 * shutdown() - Shutdown guest via guest agent.

Changes from v2:
 - Rename GuestAgent to QemuAgent

Changes from v1:
 - Update GuestAgent init function and docstring.
 - Update supported cmd list generation/checking functions.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt.cfg: Change the fail_test order in subtests.cfg file

We use shutdown test as the mark of ending of config
file, but remove_guest test need to be the last one,
so change the mark to this new case.
KVM Test: Add qemu guest agent test

This test installs qemu guest agent package in guest and
verify it work in guest.

Because there is no pre-build guest agent binary for windows
guest (qemu-ga.exe), just limit this test on Fedora guests.

Changes from v2:
 - Rename GuestAgent to QemuAgent.

Changes from v1:
 - Use new GuestAgent interface arguments.
 - Put guest agent name in config file.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
tests.isic: Remove whitespace to fix configure problem

Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
virt.kvm_vm: Inform spice client of impending migration

A spice client can be informed of a migration, so it
connects to the new vm automatically, keeping the
client connection alive during any number of migrations,
through a monitor command.

This patch implements calling the appropriate command
(there are 3 different valid commands for RHEL userspace,
older upstream and current upstream qemu), for both
human monitor and qmp. This way it'll be possible to
create a test for spice seamless migration test (issue #158).

Spice team, please take a look at this and provide feedback.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: virtio-blk-pci and RHEL 5

Checking if qemu-kvm has the '-device' command line option seems to
safe and accurate enough to generate correct syntaxes on both RHEL 5
and latest upstream.

This is better documented on github issue #504.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
virt: fix documentation about caching types and add other options

The current version of the inline documentation about caching
swapped names and definitions of writethrough and writeback. Also
add other (somewhat) recent cache options available on latest
qemu.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
virt: Record qemu_command line as an attribute of kvm vm

Make this change to fit some cases need to record or compare the
qemu command.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
virt: Add commented virtio_port options to base.cfg

This patch adds example of virtio_ports usage. All lines are
commented out so no actual changes.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>