autotest/virt-test — pull request #188 by ldoktor (2013-01-31 20:45:30+00:00)
Title: RFC: Object representation of Qemu devices

This is a proof-of-concept of object representation of Qemu devices.

I left the original code there to coexist with the new code. The parts which are covered
with devices representation also prints-out the lines with "N: " prefix. The original code
doesn't affect the qemu_cmd and is only printed-out with prefix "O: " in order to be able
to compare the differences.

Before the end of make_create_command() the all bus representation is printed out.

**GOALS:**
* create representation of all devices from params
* be able to convert between params - object representation - qemu-cmd - qemu-readconfig
- qtree in order to create the VM, verify correctness
* be able to compare 2 object representations instead of qemu commands (hotplug, drive
changes, drive eject)
* be able to insert devices in test (hotplug/unplug support)
* complete bus representation (eg. PCI), be able to assign fixed addresses or compare that
addresses are assigned in the defined manner
* Actual VM representation even when VM is dead and we are unable to access monitor

**ABOUT:**
qemu_devices.py contains **wrappers**, **devices**, **buses** and **container**.
**wrappers** are sets of functions for handling complex subsystems (usb, image)
**devices** are objects, which represents individual qemu devices of various kinds
**buses** are objects, which simulates qemu bus objects and are used inside devices
in the same fashion as in qemu itself (parent, child).
**container** is main devices object, which represents the VM device structure. It stores
all inserted devices and all theirs buses. It could simulate device plug, unplug, the
consequences and when it expects failure on qemu side it throws it. This way
we can compare the actual and expected results.

**TESTED:**
I tested the `all unattended_installs` (multiple cdroms, floppy disk) with `virtio_blk` and `multi_disk` tests (with some failures, but the failures happens on upstream version too, multi_disk.all_drive_format_types works fine) and `floppy_test`.

**INTENTION:**
Please focus on the idea and the general implementation. There are lots of nasty hacks, which I will fix, if you accept the idea. I don't want to spend months on something, which you then reject as complete nonsense.