qemu_storage: Stop ignoring failures creating VM images

By default, the qemu_storage code is ignoring failures
when qemu-img fails to create a disk image. This happens
because the failure is actually considered only if the
(terribly undocumented) param 'check_output' is set to
yes.

Since there's no 'check_output' on any .cfg file
in the virt-test repo, the failures will never be
considered and virt-tests will happily proceed, even
though a world of pain and suffering will follow.

Since there are future tests that might require the
output of the creation command, we'll fix the problem
by:

1) Introducing a ignore_errors boolean parameter to
the .create() method, when set to true it'll make
the method to not raise an error on failure.

2) Making the method return a fixed tuple
(path to the image created, object with the result
of the command). With the result object, it is easy
to get outputs as they are attributes of the said
object.

This also has the nice side effect of not requiring
the check_output parameter anymore.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
qemu_storage: Be lenient and fix a missing parent image dir

If the parent directory of the image file is missing,
the qemu-img command will throw error messages that
are not very helpful. This condition usually indicates
a serious setup problem.

However, It is possible that the missing image dir is a
localized problem and the job can continue. So, instead of
erroring the test, like previously considered, just try
to create the missing parent image dir, and proceed with
the image creation, after logging the condition and giving
some idea to the tester what could be wrong there (if
the setup problem is so serious the test will fail anyway,
but now in a more clear and understandable way).

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
libvirt: Add test module for virsh {at|de}tach-disk

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
virt: Modify virsh function for virsh {at|de}tach-disk

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
virt: Add get_disk_count() for virsh {at|de}tach-disk

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
virt: qemu adds missing virt_test_type.

Signed-off-by: Jiří Župka <jzupka@redhat.com>
virt: Repairs config syntax

Signed-off-by: Jiří Župka <jzupka@redhat.com>
qemu_vm.py: increase the vm creation timeout

Because some old versions of qemu-kvm take more than we'd like to
initialize, and this is not a bug or one that will be fixed.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
qemu: Add macvtap support

This patch introduces using macvtap nic in test, when using
macvtap nic better have a switch support macvtap, if not,
need have a host with two nic devices when using this patch.

if you want to use macvtap in your test, just configure
"nettype = macvtap" in your .cfg file, or provide
--nettype macvtap as a flag for the virt test runner.

Signed-off-by: Yunping Zheng <yunzheng@redhat.com>
Merge pull request #300 from clebergnu/timeout_create
virttest.standalone_test: Bring in funcatexit to standalone_test

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
Implement nmi function in monitor

both HMP and QMP
Changlog:
use self.cmd() on QMP monitor

Signed-off-by: Xiaoqing Wei <xwei@redhat.com>
Acked-by: Lukas Doktor <ldoktor@redhat.com>
Update kdump case to use vm.monitor.nmi()

This would prevent case error when test with QMP
as it uses 'inject-nmi' instead of 'nmi'

Signed-off-by: Xiaoqing Wei <xwei@redhat.com>
Acked-by: Lukas Doktor <ldoktor@redhat.com>
qemu.tests.cgroup:modify the way to calculate the cpu counts

Modify code to catch the word 'processor' rather than 'model name'
in /proc/cpuinfo to count cpu number. Becasue the Power cpu haven't
the 'model name' field, and both x86 and Power cpu has the
'processor' field.

Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
Signed-off-by: Liu Sheng <liusheng@linux.vnet.ibm.com>
qemu.tests.time_manage:Fixed VM names error

Currently, the VM names has changed to like virt-tests-vm1 style.
But the VM names in test case time_manage are still the old version

Modify the VM names to the new style so the test case pass.

Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
Acked-by: Feng Yang <fyang@redhat.com>
qemu.tests.enospc: Fixed 'fuser -k' failed bug

Currently, when running the tests while the clean
up didn't run on the previous, it will raise an
error like:

Test failed: CmdError:
Command <fuser -k /dev/vg_kvm_test_enospc/lv_kvm_test_enospc>
failed, rc=1, Command returned non-zero exit status
[context: performing enospc setup --> performing enospc cleanup]
* Command:
    fuser -k /dev/vg_kvm_test_enospc/lv_kvm_test_enospc
Exit status: 1
Duration: 0.0501132011414

That is the link /dev/vg_kvm_test_enospc/lv_kvm_test_enospc
exist, but no user. thus the command line:
    fuser -k /dev/vg_kvm_test_enospc/lv_kvm_test_enospc
will return 1(fuser will always return none-zero for nobody use).

So just ignore the return status of the fuser.

Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
virt.qemu.tests.nic_bonding:Fix vm.netdev_id error

Nowadays, netdev_id has been a part of nic, and not
belongs to the vm object anymore.

At the sametime nic already has the key 'device_id', so
use nic.device_id is OK.

Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
Acked-by: Feng Yang <fyang@redhat.com>
virt:Make the clock_getres to support POWER guest

The name of the clock on Power guest is "timebase" which is
different from it counterpart in x86 "kvm-clock"

To makes it can work in both Power and x86 guest, add the
platform check.

Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
Merge pull request #304 from liyangfnst/attach_detach_disk

Add test for virsh {at|de}tach-disk
Merge pull request #310 from ypu/cleanup

virttest.standalone_test: Bring in funcatexit to standalone_test