virt-libvirt:modify function to get id and uuid for virsh managedsave

Hi Chris,Lucas:
I found that in virsh_managedsave.py, the way to get VM's id or uuid is
not very exacting,
so I changed it to use libvirt_vm's function.

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
virt-libvirt: Fix bug of virsh_save.cfg.

Last line said that No newline at end of file.
When we create subtests.cfg in libvirt project,
the end of virsh_save will like this:
(omit)
save_libvirtd = "off"    - virsh_setmem:
(omit)

Signed-off-by: Yu Mingfei<yumingfei@cn.fujitsu.com>
env_process: Try to find the best possible CPU model for qemu v2

When auto_cpu_model = yes, we'll try to find the best
CPU model to be used by qemu, the process being:

1) Find the host CPU model
2) Try to pass it to qemu

We used to ignore invalid CPU models passed to qemu
in qemu_vm code, but we had to change that to allow
negative CPU model testing. So the sanity check of
whether the CPU model is valid has to be made way
earlier in the code.

Therefore, introduce get_qemu_best_cpu_model, that
will find the host CPU model and then check this
value against the valid CPU models on qemu. In case
there's no such cpu model in qemu, chose a sensible
default value (default_cpu_model if it is defined
in the params dict, or 'qemu64').

The new functions introduced to utils_misc are:
 * get_host_cpu_models -> Rename of get_cpu_model
 * get_qemu_cpu_models
 * extract_qemu_cpu_models
 * get_qemu_best_cpu_model

Some of the functions were extracted from the
cpuid test. In the next patch, we make the
test to use the new functions.

Changes from v1:
 * Refactor code to get qemu cpu models to its
   own function on utils_misc
 * Make the code actually work, by making
   involved functions to return lists

CC: Eduardo Habkost <ehabkost@redhat.com>
CC: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
cpuid: Make use of new functions on utils_misc

Make use of extract_cpu_models() on cpuid test.
One of the patches from ehabkost introducing
get_qemu_cpu_models would have to be rebased
according to the fact they were introduced
earlier by this patchset.

CC: Eduardo Habkost <ehabkost@redhat.com>
CC: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
virt-test: fix disable-kvm once more

If config has only 'disable-kvm=yes' but not 'enable-kvm=no'
qemu will be started in kvm mode and with kvm disabled at
compile time it fails to launch.

Currently disable/enable-kvm config options and qemu supported
options are intermingled in a bunch of ifs, separate apples
and oranges in different bins and make logic straightforward:

* alias disable-kvm to enable-kvm param
* get right option set to disable/enable kvm on qemu/qemu-kvm
* set appropriate option depending on value of param enable-kvm

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
virt-test: run cpuid.custom variants without kvm

cpuid.custom will fail if qemu is built without kvm,
due to virt-test tries to start qemu in kvm mode.

To fix it run custom variants in TCG mode, since they do
not have anything kvm specific.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
qemu_cpu.cfg: disable qemu-version-specific test cases by default

Instead of just defining rhel64 and qemu13 and enabling both by default,
define rhel64, qemu13, and unknown_qemu.

unknown_qemu will be enabled by default, so we don't test for things
that may fail on non-RHEL-6 or non-qemu-1.3 hosts. This should make the
tests work by default on most hosts, until we implement some kind of
host-based autoconfiguration system.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu_cpu.cfg: set auto_cpu_model = no

Without this option, autotest will set a "cpu_model" config option by
itself.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu/cpuid: use utils_misc.get_qemu_cpu_models() function

With this change, the test_qemu_cpu_models_list() command won't include
the full QEMU "-cpu ?" output in the test failure message anymore, but
it can be found in the test logs if necessary.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu/cpuid: default_vendor: support both single-model and multi-model mode

I don't know yet what will be the best way to configure the tests, but
this changes the test code to allow both modes to be used: a single
model can be set using the "cpu_model" option, or multiple models may be
tested using the "cpu_models" option. Or, if cpu_models is "*", all
models reported by QEMU can be tested (that was the current behavior
when cpu_models was not set).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu/cpuid: check_models: use cpu_models_to_test()

This way we can use the "cpu_model" config option to check for a single
CPU model, if necessary.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu/cpuid: default_vendor: accept "host" as special vendor value

This allows us to make the configuration clearer than just omitting the
vendor value.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu_cpu.cfg: put "cpuid defaults" and "cpuid custom" in a "cpuid" block

This shouldn't have any visible change, but it will make it easier to
review the changes made later when introducing the per-CPU-model
variants.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu_cpu.cfg: create per-CPU-model variants

This will allow us to more easily filter and combine CPU models with the
multiple test cases we have. We can easily introduce new tests that will
automatically be run once for each known CPU model.

Test cases that don't need to be re-run for each CPU model can use the
"cpu.unset" variant that doesn't set any specific cpu_model option.

This also introduces "kvm" and "nokvm" variants, to allow test cases to
be run with KVM disabled and enabled, if necessary.

