run: qemu - Add support to enable vhost

Make it more convenient to enable vhost=on or vhostforce=on
using the test runner. As of now, bridge access still
requires root, so you'd need to run things as root:

sudo ./run -t qemu --nettype bridge --vhost on

or

sudo ./run -t qemu --nettype bridge --vhost force

CC: Richa Marwha <rmarwah@us.ibm.com>
CC: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: Cartesian config bug repair.

https://github.com/autotest/virt-test/issues/199

There was too aggressive branch config filtering for achieving
better performance.

Before:
  1) config branch not produce any dict.
  2) save filters which block this branch.
  3) if **one** of filter will be in content next time
     then don't use this branch again.
  =>) wrong filtering

Now:
  1) config branch not produce any dict.
  2) save filters which block this branch.
  3) if **all** of filter will be in content next time
     then don't use this branch again.
  4) else check branch again for new dicts.

Signed-off-by: Jiří Župka <jzupka@redhat.com>
virt: Cartesian config speed and memory optimization.

Memory:
  It uses __slots__  instead of dict in class.
Speed:
  Replaces in most of cases very slow operation Template.substitute
  by faster version.
  These changes reduce time for big config file by 1/4 of time.

Signed-off-by: Jiří Župka <jzupka@redhat.com>
run: --no flag is actually a general flag

There is nothing specific to qemu in the --no flag,
but it was on the qemu group. Let's move it to
the general group.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
qemu/cfg/tests.cfg - Exclude multi host tests

Multi host tests can't be executed on the standalone
runner, so we've got to filter them out. This way
we'll have a lot less results displayed when listing
tests for, say, Fedora.18.x86_64, but the list will
be more accurate.

CC: Jiri Zupka <jzupka@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
netperf: introduce an agent to launch client sessions

Currently we use many threads/heavy control sessions to launch many
clients, Autotest takes too much of the host resources.

This patch introduces an agent script, it'll be executed inside the
client system to launch multiple sessions, and Autotest only needs
to use one background thread to control clients.

We can consider to process the raw results in this agent script in
future, if it can help to simplify the case.

Signed-off-by: Amos Kong <akong@redhat.com>
utils_misc: Add a function to normalize the data size

Normalize a data size in one order of magnitude to another (MB to GB,
for example). In this function you can also change the factor as you
need, the default factor is 1024.

changes from v1:
  - rename the function and variables
  - update the method for getting a fraction.
  - Add unittests

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
qemu/cfg/tests-example.cfg: Update examples to use current Fedora

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virttest.qemu_vm: Add a new list for supported devices

Other test scripts can use this list directly to check
whether some device is supported by qemu binary.

This patch also moves 'has_device' function in
'make_create_command' method into VM class, so that we
can use this method out of VM class scope.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
Qemu Test: pci_hotplug: Update this test case

This patch creates a series of sub functions for device add
action in different version of qemu.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virttest.qemu_monitor: Add APIs for device hotplug/unplug

This patch adds interfaces for hotplug operation:
 * device_add/device_del: For qemu which has '-device' option.
 * pci_add/pci_del: For some old version of qemu.
 * drive_add/drive_del: For newer qemu which supports drive_add.
 * com_redhat_drive_add/com_redhat_drive_del: For RHEL only.

With these interfaces, test cases writer doesn't need to care
about the verison of qemu.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virttest.qemu_monitor: Verify hmp cmd in qmp as well

Some QMP's interface will fallback to HMP if there is no
match QMP command, this patch checks HMP before calling
HMP cmd in QMP, to avoid some unexpected failure.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virttest.qemu_vm: Add APIs for pci hotplug

This patch brings some interfaces for hotplug in qemu_vm
module, so that user doesn't need to care about monitor
protocol and qemu version.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
Qemu Test: pci_hotplug: Update this test with new interface

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
tests.pci_hotplug: FIX function name - is_supported_device()

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
qemu_vm: Log the original traceback when VM.create() failes

* when self.make_create_command() raises an exception in VM.create()
  it's catched and reraised. The problem is that the information about
  actual failed line is lost. This patch logs the original traceback
  and raise VMStartError instead.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
Object representation of qemu devices

This is a first part of new way for creating VM. When it's complete
it should create device representation which allows deeper analysis
of current VM state including additionally hotplugged devices.

Current implementation only takes care of usb buses, usb devices and
block devices (disk, cdrom, floppy) and uses the old way of VM handling.
Each added device only extends the old qemu_cmd variable.

For correct PCI address assignement it inserts dummy string devices for
many devices, which are not yet covered by new classes. They don't
affect the qemu_cmd.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
FIX: use weakrefs on qdev object

Those references prevented garbage collector from removing qdev
object, which resulted in hanging VM and lots of nasty related
hangs.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_vm: Use only qdev for VM creation

This patch removes the old way of device definition. This way we
can't compare the outputs, but we get closer to the speed of which
qdev will work in reality.

It still generates huge output of all devices and buses. It's
there for you to compare, whether the theoretical information
match the actual VM. In the future this might be compared
automatically (similar to qemu_qtree.py but for every device).

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

Conflicts:
	virttest/qemu_vm.py
virttest.qemu_devices: Add support for compasion

Support qdev comparsion using qdev1 == qdev2 and qdev1 != qdev2.

It uses cmdline, hotplug, unplug and readconfig outputs of all devices
and compares the results. It doesn't require the same names, only same
commands.

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