virttest.qemu_devices: Add support for USB controllers

this patch adds support to create USB controllers using qemu_devices.
This version supports all current options including usb-hubs plus
adds couple of new options.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_vm: Use qemu_devices to handle usbs

Use qemu_devices to create usb controllers and usb devices.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_devices: Add none_or_int wrapper

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_devices: Add support for disk devices and use it in qemu_vm

This patch changes the way of handling images, cdroms and floppies
params. Instead of custom handling in make_create_command it uses
wrappers in self.devices. It keeps track of all image buses according
to autotest.

It shouldn't change the way how autotest used to create disks. Anyway
few params which were omited for some devices were added. Also all
buses are tracked so in case there is no free bus it should create one.

This feature works 100% with strict_mode. For non-strict_mode there
might be few differences as qemu doesn't differentiate between ide and
ahci buses. Handling of this would require deeper modifications to
the way of images handling and will be discussed and resolved later.

Images should be added with the correct version of device thus we should
be able to unplug/hotplug the device in test.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_devices: Fix cdrom params

Original autotest ignored some params.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
Fixup: Param removable works only for scsi or usb disks

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.env_process: Don't update params of an unused living VM

Currently during vm_preprocess params of unused running VMs are updated,
but VM is not recreated (it's not used, so there is no need for it).
If we create VM in 1st test, in 2nd test we use different params but set
start_vm = no, params are updated so when we use the same params from
2nd test in 3rd test, preprocess would match the VM from 1st test as
the params were updated. Anyway as the VM is not recreated, the running
VM doesn't represents the params from 2nd test.

With my modification the preprocess would always handle VM properly. The
only problem might be, when someone uses vm.create() directly without
preprocess in the 2nd test. Anyway it's a bad practise and I haven't found
it in upstream tests. We always use preprocess to prepare the VM.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_devices: Fix DevContainer.remove() issues

Fix issues of DevContainer.remove() and add support for
non-recursive removal.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_devices: Add calls to handle QBaseDevice.child_bus

To simplify and unify usage of QBaseDevice.child_bus I added
add/rm_child_bus functions.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_devices: Hotplug/unplug support

This patch adds the possibility to safely hotplug/unplug devices from
running VM.

Additionally it adds another VM state and VM param. When the test
requires clean VM, you might specify "allow_hotplugged_vm = no" and
when VM used hotplug it will be recreated.

For hotplugging you might specify monitor, which should be used and
whether to verify results. This is not supported by all devices, but
when there is a method to automatically verify hotplug results, it'll
do it for you and cleans the qdev state for you. Otherwise it's upto the
user to do it by qdev.hotplug_verified().

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_devices: Add support for hotpluggable drives

Add support for QDrive, which supports drive_add (QHPDrive) or
__com.redhat_drive_add (QRHDrive).

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_devices: Fix error messages of DevContainer.insert

Error reason was shown only in force insertion mode.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_devices: Set bus/addr when force insertion device

When we force insert device into bus where it doesn't belongs to
we should probably set bus and addr as it's not the default behavior.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_devices: Skip 'driver=' string in devices

Libvirt doesn't use the full cmdline, but only -device $driver,$params
format. This patch makes autotest follow this syntax too.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
shared.cfg.machines: Disallow 'ide' usage on q35

q35 doesn't have ide bus. People should use ahci instead.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.qemu_vm: Remove unused functions add_drive and add_cdrom

add_drive and add_cdrom are obsoleted by
virttest.qemu_devices.images_define_by_variables()

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

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
qemu.tests.physical_resources_check: Use qemu_qtree to verify images

Replace the method which used only disk names to match autotest
image format with virttest.qemu_qtree one. It additionally verifies
all kind of other params of "info qtree" and "info block".

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