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>
guestfish_block_dev: Add two cases for test API

1. blockdev-rereadpt
2. canonical-device-name
guestfish_block_dev: Add three cases for test API

1. device-index
2. list-devices
3. disk-format
guestfish_block_dev: Add three cases to test API

1. max-disks
2. nr-devices
3. list-partitions
guestfish_block_dev: Add two cases to test API

1. disk-has-backing-file
2. disk-virtual-size
Add file_dir APIs: chmod, chown, lchown, du, file
Optimize checking logic for API:file
Adjust coding formats
pep8 fix
Merge pull request #119 from shi2wei3/file_dir_APIs

Add file_dir APIs: chmod, chown, lchown, du, file
Merge pull request #118 from vanbogithub/bfan-dev

guestfish_block_dev: Add total 10 cases to test APIs
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>