virt: introduce KVM monitor connection timeout

On some situations a job may get stuck forever trying to establish a
connection to a UNIX domain socket that connects the test code to
the qemu monitor.

This simple connection timeout won't fix all test problems, but will
avoid jobs that never finish properly.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
virt: Add comparison operator support for VirtNet

Signed-off-by: Chris Evich <cevich@redhat.com>
virt: set vnet_hdr to True when open the tap device

Set vnet_hdr to True to let the open_tap to check if IFF_VNET_HDR
is support in tun. Otherwise most of the flags of the device will
be set to off and the performance of the nic device will be poor.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
virt: Add host_setup_flag documentation to config files

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
install-script: fix mysqld restart routine
client: Recognize Centos vendor
client: Make vmlinux instalation configurable

Some installations has small /boot partitions so vmlinux instalation
is problematic.
client test: fix sources patching failure

Commit ce80096d388fd makes source directory configurable, so
patches are no longer accessible via hardcoded '../'
virt: Remove virtio console socket files after qemu exit

This patch moves 'get_virtio_port_filename' method to virt_vm
module, and create a 'get_virtio_port_filenames' method for
the cleanup step in vm destroy function.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt: Make serial port configurable

Now autotest only support one serial port, and it's name
and parameters are hardcode in script. This patch adds a
parameter called 'isa_serial' in config file, let user
can add more than one serials to one guest.

An example for this sia_serial parameter.
isa_serial = "S1 S2 S3"

Changes from v1:
 - Raise exception if 'isa_serial' parameter is incorrect set.
 - Update variant name definition.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
KVM Test: qemu_guest_agent: Test guest agent with isa-serial device

The qemu guest agent supports both virtio serial and isa serial, but
the original guest agent test only test it with virtio serial. This
patch add the missing part of isa serial testing.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt.kvm_monitor: Add a method to verify monitor cmd is supported by qemu

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt.guest_agent: Add shutdown parameter to shutdown method

The 'guest-shutdown' cmd in qemu guest agent has 3 modes:
 - 'powerdown': The default action for this command.
 - 'reboot': Reboot guest.
 - 'halt': halt guest directly.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt.guest_agent: Add suspend command for qemu guest agent

The 'guest-suspend-*' tries to execute the scripts provided
by the pm-utils package.  If it's not available, the suspend
operation will be performed by manually writing to a sysfs
file.
For the best results it's strongly recommended to have the
pm-utils package installed in the guest.

Qemu provides 3 modes to suspend guest:
 - "disk": Suspend guest to disk (S4)
    Note this "guest-suspend-disk" cmds won't return a response
    on success. Guest may quit with exit code 0 or return's a
    'shutdown' status when querying VM status via monitor.

 - "ram": Suspend guest to memory (S3)
    guest-suspend-ram requires QEMU to support the
    'system_wakeup' command. Thus, it's *required* to query
    QEMU for the presence of the 'system_wakeup' command
    before issuing guest-suspend-ram.
    Note: This command won't return a response on success.
    There are 2 ways to check guest status after issuing this
    command:
      * Wait for the SUSPEND QMP event from QEMU
      * Query VM status is "suspended" in QEMU monitor.

 - "hybird": Suspend guest to memory and disk
    guest-suspend-ram requires QEMU to support the
    'system_wakeup' command. Thus, it's *required* to query
    QEMU for the presence of the 'system_wakeup' command
    before issuing guest-suspend-ram.
    Note: This command won't return a response on success.
    There are 2 ways to check guest status after issuing this
    command:
      * Wait for the SUSPEND QMP event from QEMU
      * Query VM status is "suspended" in QEMU monitor.

Changes from v1:
 - Update random number generation method.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt.guest_agent: Add fsfreeze and fsthraw support

The "guest-fsfreeze-freeze" and "guest-fsfreeze-thaw" cmds are
used to freeze/unfreeze all freezable, local guest filesystems.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt: virtio_console: Fix virtio_console_guest.py script location

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virt: virtio_console: Fix log messages in migrate test

Fixes the incorrect function prefix in migrate virtio_console test.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
Removed duplicate "Importing modules" section

There were two sections discussing "Importing modules". I removed
the one that appeared to have the older example.

Signed-off-by: Daniel DeFolo <daniel.defolo@hp.com>
virt: Fix typo in VMConfigMissingError exception

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt-kvm/libvirt: Inherit needs_restart() metod

+ Both libvirt and KVM had nearly identical needs_restart
implimentations.  This patch allows them to inherit common checks while
allowing specialty checks via subclass overrides.

+ Fix networking bug in needs_restart() for virt-kvm and virt-libvirt.
Before each test, preprocess_vm() checks any VM instances stored in
env file against requested parameters, using vm.needs_restart().  However,
as implemented, only parameters encoded on the qemu or virt-install
command-line are tested.  This patch adds a check to also compare networking
parameters.

N.B. It does NOT verify non-networking related hot-added devices.

Signed-off-by: Chris Evich <cevich@redhat.com>