virt-libvirt: Fix debug log message typo.

* Bug introduced in 8f464022f845e958c4777f943384179b66428eec
* Fix 'name' -> 'xml_path'

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-libvirt: configuration of virsh managedsave

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
virt-libvirt: add test of virsh managedsave

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
run: Print more info in --list-tests

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
cartesian_config: Fix use of reserved keywords and unused variables

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
kvm_virtio_port: Do not readout ports when VM is dead

When VM dies it closes connection to sockets. We might (and often)
stuck in readout for ever.

Additionally get rid of in-test readouts which are handeled by
guest_worker's safe_exit_loopback_threads()

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virtio_console: Check periodically for failures in loopback test

Don't wait until the test timeout, but fail the test when thread
or VM fails.

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

The data dir library is useful to avoid recalculating
over and over again commonly used locations of this test
suite. This time, let's introduce get_root_dir, that
returns the top level dir of the test suite.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
utils_misc.Env: Create a method to destroy the env file

Make it possible to destroy all vms, and close other
processes stored in the env file. This way we can do some
safe cleanup before we run virt tests.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
standalone_test: Destroy the previous env file before run

This is a complement solution for issue #122.

Before running the tests, clean up all objects lying around
in the env file. This is safer and avoids errors that happen
here and there, and are hard to understand for people not
familiar with the virt tests structure.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt.kvm_vm: Introduce background error queue

Introduce a background error queue to store exceptions
happened during virt background tasks (such as aexpect
instances and screendump thread). With this queue,
it is possible to store exception information useful
to fail tests at certain points. Examples:

* We can detect qemu suffered a crash from inside the
  aexpect thread
* We can detect screen inactivity on the screendump
  thread and fail the unattended install test without
  having to wait the entire timeout of the test

The next patches will introduce that functionality.

Implementation consists in a virt test attribute,
background_error test, that is a Queue.Queue()
(thread safe), background threads that want to
make use of it need to catch the exception they
want to propagate and store it in the queue
using put(sys.exc_info).

Then in every convenient situation to do so, subtests
can call the test.verify_bg_errors() method
(in the beginning or end of each test loop, where
operations such as migrations are executed).

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt.virt_env_process: fail tests due to guest screen inactivity

In a very specific test (unattended_install), all OEM installer
mechanism will present intense guest screen activity, so screen
inactivity for a relatively long time almost always mean something
went very wrong and the installer is stuck.

So create a mechanism to detect screen inactivity for any vm that
takes place in the test - have a timer for each vm that is reset
only if the next screenshot is different than the previous. So,
if the vm got stuck somewhere at the install process, for example:

* Wrong Windows CD Key
* Guest OS does not see a disk controller due to lack of drivers
* BIOS got stuck

And other similar cases, we'll have a test failure before the full
test timeout (that for Windows may be up to 3 hours). So we save
time and know about such situations earlier.

Next patch introduces the parameters on base.cfg, subtests.cfg, and
also introduces a sensible default for inactivity treshold (30 min).

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt tests: Introduce inactivity watcher for unattended_install

With this patch, if the screen got inactive during unattended
install for more than 30 minutes, an error will be thrown. For
any other tests, we'll just log a debug message, since in other
tests we do not expect to see much action going on the screen.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
kvm_vm: Reorganize imports

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Introduce vm.verify_userspace_crash()

In order to capture any qemu crashes, introduce a method
that scans qemu output and throws an error if a core dump
condition is found.

Improve verify_alive() by calling this function, among
others, and add a check on two of the most called functions
of the framework: vm.wait_for_login() and
vm.wait_for_serial_login().

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: xml_utils fixes

    * Fixed missing __super__ calls in subclasses
    * Fixed XMLTreeFile __str__ bug
    * Fixed TempXMLFile unlink bug
    * Fixed corrupt-XML exception handling
    * Added unittest for __str__ method

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: virsh module and unittest fixes

* Virsh:
    * Fixed imports
    * Fixed VirshSession error-detection bug
    * Fixed VirshPersistent double-new_session bug
    * Fixed automatic __del__ / out-of-scope bug
    * Fixed double close_session exception bug
    * Cleaned up all logging calls for pylint's sake
    * Fixed up some API docstrings
    * Fixed parameter name clash (rename domname -> vm_name)

* Virsh unittest:
    * Fixed utils.process_is_alive logging annoyance
    * Added session-recycle test
    * Enhanced lingering virsh-process checks
    * Stopped printing of DEBUG messages during testing

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-libvirt: libvirt_xml fixes/enhancements

* Cleaned up module docstring
* Fixed LibvirtXMLError bug
* Simplified initialization and virsh use (internal and external)
* Made __readonly__ method easier to use in subclasses
* LibvirtXMLBase.copy() bugfixes
* Made VMXML.new_from_dumpxml() into static method to wrap __new__
* Cleaned up some overly short variable names

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-libvirt: Test cleanup

* Fixed a bunch of pylint complaints
* Fixed bug in virsh_restore
* Updated virsh_define to change in libvirt_xml constructors

Signed-off-by: Chris Evich <cevich@redhat.com>
openvswitch: Remove unneeded import