virt-libvirt: De-duplicate virsh/libvirt_xml bases

The virt networking code in utils_misc and base classes from the virsh
and libvirt_xml modules were duplicating a lot of functionality.  Moved
the comonalities under a new utils_misc PropCanBase base class. Added
new unittests for the new base class and fixed up all usage mismatches.

Also moved Closure class from virsh into utils_misc so it's more
centrally located for common use.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-libvirt: Impliment basic libvirt_xml functionality

Follow a properties and accessor-method pattern so allowing higher
level code to ignore all details of underlying XML format.  Also,
provide intermediate methods for working with XML related virsh
commands along-side the abstracted XML-manupulator classes.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-libvirt: Update vm.uuid on vm.get_uuid()

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-libvirt: Add virsh_define (and undefine) test

Thanks to Yu Mingfei <yumingfei@cn.fujitsu.com> for the original
virsh_rename_domain test which this is based upon. Exercises
virsh define and virsh_undefine plus auto-generated uuids.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: fix libvirt_xml, virsh, utils_misc & friends

+ libvirt_xml:
    + Improved docstring
    + Removed uuid module usage
    + Removed duplicate method definitions
    + Fixed comment spelling mistakes
    + Added os_arch_machine_map property to LibvirtXML

+ utils_misc:
    + Remove unused Closure Class
    + Fixed indentation / spacing
    + Added comments

+ utils_misc unittest:
    + Cleaned up nested class/method definitions
    + Unfolded some complex assignments
    + Fixed indentation / spacing
    + Add some dict-method unittests

+ virsh:
    + Updated/Clarified module docstring
    + Removed unnecessary DaArgMangler class
    + Fixed specialized VirshClosure Class
    + Cleaned up VIRSH_EXEC usage & warning
    + Replaced old use of PROPERTIES with __slots__ (resolved TODO)
    + Enforced setting of 'uri' and 'virsh_exec' properties
    + Made VirshSession class record the uri for later comparison
    + Major VirshPersistant cleanup/bugfix
        + Added session acounting (helps unittests)
        + Added close_session method to unify behavior
        + Fixed new_session to properly close alive existing sessions
        + Fixed set_uri to open new session only on uri change WRT old session
        + Cleaned up virsh.command to work with VirshPersistant properly

+ virsh_unittest:
    + Added back unittest module (some tests ignored if no libvirt)
    + Added 8 tests for VirshClosure
    + Added VirshPersistent session count check to ConstructorsTest
    + Added help command cache tests
    + Added VirshPersistant test teardown double-check session accounting

+ libvirt_vm: Cleaned up hvm/pvm arch and machine-type detection/check

+ guest-os.cfg.sample:
    + Added vm_arch_name param for every OS defaulting uname -m
    + Removed a few guest os types that aren't used anymore

Signed-off-by: Chris Evich <cevich@redhat.com>
Add JeOS minimal guest

After exploring some possibilities, we came up with a
minimal Fedora install, which presents an interesting
compromise between features and disk space. The idea
is to host the compressed image on my FedoraPeople
area and have code to automatically download it if it's
missing, and subsequently cache it.

The unattended install variant is in fact only for
people that, for some weird reason want to rebuild
the minimal guest on a convenient way, nothing more
than that.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Modify run script to take advantage of JeOS

Modify the virt assistant function to:

 1) Download the JeOS image
 2) Setup the environment non interactively

So it all will be done without user intervention.
The first time the JeOS will have to be built,
a couple of minutes to download the 120MB compressed
image + 1 minute to uncompress the image will be
required, after that it'll keep using the uncompressed
image, unless you want to replace it by the pristine
file you have on your hard drive, then you have to call
run with --restore-image.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
jeos: Use 7za rather than 7z

In Fedora, it requires less dependencies.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
utils_misc.virt_test_assistant: Tweaks and reorganization

Now setup log goes to main debug log, setup phase is
displayed as a test. Also, there was a bug on the
uncompress stage in case the image was already
uncompressed, fixed by passing the right flags to 7za.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: Unify and replace /tmp/kvm_autotest_root by /var/tmp/virt_test

There's no reason why all tests can't use a single roof
for their activities, moreover, /var/tmp is a safer place
to store isos and disk images, considering that we might
have /tmp on tmpfs on Fedora 18 on.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
run: Allow to specify an arbitrary qemu version to test

This introduces the flag --qemu-bin, that allows people
to specify an arbitrary qemu built on your box, such as:

./run -t kvm --qemu-bin /home/lmr/Code/virt-test.git/kvm/install_root/bin/qemu-system-x86_64

And this will automatically run the tests with that qemu.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
run: Add a test list option

Add an option --test-list, that has to be used in
conjunction with -t (test_type):

./run -t kvm --list-tests
(display list of tests)

It'll connect the list to a less pipe, if less is
available, similar to what git does. It'll show all
tests available for the JeOS so one of them can be
chosen.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
run: Allow to select a list of tests

Now that run can list the tests available, also allow
to specify a list of tests (space separated):

./run -t kvm --tests boot_with_usb reboot_with_usb

And it'll select and run those.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
run: Fix bug with option -c

With the new functionality to run tests, even when specifying
a custom config file we were applying a 'only migrate' block,
that's very likely to restrict all the tests run by the
specific configuration.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Add a new tests example config file

Since now the default tests.cfg is based on JeOS, we
cleaned up the old file and added more useful examples,
such as sets similar to the ones we run on our automated
KVM regression infrastructure.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
libvirt: Add better support on run

Allow jeos tests to work fine if you choose to run
libvirt tests. The user will have to be educated to
specify unattended_install.import.import if he/she
wants to run tests dependent on guests.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
shared/cfg/subtests.cfg.sample: Remove JeOS from some variants

In some cases, the test variant is irrelevant, in others,
JeOS lacks a toolchain for it to work. So, let's remove
them and leave a more meaningful list of tests for
people interested in JeOS.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
run: Move setup stage to headers

In order to avoid confusion, move setup to the script
initially printed headers, so it can't be mistaken with
a regular test.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
run: Improve reporting on setup error

In case '7za' is missing, we better report to the user
straight away, rather than just failing silently.
Also, we want to avoid as much as possible config
files not in their right places.

In order to accomplish that goal, check for 7za's
presence in the system on virt_test_assistant, and
throw an exception if it's not present. Also,
make sure we catch exceptions when calling
virt_test_assistant, to present error information
in a good way.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
get_started: Make JeOS download optional on script

Chris pointed out it's appropriate to ask whether the
user wants to download the minimal guest image instead
of just going ahead and downloading it. So be polite
and ask first on non interactive setup.

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