KVM-Test: kvm_monitor.py: Add function sendkey() for QMP monitor

QMP monitor doesn't support sendkey command, this function will
call sendkey in human command. With this function, we can send
key event via QMP monitor directly.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
Acked-by: Yiqiao Pu <ypu@redhat.com>
Acked-by: Feng Yang <fyang@redhat.com>
KVM-test: Add 'timeout' parameter for function human_monitor_cmd

Add 'timeout' parameter when need specify the cmd_timeout
using human_monitor_cmd().

Changes from v2:
 - Use CMD_TIMEOUT instead of hardcoded timeout value.

change from v1:
1. fix -- lack 'timeout' in return value of human_monitor_cmd()

Signed-off-by: Golita Yue <gyue@redhat.com>
Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
Acked-by: Feng Yang <fyang@redhat.com>
Acked-by: Xiaoqing Wei <xwei@redhat.com>
KVM Test: Add get_block, check_block_locked function to kvm_vm.py

get_block  could get specified block device from monitor.
check_block_locked check whether specified block device is locked or not.

Changes from v3:
 - Update get_block method's docstring.

Changes from v2:
 - Check 'value' in the beginning of check_block_locked
 - Make sure 'value' contains in the output of monitor command

Changes from v1:
Put these two functions to kvm_vm
Put all the parameters to p_dict dictionary.

Signed-off-by: Feng Yang <fyang@redhat.com>
Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
virt: kvm_monitor.py: Convent float number string to float type

send_arg_cmds can convent some types of string to python type.
This patch makes it convent float number string to float type.

Changes from V1:
 - Update regex string as ldoktor's advice.

Signed-off-by: Feng Yang <fyang@redhat.com>
Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
Acked-by: Xiaoqing Wei <xwei@redhat.com>
virt: Add migrate_set_downtime function for qmp monitor.

We already have this function for human monitor, so some case fail without this
function.

dd migrate_set_downtime function in kvm_monitor.

Signed-off-by: Feng Yang <fyang@redhat.com>
Acked-by: Qingtang Zhou <qzhou@redhat.com>
virt test: Add live_snapshot function in vm and monitor class

Add live_snapshot function in kvm_vm and kvm_monitor class. In
kvm_vm tests only need pass base image name, snapshot image name
and snapshot image format(default qcow2) to call live_snapshot.
The function will get the device id by itself.

Signed-off-by: Yiqiao Pu<ypu@redhat.com>
Acked-by: Suqin Huang <shuang@redhat.com>
virt: Make qmp cmd function support fd parameter

Also add getfd function for qmp class.

Signed-off-by: Feng Yang <fyang@redhat.com>
Acked-by: Yiqiao Pu <ypu@redhat.com>
virt-test: sync the Catch AttributeError and make screendump thread to go on

Add a missing warn message record line.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
virt: Add transparent hugepage set up in virt_env_process

Add the set up of transparent hugepage in virt_env_process as
hugepage set up. This will help to run a set of cases for
transparent hugepage easily.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
KVM-test: Add cpu_model by host cpuinfo

Aim to boot up guest with the cpu_model suit for host. Add
cpu_model in env. And all tests will read the cpu_model from
env if the params auto_cpu_model set to yes.

Changes from v1:
  - Use "\b: in pattern instead of make up string with ","
  - Fix the pattern flags and cpu_model name mistake
  - Clean up code
  - Add qemu-kvm support cpu_model check and the default cpu_model
    in different host
Changes from v2:
  - Fix cpu_model name mistake
  - Return a cpu_model string content all cpu_model can be used in
    the host and separated with ",". Set the cpu_model to the
    highest model that supported by current qemu-kvm.
Changes from v2:
   - Typo fix.
   - Make it more readable.
   - Disable the cpu model detect in cpu_flags test set as it will
     configure the cpu model they need inside the tests.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
Acked-by: Suqin Huang <shuang@redhat.com>
KVM Test: Set env setup and clean for SRIOV test

For a serial of SRIOV tests with the same module parameters, only
need to setup and clean up the env in the first and last test.
Otherwise some of the case will failed of module reload when the
pre-test will not kill guest. Use a flag to set the setup and
clean as following:
   00: do nothing
   01: setup env
   10: cleanup env
   11: setup and cleanup env
And this flag is for whole kvm test. It can be use for other tests
later has similar request. Please use bit operates (and, or) to
set the flag.

Change form v1:
  - Add missing part for PciAssignable Class in __init__ function
Change from v2:
  - type error fix
Change from v3:
  - Make the network restart optional
  - Move the host_setup_flag fix up inside of the execute loop

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
Acked-by: Qingtang Zhou <qzhou@redhat.com>
Acked-by: Suqin Huang <shuang@redhat.com>
virt: Add Fedora 17 to the list of guests

Also, make it the default guest for KVM autotest.

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