libvirt.test: Add 'mode' test(agent) for virsh reboot

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
virsh.list: When setting title, add proper option to virsh.desc

Commit id '58fd81a8' added the --title testing for virsh.list; however,
the add of the title was done to the --config and for a running domain
that didn't have expected results. Adjust the add of the title to be
based on the expected state of the domain.

Signed-off-by: John Ferlan <jferlan@redhat.com>
update_device: Add changes from prior to split

When tp-libvirt was split from virt-test, all PR's were closed - this
PR is adding back the changes made by myself and cevich from PR #1171.

Adjust the test to use the newer --live option rather than --persistent.

Also fix issue with shut_off_option testing.  When a guest is off, the
failure should only be if someone passed the --live flag.  Add the
shut_off_option testing to the normal_test list and use the diff_file
check to ensure that a shutdown guest would be updated.  The --live
option processing should only affect the running guest and not the
configuration after shutdown

Signed-off-by: John Ferlan <jferlan@redhat.com>
update_device: version-specific behavior

* Added --persistent and --config version-specific behavior checks.
* Updated test to use disk device XML class.
* Re-worked result checking logic to be easier to read

jferlan added cevich's change plus the suggested disk.xmltreefile.write()
call from code review

Signed-off-by: John Ferlan <jferlan@redhat.com>
update_device: Fixes to get things to work

Adjust prior set of changes to make things work.

1. Add a cdrom device to guest
   Not sure if somewhere along the way when the code was first developed
   if the cdrom was part of the guest or not or if some previous test just
   happened to leave one around... In any case, the current code doesn't
   have one for the guest - so I added code to add one

2. Adjust create_attach_xml
   Rather than rely on hardcoded device and bus, pass it along.  Some one
   in the future can do the work to make them more configurable to have
   virtio instead of ide, but for now go with the ide bus & hde device

3. Adjust is_attached
   Pass the device name and fix the indention on the return True; otherwise,
   it was never hit.

4. libvirt_library_version
   Remove the code from here - I actually moved this version of how to parse
   the 'virsh version' output into the provider code (see PR #82). Thus this
   code also makes use of that new code.

5. Moved the state/setup closer to where it's used

6. Modified the flag_list setup code - I found that doing a flag.split("--")
   of an empty flag list (eg. "".split("--")) returned [''] instead of [],
   so I adjusted the logic slightly to account for that.

7. Create the cdrom device in order for it to be updated.  Initial device
   will be "orig.iso" and it'll be changed to "test.iso" or "test_diff.iso".

8. Fix the "diff_iso" logic - it's a boolean not a value

9. Fix the 'inactive_attached' logic to look at the inactive_device

Signed-off-by: John Ferlan <jferlan@redhat.com>
libvirt.test: Add mode(agent) test for shutdown

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
schedinfo_qemu_posix: Resolve pep8/inspekt fixes

When running inspekt on my branches this was flagged.
domiftune: Adjust max value

Turns out this test made an assumption that the value being passed to
libvirt for the 'domiftune' as the maximum was in bytes per second rather
than the libvirt expected kilobytes per second.

The reality is, libvirt's documentation wasn't very clear so that has
been fixed. Furthermore, there was a bug in the /sbin/tc code which was
fixed that resulted in libvirt actually failing (correctly) when such a
large and incorrect value was passed. For details read the upstream commit:

http://www.redhat.com/archives/libvir-list/2014-February/msg00904.html

NOTE:
It's now not even possible to get the "maximum" bytes per second passed,
but we can come close (within 295 bytes) by passing a kilobytes value.

Signed-off-by: John Ferlan <jferlan@redhat.com>
provider: Add libvirt_version

Add a new provider directory to serve as an area to put common functions
and functionality needed for tp-libvirt specific tests.

Add a libvirt_version.py which has a function designed to compare a
specific upstream libvirt version against the running libvirt library
version on the system. This will allow tests that may have different
output or functionality allowed based on which libvirt version is running
on the host to perform or generate output expected for the specific version

Code is based on cevich@redhat.com's libvirt_library_version() logic
taken from a yet unreworked/remerged PR #1171 from virt-test. I massaged
the logic a bit in order to fit the model libvirt uses to take the major
version * 1000000 + the minor version * 1000 + the update in order to
fabricate a version which is easy to compare.

Signed-off-by: John Ferlan <jferlan@redhat.com>
virsh.domdisplay: Only add port if nonzero for vnc

A change made in libvirt 1.1.3 in commit id '9976c4b9' will only print
the port id if it's non zero.

Adjust the code to compare different results depending upon whether it
can ascertain if at least libvirt 1.1.3 is installed.

Signed-off-by: John Ferlan <jferlan@redhat.com>
domiftune: Update test to handle clearing inbound/outbound

In libvirt 1.2.3, commit id '14973382' it will now be possible to pass
a zero (0) as an inbound or outbound parameter to domiftune in order to
clear all the settings found.

Thus, modify the cfg to move the setting of input/output to zero from
negative to positive testing.  Also set a marker that will allow the
test code to handle the attempted clear.

Since previously 0 was considered an error, the code was modified to
check the libvirt version and handle the results based upon the version.
Prior to libvirt 1.2.3, a zero in a positive test would cause a failure,
but since it's known that way just adjust the expected results.

For the new code, we'll set the variables average, peak, and burst to
values and then pass the zero along to ensure that each of the values
was cleared on the next check.  This is only done of course if we are
at libvirt 1.2.3 or later.

NOTE:
I tested the results for the "now" good case. I also built a libvirt prior
to the specific commit id and tested that if a zero was passed, then the
code would follow the path of the expected failure. As part of this same
build - I also tested the error path if the new code changes or fails
to clear the other fields, then emit a failure.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Merge pull request #82 from jferlan/version

provider: Add a libvirt_version
Merge pull request #83 from jferlan/domdisplay

virsh.domdisplay: Only add port if nonzero for vnc
Merge pull request #108 from jferlan/domiftune

Domiftune changes
Merge pull request #109 from jferlan/update_device

update_device: Revisit old changes and fix
Merge pull request #121 from jferlan/schedinfo_inspekt

schedinfo_qemu_posix: Resolve pep8/inspekt fixes
update_device: Add 'scsi' as an option

Add the ability to have a scsi cdrom as well as the ide cdrom for the test

Also fix the method call for LibVersionCompare to version_compare
Merge pull request #122 from jferlan/fixed_update_device

update_device: Add 'scsi' as an option
Merge pull request #106 from jferlan/list

virsh.list: When setting title, add proper option to virsh.desc
Merge pull request #102 from liyangfnst/reboot

libvirt.test: Add 'mode' test(agent) for virsh reboot