This way the test output will now look like this:

    (1/94) qemu_cpu.check_models.kvm.cpu.intel.486.qemu13: PASS (0.42 s)
    (2/94) qemu_cpu.check_models.kvm.cpu.intel.core2duo.qemu13: PASS (0.44 s)
    [...]
    (49/94) qemu_cpu.cpuid.default.vendor.nokvm.cpu.intel.core2duo.qemu13: PASS (20.63 s)
    (50/94) qemu_cpu.cpuid.default.vendor.nokvm.cpu.intel.kvm32.qemu13: PASS (21.66 s)
    [...]
    (62/94) qemu_cpu.cpuid.default.vendor.nokvm.cpu.intel.SandyBridge.qemu13: PASS (20.58 s)
    (63/94) qemu_cpu.cpuid.default.vendor.nokvm.cpu.intel.Haswell.qemu13: PASS (20.52 s)
    (64/94) qemu_cpu.cpuid.default.vendor.nokvm.cpu.amd.qemu64.qemu13: PASS (21.51 s)
    (65/94) qemu_cpu.cpuid.default.vendor.nokvm.cpu.amd.phenom.qemu13: PASS (20.53 s)
    [...]
    (71/94) qemu_cpu.cpuid.default.vendor.nokvm.cpu.amd.Opteron_G5.qemu13: PASS (21.59 s)
    (72/94) qemu_cpu.cpuid.custom.vendor.normal.kvm.cpu.unset.qemu13: PASS (20.53 s)
    (73/94) qemu_cpu.cpuid.custom.vendor.tooshort.kvm.cpu.unset.qemu13: PASS (0.87 s)
    (74/94) qemu_cpu.cpuid.custom.vendor.empty.kvm.cpu.unset.qemu13: PASS (0.81 s)
    (75/94) qemu_cpu.cpuid.custom.level.level5.kvm.cpu.unset.qemu13: PASS (20.60 s)
    [...]

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
qemu_cpu.cfg: run cpuid.custom test cases with and without KVM

This will help us check if we didn't break anything in KVM-specific or
TCG-specific code inside QEMU.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
test virtio_console: Raise TestFail in case of failure

Some tests (polling, sigio, rmmod, ...) raised VirtioPortException
instead of TestFailure. This might be confusing so let's raise
TestFail + original traceback instead.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
test virtio_console: wait for data in rw_nonblocking_mode test

On heavy loaded VM data might not yet be available, give
the machine second chance in case of Errno 11.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
virttest.standalone_test: Fix logging parameter

Use variables instead of tuple in logging.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
qemu.tests: Add a new test: Migrate after NIC hotplug

commit 9eaa33dd1abe85141d2eee48c9712c69dcb4edff
    Author: Yiqiao Pu <ypu@redhat.com>
    Date:   Mon Aug 1 11:15:22 2011 +0000

    KVM-test: Add a new test: Migrate after NIC hotplug

    https://tcms.engineering.redhat.com/case/69571/?from_plan=3083

    Migrate VM which was hotpluged a nic, and test if new nic works.
    This test reuses nic_add()/nic_del()/netdev_add()/netdev_del()
    in nic_hotplug.py, need put them the kvm_test_utils.py later.
    This test only works with latest qemu-kvm.

    Signed-off-by: Yiqiao Pu <ypu@redhat.com>

    commit 324c09e2302a785893bc4a20ea79a24b2fa81a29
    Author: Qingtang Zhou <qzhou@redhat.com>
    Date:   Tue Jun 26 16:38:50 2012 +0000

    virt: Update 'guest_name' to 'os_type' in all scripts

    Checking guest os type with 'guest_name' parameter may not
    always work for all guests, and not supported by upstream.
    Thus update all these places to using 'os_type'.

    RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=835505

    Signed-off-by: Qingtang Zhou <qzhou@redhat.com>
    Acked-by: Yiqiao Pu <ypu@redhat.com>

    commit a54f0381cb8703efeb72f43a684e11e733215bdf
    Author: Feng Yang <fyang@redhat.com>
    Date:   Fri Dec 21 08:57:27 2012 +0000

    migration_after_nichotplug.py: update it with vm.hotplug_nic()

    Use VM's hotplug_nic() function.
    Update step docs and error.context()
    Make this script works again.

    BZID:
    Bug 874433 - [KVM_Autotest] nic_hotplug.migration: Please update your code
     to use VirtNet.generate_mac_address()
    Bug 889390 - [KVM_AUTOTEST] Update migration_after_nichotplug.py to reuse
     some framework function.

    Signed-off-by: Feng Yang <fyang@redhat.com>
    Acked-by: Qingtang Zhou <qzhou@redhat.com>

Send this script to upstream.
Signed-off-by: Feng Yang <fyang@redhat.com>
nic_hotplug.cfg: Add migration_after_nichotplug test case.

Signed-off-by: Feng Yang <fyang@redhat.com>