virt: Adds multi_host_migration early boot tests.

Signed-off-by: Jiří Župka <jzupka@redhat.com>
tools: Add tapfd_helper tool

Move this tapfd_helper tool from autotest repo into
this virt-test repo, since it's a virt-test only tool.

This script can help us boot up guest with autotest
generated qemu command line, it creates tap device
and updates the tapfd in given qemu cli.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt: Adds support for cancel migration in multi-host tests.

1) Start migration with stressed VM.
2) Wait cancel_delay and then cancel migration.
3) Check if machine is alive on source host.
4) Stop stress of VM.
5) Migrate machine again.
6) Check if machine is alive on destination host.

Signed-off-by: Jiří Župka <jzupka@redhat.com>
kvm.virtio_console: FIX delete_guest_script must kill python

On linux guest the guest_worker runs as a daemon so we have to
also kill the worker and remove it's pipes. Otherwise the new
instance would only connect to the old running version.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.kvm_vm: FIX docstrings for add_virtio_port()

Add missing docstrings.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.kvm_vm: Add support for virtio_port extra_params

This allows to specify extra params of virtio_ports using
virtio_port_params_$name = "$param1 $param_2 ...".

Whitespaces are stripped and replaced with ','.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
kvm.virtio_console: Add new test failed_boot

This patch adds new test failed_boot. It tries to create VM
and checks the error message.

As an example boot_nr0 test is added to cfg. It tries to create
VM with virtio port number = 0 (nr=0) which should fail due
to backward compatibility issue.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest: Store qemu_id in VirtioPort

This patch stores the qemu_id to each VirtioPort. This is crucial
for virtio_console hotplug tests.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
kvm.virtio_console: Make all subtests context_aware

This patch makes all virtio_console subtests contest_aware. This should
help debugging failures in subtests called from another subtest's body.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
kvm.virtio_console: Add reboot virtio_console subtest

This patch adds 2 variants of reboot test.
1) stressed - stresses all ports and gently reboots VM (supersede the
              poweroff test)
2) unplugged_ports - unplugs all ports and gently reboots VM

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
shared.cfg: Move guest_s4 OS dependend setup to guest-os.cfg.sample

These settings were by default in subtests.cfg and windows version
overwrote this in guest-os.cfg. I'd like to move them to guest-os.cfg
for booth versions thus the'll be on the same place and it's gonna
be possible to get them in other tests too.

I put a comment to subtests.cfg about required variables.

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

_init_guest() doesn't execute the worker. We have to do that manualy
before calling self._init_guest()

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

The main loop of ThSendCheck worked incorrectly in case of port
reconnection. It could end-up with infinite number of reconnection
although only 10 was allowed. This patch makes ThSendCheck work
as it should.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.kvm_virtio_port: New features for GuestWorker

This patch adds new features to GuestWorker:
* read_nonblocking - read-out the output of guest script (used when
                     the test fails and we want to see the output)
* ThSendCheck - adds reduced_set option (use only A-Z, simplifies debuging
* ThRecvCheck - adds debug mode. This mode executes completely different
                loop. It's better for debuging purposes. Not all
                functionalities are kept so you should know when you want
                to use it.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
shared.scripts.virtio_console_guest: Adds new loopback mode

This patch adds _reconnect_none_mode version of the loopback thread.
It works as ordinary none_mode, but additionally disconnects in case
the port is unreadable and reconnects when possible.

It was necessarily to make virt global variable to be able to access
it in this thread.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
kvm.virtio_console: Add interrupted loopback test

This test starts loopback between first 2 ports and do the interruption.
Than it verifies, whether new data still arrives and the loss/dup is
in the allowed range. Multiple interruption loops are supported.

Variants:
* stop and cont
* port replug (sender, receiver, random)
* hibernate (S4)

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
shared.cfg: Modify virtio_console loopback test setting

This setting suits the current version of virtio_console loopback
test.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.kvm_vm: FIX virtio_ports bus handling

The bus handling in virtio_ports is broken. This patch modifies
it to realy work as described:
1) manual port definition
2) virtio_port_spread
3) without definition (but create the first bus)

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

Console version of test_rw_notconnect_guest used the second vio port,
but should use the first one instead. Test might fail in case VM
was recreated by the test.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
kvm.virtio_console: FIX Exceptions don't accept *args

Don't pass *args to Exceptions, use '%' instead.

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