tests.virtio_console: reorganize cfg

In order to be able to run all virtio smoke tests easily I added
virtio_console_smoke variant with all related subtest inside.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
qemu.virtio_console: Add negative boot test with too much ports

Set more than allowed number of ports per virtio-serial-pci.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
qemu.tests.virtio_console: Add interrupted_transfer.suspend test

This patch adds interrupted_transfer suspend variant. This variant
initiates loopback over 2 vio ports and suspends the VM to mem.
After a while it resumes the VM with 'system_wakeup' and verifies
that the data are still transfered in booth directions.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
qemu.tests.virtio_console: Fix loopback test freeze

Loopback test might freeze the whole autotest when sender thread
fills the buffer. During cleanup it tries to send additional data
which is blocked due of full buffer. The only solution I found is
to destroy the VM and inform about this bug.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.aexpect: Add read_until_any_line_matches() function

This function is similar to read_until_last_line_matches() function
but it search all lines, not just the last ones. It's useful for
example in virtio_console test where additional output might occur
before it's analyzed with the last_line reader.

The match function is prioritizing the patterns so first it searches
the output for the last pattern, than for the -2 so when there
is PASS and FAIL in the output and patterns = (PASS, FAIL) it matches
the FAIL first, even thought PASS is first in the output.

Separate lines are matched so it's recommended to use '^' at patterns
beginning. ('^PASS', '^FAIL') in order to match the beginning of the
line.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_virtio_port: Use read_until_any_line_matches()

Use read_until_any_line_matches as another thread might write
some debug info right after the PASS/FAIL statement. Than
the test fails even thought it should PASS. There are still
some problems with non-thread-safe-print, the most important
are solved with sys.stdout.write(...\n).

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_virtio_port: Fortify GuestWorker against freezes

Require exact PASS statement for some commands as another PASS/FAIL
line might be matched instead.

Also add some workarounds for stucked ports/python by killing the
worker.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_virtio_port: Fortify Send/RecvCheck threads

ThSendCheck and ThRecvCheck might fail or freeze when they use
closed port.

This is a preparation for interrupted_loopback.disconnect test
where the ports are closed while transfering data.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
scripts.virtio_console_guest: Support for port reconnection

When the port is closed, it's completelly removed from the list
of descriptors. When it's opened, the file descriptor might differs
from the original one. Thus it's necessarily to keep the paths
of the used ports in the Switch thread and in case of reconnection
find the new file descriptor.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
tests.virtio_console: Add interrupted_transfer.disconnect subtest

This test closes the used ports while transfering data and after the
intr_time opens them again. It randomly closes ports on guest side
and host side, send threads and recv threads thus in the long run
it should cover all cases.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
qemu.tests.virtio_console: Fix sigio test crashes

When guest script is already running and the test only connects, every
signal destroys the daemon. This is complex problem of python, where
only the main thread accepts the signals. In order to fix this without
much pain I added test_delete_guest_script() at the test beginning thus
fresh instance of guest script is always executed. This solution seems
to work pretty well.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
qemu.tests.virtio_console: Exit background threads on test failure

Force exit background threads on thest failure.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.env_process: Quit screendump thread when exit_event is None

Sometimes exit_event can be deleted before screendump thread
finishes. Than it hungs in system forever and autotest never
exits.

This problem was spotted after test:
    virtio_console.spread_2.incorrect_options.boot_nr0
where the screendump thread never finished and additional was spawned
at the beggining of the next thread. This caused autotest hang in the and
as only single screendump thread can exit (due of nature of exit fce).

Additionaly set the screendump thread name for future analysis.

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