virt-libvirt: Fix virsh vcpuinfo test config typo

Signed-off-by: Chris Evich <cevich@redhat.com>
qemu_vm: don't wait 1 second before first check

There's no need to wait 1 second before the first check for
status=paused, just used the default values for th wait_for() 'first'
and 'step' parameters.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu_vm: introduce wait_for_status() method

A helper to wait until VM status changed to specific value.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu_vm: introduce wait_until_paused() method

Just a helper for code that needs to wait until the VM is paused.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu_vm: introduce wait_until_dead() helper

Makes the code that waits until VM is dead simpler.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu_vm: introduce graceful_shutdown() method

This will help isolate the destroy() code that uses the shutdown command
from the rest of the VM-killing code.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu_vm: isolate code that waits for guest shut down

The code is trivial by now, but it will be extended once we start using
-no-shutdown.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu_vm: wait until VM is paused in case -no-shutdown is being used

This should help us in the main use case of the kill_vm_only_when_paused
code: to make the shutdown code wait until the VM is paused instead of
waiting until the VM is killed, when -no-shutdown is used.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu_vm: eliminate kill_vm_only_when_paused option

The option is not necessary anymore, as we have code specific for
-no-shutdown in the graceful-shutdown code path.

Other code that needs to wait until VM is paused outside
graceful_shutdown() may simply call wait_for_shutdown() or
wait_until_paused() directly.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu_vm: Fix mistake in commit 3e911b6

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
qemu_vm: Fixing coding style (docstring and line spacing)

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
qemu_vm: Fix logging for destroy()

Do a better job at logging which VM is being killed,
and which method to kill it was used. Other parts of
the VM classes need cleanup, but let's start with this
method.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
qemu_monitor.py: increase default timeouts

Based on experience and advice we are increasing the default
timeouts. We have seen non intended failures with the timeouts
as they are. Increasing them makes legit tests (migration ones
in our experience) not fail anymore.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
run: Fix error message displayed when -v is not specified

This is a solution for issue #184.

Create the utility function _restore_stdout, so we
don't need to resort to standalone_utils.print_stdout
on error paths, changing all error paths to use it.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: repair step editor.

Signed-off-by: Jiří Župka <jzupka@redhat.com>
qemu_vm: Making qemu creation module honor cpu_model unconditionally

When we introduced qemu CPU model configuration, we opted
for robustness, so we wouldn't add a cpu_model to the
command line in case it was not showing on qemu -cpu help
text. This is bad because:

1) It was all done very silently
2) This makes negative cpu model testing unfeasible

So let's honor the setting, and print a error message,
so people have a better idea of what's going on. In
such cases, the bad param will be passed to qemu, it
will fail and a VMCreateError will be thrown.

CC: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
qemu_vm: Update testdev option, add -isa-debug-exit option

For qemu upstream, in order to run the kvm-unit-tests suite,
there are new test devices, that differ in syntax from the
ones present in qemu-kvm:

* pc-testdev
* isa-debug-exit

Add them both to the qemu VM class, and make things
backwards compatible (ie, if an older qemu-kvm is being
tested, it'll handle the correct syntaxes as well).

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
qemu: unittests - Handle running on qemu upstream new testdevs

The implementation of the devices needed for KVM unit
testing changed a bit on qemu:

1) There's no need for a testlog anymore (as kvm-unit-tests
   now writes to the standard serial port)
2) Now there's a shared new device, called isa-debug-exit,
   that when written to, causes qemu to exit
3) Due to the new behavior of the isa-debug-exit device,
   the new known good behavior for qemu at the end of the
   unit test is to return 1.

Take that all into account, while still keeping backwards
compatibility. Also, document how one can run the unittests
with the new virt-tests runner both in the config file
and the wiki.

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