client: xml_utils documentation update

I noticed some confusion on intended usage of some of the classes.
Added extensive documentation regarding design intent and references
to additional examples and docs.

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

* Improved LibvirtXMLError exception with optional string argument
* Added module docstring
* Added LibvirtXMLBase base-class for common methods/attributes
* Added simple LibvirtXML class

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-libvirt: libvirt_vm bug fix

If the action is status, the funtion is supposed to return True when libvirtd
    service is running,otherwise return False if its stopped.
    However in this case since the function calls utilis.run without
    ignore_status=True, if the libvirtd service is stopped, then a CmdError
    is raised and the utils.run function fails to return after raising the
    error, in which case service_libvirtd_control(status) will never return false
    when libvirtd service is stopped.

    The fix will be to use ignore_status=True while calling utils.run,
    so that it can return if there is a CmdError, in case libvirtd is
    stopped.

Signed-off-by: Prem Karat <prem.karat@linux.vnet.ibm.com>
virt.storage: Backup both good and bad images upon disk corruption

It's useful to have both the good image created
at unattended install time and, when the image
gets corrupted, the bad image, both with the same
unique suffix. So expand the backup image method
to handle this behavior accordingly, and also
simplify the logic used on that method.

CC: Cleber Rosa <cleber@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt.kvm_vm: Skip adding interface to TAP if it's already present

This is a solution for issue #520 - when trying to create
a TAP device, the interface might be already a member of
the bridge, so the addition will fail with an IOError, with
errno == errno.EBUSY (device or resource busy). That IOError
will be wrapped in our TAPCreationError exception. So, when
performing the operation, catch the TAPCreationError and
verify errno of the detail attribute, if it's errno.EBUSY,
skip the addition operation and continue.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt.kvm_vm: Add prefix/disable_kvm/disable_shutdown support

This patch adds the following new config keys for
the virt tests (kvm variant):

 1) Add prefix to the qemu cmd (ex: valgrind)
 2) Explicitly add -no-kvm to the qemu cmd
 3) Explicitly add -no-shutdown to the qemu cmd

Document the additions on base.cfg.

Signed-off-by: Yunping Zheng <yunzheng@redhat.com>
virt.kvm_vm: Adding bios_path to pass custom bios path

Sometimes people need to use customized bios, eg: for debugging.

Signed-off-by: Xiaoqing Wei <xwei@redhat.com>
virt.kvm_vm: Don't regenerate spice cert when they already exist

Now autotest alway regenerates certs before run/boot
a guest, which is not needed, and sometimes could be
a disaster when one has a running VM, since re-generate
the certs would make your existing VM no longer accessible.

Signed-off-by: Xiaoqing Wei <xwei@redhat.com>
virt.utils_misc: Write keyvals of the kernel version used

We want to display kernel versions used for virt jobs, so
let's record the kernel used in each scenario right from
the install_host_kernel helper function.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: Remove temporarily virsh_unittest

As it needs to be reworked post virt test refactoring.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
client: xml_utils cleanup / enhancements

+ ElementTree's remove method only operates on an element, and normally it
  is a child element you need to remove.  Add remove() to XMLTreeFile
  that utilizes a method for locating the parent element.

Signed-off-by: Yu Mingfei<yumingfei@cn.fujitsu.com>

+ The automatic removal of temporary files behavior was inconsistent
  between various classes. Special methods moved into base-class to
  unify behavior.

+ Unit tests updated to confirm exceptional exits
  retain specially-named backup files for debugging.  Normal exits
  auto-delete, and unittests fail if auto-delete doesn't happen as expected.

+ TemplateXML class, __init__ method is very sensitive to XMLTreeFile
  __init__behavior.  Cleaned up comments to make this more clear.

+ Added XMLTreeFile.backup_copy() method to make producing additional
  temporary backups easy.  Added unittests that confirm backup
  files behave correctly.

+ Added XMLTreeFile.remove_by_xpath() method to enhance Yu's remove
  method and make removing elements by name/path convenient.

Signed-off-by: Chris Evich <cevich@redhat.com>
virt-libvirt: virsh param handling bugfix

Signed-off-by: Chris Evich <cevich@redhat.com>
client: Moving client/virt to client/tests/virt

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: Moving sample cfg files to shared/cfg

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: Moving libs to virttest lib dir

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: Moving common dirs to shared

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt: Moving cartesian parser to virttest library

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Moving kvm libvirt v2v to virt

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt.kvm: Move sample cfg files to cfg subdir

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt.libvirt: Moving sample config files to cfg

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